Skip to content

Commit 981123b

Browse files
edmondstohojo
authored andcommitted
Explicitly set PREFIX=/ when installing libbpf headers
When xdp-tools builds the embedded copy of libbpf, it invokes the libbpf build system to installs it headers, and then constructs a path to those embedded libbpf headers [0] based on the assumption that libbpf installed its headers into its default PREFIX value of /usr. However, if PREFIX is passed to the xdp-tools build system, this variable gets passed down to the invocation of the libbpf build system as well, and libbpf installs its headers into a different directory that doesn't match xdp-tools' LIBBPF_INCLUDE_DIR variable, and the build fails like this: $ make PREFIX=/usr/local […] libbpf support: Submodule 'libbpf' (https://github.com/libbpf/libbpf.git) registered for path 'lib/libbpf' Cloning into '/home/edmonds/src/xdp-tools/lib/libbpf'... Submodule path 'lib/libbpf': checked out 'fdf402b384cc42ce29bb9e27011633be3cbafe1e' submodule v1.4.0 […] lib libbpf CC libbpf/src/libbpf.a INSTALL libbpf/src/libbpf.a libxdp CC staticobjs/libxdp.o libxdp.c:31:10: fatal error: bpf/libbpf.h: No such file or directory 31 | #include <bpf/libbpf.h> | ^~~~~~~~~~~~~~ compilation terminated. This commit explicitly passes PREFIX=/ to the libbpf build system when installing the embedded libbpf headers, and also updates the LIBBPF_INCLUDE_DIR variable in the xdp-tools build system to match the resulting include path, so that the embedded libbpf headers are installed into a fixed location. [0]: https://github.com/xdp-project/xdp-tools/blob/7b3bbe2f6f16d658bb09a7b7e5958f4a49825ee6/configure#L382 Signed-off-by: Robert Edmonds <[email protected]>
1 parent 289c8eb commit 981123b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ EOF
379379
fi
380380

381381
LIBBPF_VERSION=$(get_libbpf_version "lib/libbpf/src")
382-
LIBBPF_INCLUDE_DIR='$(LIB_DIR)/libbpf/src/root/usr/include'
382+
LIBBPF_INCLUDE_DIR='$(LIB_DIR)/libbpf/src/root/include'
383383
LIBBPF_LIB_DIR='$(LIB_DIR)/libbpf/src'
384384
OBJECT_LIBBPF="${LIBBPF_LIB_DIR}/libbpf.a"
385385
echo "submodule v$LIBBPF_VERSION"

lib/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ LIBBPF_SOURCES := $(wildcard libbpf/src/*.[ch])
4848
libbpf/src/libbpf.a: $(LIBBPF_SOURCES)
4949
@echo ; echo " libbpf"
5050
$(QUIET_CC)$(MAKE) -C libbpf/src CFLAGS="$(LIBBPF_CFLAGS)" $P
51-
$(QUIET_INSTALL)$(MAKE) -C libbpf/src install_headers DESTDIR=root $P
51+
$(QUIET_INSTALL)$(MAKE) -C libbpf/src install_headers DESTDIR=root PREFIX=/ $P
5252

5353
libbpf_clean:
5454
$(Q)$(MAKE) -C libbpf/src clean $P

0 commit comments

Comments
 (0)