Integrate libxdp as a submodule

This adds libxdp as a submodule and link target alongside libbpf. This
should make it just as easy for examples to use libxdp as it currently is
for libbpf. Some hoops need to be jumped through to make libxdp link
against the same version of libbpf as the one we use in this repository.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
This commit is contained in:
Toke Høiland-Jørgensen
2021-10-15 13:27:49 +02:00
parent 58fcc521b7
commit ff3e4272ff
6 changed files with 85 additions and 9 deletions

View File

@@ -2,17 +2,18 @@
LIBBPF_CFLAGS:=$(if $(CFLAGS),$(CFLAGS),-g -O2 -Werror -Wall) -fPIC
LIB_DIR = .
LIB_INSTALL := lib-install
include defines.mk
SUBDIRS=
all: $(OBJECT_LIBBPF)
all: $(OBJECT_LIBBPF) $(OBJECT_LIBXDP)
@set -e; \
for i in $(SUBDIRS); \
do echo; echo " $$i"; $(MAKE) -C $$i; done
.PHONY: clean
clean: libbpf_clean
clean: libbpf_clean libxdp_clean
@for i in $(SUBDIRS); \
do $(MAKE) -C $$i clean; done
@@ -21,7 +22,9 @@ install:
$(MAKE) -C libxdp install
$(MAKE) -C testing install
libbpf: $(OBJECT_LIBBPF)
libxdp: libbpf $(OBJECT_LIBXDP)
# Handle libbpf as git submodule
ifeq ($(SYSTEM_LIBBPF),n)
@@ -31,21 +34,45 @@ endif
# Detect submodule libbpf source file changes
LIBBPF_SOURCES := $(wildcard libbpf/src/*.[ch])
LIBBPF_INSTALL := libbpf-install
INSTDIR=../../$(LIBBPF_INSTALL)
.PHONY: libbpf_clean
libbpf/src/libbpf.a: $(LIBBPF_SOURCES)
@echo ; echo " libbpf"
$(QUIET_CC)$(MAKE) -C libbpf/src CFLAGS="$(LIBBPF_CFLAGS)" $P
$(QUIET_INSTALL)$(MAKE) -C libbpf/src DESTDIR=$(INSTDIR) install_headers $P
$(QUIET_INSTALL)$(MAKE) -C libbpf/src DESTDIR=../../$(LIB_INSTALL) install_headers $P
.PHONY: libbpf_clean
libbpf_clean:
$(Q)$(MAKE) -C libbpf/src clean $P
$(Q)$(RM) -r $(LIBBPF_INSTALL)
$(Q)$(RM) -r $(LIB_INSTALL)
else
libbpf_clean:
@echo -n
endif
# Handle libbpf as git submodule
ifeq ($(SYSTEM_LIBXDP),n)
ifeq ($(VERBOSE),0)
P:= >/dev/null
endif
# Detect submodule libbpf source file changes
LIBXDP_SOURCES := $(wildcard xdp-tools/lib/libxdp/*.[ch])
$(LIB_INSTALL)/usr/lib/libxdp.a: $(LIBXDP_SOURCES)
@echo ; echo " libxdp"
$(QUIET_CC)$(MAKE) -C xdp-tools BUILD_STATIC_ONLY=1 libxdp $P
$(QUIET_INSTALL)$(MAKE) -C xdp-tools DESTDIR=../../../$(LIB_INSTALL) PREFIX=/usr BUILD_STATIC_ONLY=1 libxdp_install $P
.PHONY: libxdp_clean
libxdp_clean:
$(Q)$(MAKE) -C xdp-tools clean $P
$(Q)$(RM) -r $(LIB_INSTALL)
else
libxdp_clean:
@echo -n
endif