diff mbox series

[1/2] configure: provide surrogates for possibly missing libbpf_version.h

Message ID 20240811223135.1173783-2-stefan.maetje@esd.eu (mailing list archive)
State Accepted
Commit 0ddadc93e54f20e35cb742701413ede88ea00471
Delegated to: Stephen Hemminger
Headers show
Series iproute2: ss: clarify build warnings when building with libbpf 0.5.0 | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Stefan Mätje Aug. 11, 2024, 10:31 p.m. UTC
Old libbpf library versions (< 0.7.x) may not have the libbpf_version.h
header packaged. This header would provide LIBBPF_MAJOR_VERSION and
LIBBPF_MINOR_VERSION which are then missing to control conditional
compilation in some source files.

Provide surrogates for these defines via CFLAGS that are derived from
the LIBBPF_VERSION determined with $(${PKG_CONFIG} libbpf --modversion).

Signed-off-by: Stefan Mätje <stefan.maetje@esd.eu>
---
 configure | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/configure b/configure
index 928048b3..7437db4f 100755
--- a/configure
+++ b/configure
@@ -315,6 +315,12 @@  check_libbpf()
         echo "HAVE_LIBBPF:=y" >> $CONFIG
         echo 'CFLAGS += -DHAVE_LIBBPF ' $LIBBPF_CFLAGS >> $CONFIG
         echo "CFLAGS += -DLIBBPF_VERSION=\\\"$LIBBPF_VERSION\\\"" >> $CONFIG
+	LIBBPF_MAJOR=$(IFS="."; set $LIBBPF_VERSION; echo $1)
+	LIBBPF_MINOR=$(IFS="."; set $LIBBPF_VERSION; echo $2)
+	if [ "$LIBBPF_MAJOR" -eq 0 -a "$LIBBPF_MINOR" -lt 7 ]; then
+	    # Newer libbpf versions provide these defines in the bpf/libbpf_version.h header.
+            echo "CFLAGS += -DLIBBPF_MAJOR_VERSION=$LIBBPF_MAJOR -DLIBBPF_MINOR_VERSION=$LIBBPF_MINOR" >> $CONFIG
+	fi
         echo 'LDLIBS += ' $LIBBPF_LDLIBS >> $CONFIG
 
         if [ -z "$LIBBPF_DIR" ]; then