diff --git a/Makefile b/Makefile index 5c22e854..d5dc21fb 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,14 @@ MAKEFLAGS += --no-print-directory endif include version.mk +include config.mk + +UTILS := xdp-filter xdp-loader xdp-dump + +ifneq ($(BPFTOOL),) +UTILS += xdp-bench xdp-monitor xdp-trafficgen +endif -UTILS := xdp-filter xdp-loader xdp-dump xdp-bench xdp-monitor xdp-trafficgen SUBDIRS := lib $(UTILS) .PHONY: check_submodule help clobber distclean clean install test libxdp $(SUBDIRS) diff --git a/configure b/configure index e75090e0..1c71ec94 100755 --- a/configure +++ b/configure @@ -73,7 +73,7 @@ check_toolchain() CLANG=$(find_tool clang "$CLANG") LLC=$(find_tool llc "$LLC") - for TOOL in $PKG_CONFIG $CC $LD $OBJCOPY $CLANG $LLC $M4 $BPFTOOL $READELF; do + for TOOL in $PKG_CONFIG $CC $LD $OBJCOPY $CLANG $LLC $M4 $READELF; do if [ ! $(command -v ${TOOL} 2>/dev/null) ]; then echo "*** ERROR: Cannot find tool ${TOOL}" ; exit 1; @@ -112,12 +112,12 @@ check_toolchain() exit 1 fi - if $BPFTOOL gen help 2>&1 | grep 'gen skeleton.*name' > /dev/null; then + if command -v $BPFTOOL &>/dev/null && $BPFTOOL gen help 2>&1 | grep 'gen skeleton.*name' > /dev/null; then bpftool_version=$($BPFTOOL version | head -n 1) echo "using $bpftool_version" else - echo "bpftool doesn't support skeleton generation" - exit 1 + echo "bpftool not found or doesn't support skeleton generation; not building all tools" + BPFTOOL= fi if [ -z "$ARCH_INCLUDES" ] && [ -n "$ARCH_NAME" ]; then @@ -137,8 +137,9 @@ check_toolchain() echo "M4:=${M4}" >>$CONFIG echo "EMACS:=${EMACS}" >>$CONFIG echo "ARCH_INCLUDES:=$ARCH_INCLUDES" >> $CONFIG - echo "BPFTOOL:=${BPFTOOL}" >> $CONFIG echo "READELF:=${READELF}" >> $CONFIG + echo "BPFTOOL:=${BPFTOOL}" >> $CONFIG + [ -n "$BPFTOOL" ] && echo "HAVE_FEATURES+=BPFTOOL" >>"$CONFIG" } check_zlib() diff --git a/lib/testing/test-tool.c b/lib/testing/test-tool.c index 3dd5270a..95f76cb3 100644 --- a/lib/testing/test-tool.c +++ b/lib/testing/test-tool.c @@ -205,10 +205,14 @@ int do_probe(const void *cfg, __unused const char *pin_root_path) switch (opt->action) { case PROBE_CPUMAP_PROGRAM: +#ifdef HAVE_BPFTOOL res = sample_probe_cpumap_compat(); +#endif break; case PROBE_XDP_LOAD_BYTES: +#ifdef HAVE_BPFTOOL res = sample_probe_xdp_load_bytes(); +#endif break; default: return EXIT_FAILURE; diff --git a/lib/util/util.mk b/lib/util/util.mk index 2b6a2e08..6c9ebaf0 100644 --- a/lib/util/util.mk +++ b/lib/util/util.mk @@ -1,2 +1,11 @@ -UTIL_OBJS := params.o logging.o util.o stats.o xpcapng.o xdp_sample.o -UTIL_BPF_OBJS := xdp_sample.bpf.o xdp_load_bytes.bpf.o +LIB_DIR ?= .. +include $(LIB_DIR)/defines.mk + +UTIL_OBJS := params.o logging.o util.o stats.o xpcapng.o +UTIL_BPF_OBJS := + +ifneq ($(BPFTOOL),) +UTIL_OBJS += xdp_sample.o +UTIL_BPF_OBJS += xdp_sample.bpf.o xdp_load_bytes.bpf.o +endif +