Skip to contentSkip to conversation

configure: Add option to enable/disable libnfnetlink

PATCH In review Alexander Kanavin 2 participants 2 messages Apr 25, 2024 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 configure: Add option to enable/disable libnfnetlink

From: "Maxin B. John" <[email protected]>

Default behavior (autodetecting) does not change, but specifying either option would explicitly disable or enable libnfnetlink support, and if the library is not found in the latter case, ./configure will error out.

---
 configure.ac | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
configure.ac +11 -2
index d99fa3b9..c9194da0 100644
@@ -63,6 +63,9 @@ AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=PATH],
 AC_ARG_ENABLE([nftables],
 	AS_HELP_STRING([--disable-nftables], [Do not build nftables compat]),
 	[enable_nftables="$enableval"], [enable_nftables="yes"])
+AC_ARG_ENABLE([libnfnetlink],
+    AS_HELP_STRING([--disable-libnfnetlink], [Do not use netfilter netlink library]),
+    [enable_libnfnetlink="$enableval"], [enable_libnfnetlink="auto"])
 AC_ARG_ENABLE([connlabel],
 	AS_HELP_STRING([--disable-connlabel],
 	[Do not build libnetfilter_conntrack]),
@@ -113,8 +116,14 @@ AM_CONDITIONAL([ENABLE_SYNCONF], [test "$enable_nfsynproxy" = "yes"])
 AM_CONDITIONAL([ENABLE_NFTABLES], [test "$enable_nftables" = "yes"])
 AM_CONDITIONAL([ENABLE_CONNLABEL], [test "$enable_connlabel" = "yes"])
 
-PKG_CHECK_MODULES([libnfnetlink], [libnfnetlink >= 1.0],
-	[nfnetlink=1], [nfnetlink=0])
+# If specified explicitly on the command line, error out when library was not found
+AS_IF([test "x$enable_libnfnetlink" = "xyes"], [
+    PKG_CHECK_MODULES([libnfnetlink], [libnfnetlink >= 1.0], [nfnetlink=1])
+    ])
+# Otherwise, disable and continue
+AS_IF([test "x$enable_libnfnetlink" = "xauto"], [
+    PKG_CHECK_MODULES([libnfnetlink], [libnfnetlink >= 1.0], [nfnetlink=1], [nfnetlink=0])
+    ])
 AM_CONDITIONAL([HAVE_LIBNFNETLINK], [test "$nfnetlink" = 1])
 
 if test "x$enable_bpfc" = "xyes" || test "x$enable_nfsynproxy" = "xyes"; then
Signature · 1 line
2.39.2
reviewer
#1 lore raw
Quoted 6 lines · Alexander Kanavin

From: "Maxin B. John" <[email protected]>

Default behavior (autodetecting) does not change, but specifying either option would explicitly disable or enable libnfnetlink support, and if the library is not found in the latter case, ./configure will error out.

Thanks for following up! I applied the patch after merging the two AS_IF() calls: AS_IF supports building "else if"-like chains of conditions.

Cheers, Phil