]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
build: use pkg-config for libpcap
authorAlyssa Ross <hi@alyssa.is>
Sun, 2 Apr 2023 23:29:40 +0000 (23:29 +0000)
committerPhil Sutter <phil@nwl.cc>
Tue, 4 Apr 2023 11:38:07 +0000 (13:38 +0200)
If building statically, with libpcap built with libnl support, linking
will fail, as the compiler won't be able to find the libnl symbols
since static libraries don't contain dependency information.  To fix
this, use pkg-config to find the flags for linking libpcap, since the
pkg-config files contain the neccesary dependency information.

autoconf will add code to the configure script for initializing
pkg-config the first time it seems PKG_CHECK_MODULES, so make the
libnfnetlink check the first one in the script, so the initialization
code is run unconditionally.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
Signed-off-by: Phil Sutter <phil@nwl.cc>
configure.ac
utils/Makefile.am

index bc2ed47b78653744e7ed03aa59d24f352e5c3985..488c01eb68a2319ae20447bb65a8cef6923d24c6 100644 (file)
@@ -113,14 +113,15 @@ AM_CONDITIONAL([ENABLE_SYNCONF], [test "$enable_nfsynproxy" = "yes"])
 AM_CONDITIONAL([ENABLE_NFTABLES], [test "$enable_nftables" = "yes"])
 AM_CONDITIONAL([ENABLE_CONNLABEL], [test "$enable_connlabel" = "yes"])
 
-if test "x$enable_bpfc" = "xyes" || test "x$enable_nfsynproxy" = "xyes"; then
-       AC_CHECK_LIB(pcap, pcap_compile,, AC_MSG_ERROR(missing libpcap library required by bpf compiler or nfsynproxy tool))
-fi
-
 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
+       PKG_CHECK_MODULES([libpcap], [libpcap], [], [
+               AC_MSG_ERROR(missing libpcap library required by bpf compiler or nfsynproxy tool)])
+fi
+
 if test "x$enable_nftables" = "xyes"; then
        PKG_CHECK_MODULES([libmnl], [libmnl >= 1.0], [mnl=1], [mnl=0])
 
index e9eec48ffc3b594fcadf5bfaa2b3b50d1fe1b528..3405651477ea1eace3c1b801ec930062c1c621a8 100644 (file)
@@ -2,7 +2,7 @@
 
 AM_CFLAGS = ${regular_CFLAGS}
 AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_builddir}/include \
-              -I${top_srcdir}/include ${libnfnetlink_CFLAGS}
+              -I${top_srcdir}/include ${libnfnetlink_CFLAGS} ${libpcap_CFLAGS}
 AM_LDFLAGS = ${regular_LDFLAGS}
 
 sbin_PROGRAMS =
@@ -25,12 +25,12 @@ endif
 if ENABLE_BPFC
 man_MANS += nfbpf_compile.8
 sbin_PROGRAMS += nfbpf_compile
-nfbpf_compile_LDADD = -lpcap
+nfbpf_compile_LDADD = ${libpcap_LIBS}
 endif
 
 if ENABLE_SYNCONF
 sbin_PROGRAMS += nfsynproxy
-nfsynproxy_LDADD = -lpcap
+nfsynproxy_LDADD = ${libpcap_LIBS}
 endif
 
 CLEANFILES = nfnl_osf.8 nfbpf_compile.8