@@ -240,6 +240,51 @@ check_elf()
fi
}
+check_libbpf()
+{
+ if ${PKG_CONFIG} libbpf --exists || [ -n "$LIBBPF_DIR" ] ; then
+
+ if [ -n "$LIBBPF_DIR" ]; then
+ LIBBPF_CFLAGS="-I${LIBBPF_DIR}/include -L${LIBBPF_DIR}/lib64"
+ LIBBPF_LDLIBS="${LIBBPF_DIR}/lib64/libbpf.a -lz -lelf"
+ else
+ LIBBPF_CFLAGS=$(${PKG_CONFIG} libbpf --cflags)
+ LIBBPF_LDLIBS=$(${PKG_CONFIG} libbpf --libs)
+ fi
+
+ cat >$TMPDIR/libbpftest.c <<EOF
+#include <bpf/libbpf.h>
+int main(int argc, char **argv) {
+ void *ptr;
+ DECLARE_LIBBPF_OPTS(bpf_object_open_opts, opts, .relaxed_maps = true, .pin_root_path = "/path");
+ (void) bpf_object__open_file("file", &opts);
+ (void) bpf_map__name(ptr);
+ (void) bpf_map__ifindex(ptr);
+ (void) bpf_map__reuse_fd(ptr, 0);
+ (void) bpf_map__pin(ptr, "/path");
+ return 0;
+}
+EOF
+
+ if $CC -o $TMPDIR/libbpftest $TMPDIR/libbpftest.c $LIBBPF_CFLAGS -lbpf 2>&1; then
+ echo "HAVE_LIBBPF:=y" >>$CONFIG
+ echo 'CFLAGS += -DHAVE_LIBBPF ' $LIBBPF_CFLAGS >> $CONFIG
+ echo 'LDLIBS += ' $LIBBPF_LDLIBS >>$CONFIG
+ echo "yes"
+ return 0
+ fi
+ fi
+
+ echo "no"
+
+ # if set FORCE_LIBBPF but no libbpf support, just exist the config
+ # process to make sure we don't build without libbpf.
+ if [ -n "$FORCE_LIBBPF" ]; then
+ echo "FORCE_LIBBPF set, but couldn't find a usable libbpf"
+ exit 1
+ fi
+}
+
check_selinux()
# SELinux is a compile time option in the ss utility
{
@@ -385,6 +430,9 @@ check_setns
echo -n "SELinux support: "
check_selinux
+echo -n "libbpf support: "
+check_libbpf
+
echo -n "ELF support: "
check_elf