[PATCH] Detect libpcap dependencies using pkg-config

8 views
Skip to first unread message

Baruch Siach

unread,
Sep 2, 2021, 8:07:49 AM9/2/21
to netsn...@googlegroups.com, Tobias Klauser, Baruch Siach
When building statically the link command line must include all
dependencies of all libraries. libpcap can optionally depend on libnl.
mausezahn can't build statically in this case.

Use pkg-config in configure and in the link command to construct the
library flags we need to link with libpcap.

Signed-off-by: Baruch Siach <bar...@tkos.co.il>
---
configure | 4 +++-
mausezahn/Makefile | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 510826a798f5..598ae2433a7a 100755
--- a/configure
+++ b/configure
@@ -588,7 +588,9 @@ int main(void)
}
EOF

- $CC -o $TMPDIR/pcaptest $TMPDIR/pcaptest.c -lpcap >> config.log 2>&1
+ $CC -o $TMPDIR/pcaptest $TMPDIR/pcaptest.c \
+ $($PKG_CONFIG --libs libpcap 2>> config.log) \
+ >> config.log 2>&1
if [ ! -x $TMPDIR/pcaptest ] ; then
echo "[NO]"
echo "CONFIG_LIBPCAP=0" >> Config
diff --git a/mausezahn/Makefile b/mausezahn/Makefile
index ca16b6579583..9544565355cc 100644
--- a/mausezahn/Makefile
+++ b/mausezahn/Makefile
@@ -1,6 +1,6 @@
mausezahn-libs = -lcli \
-lnet \
- -lpcap \
+ $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --libs libpcap 2> /dev/null ) \
-lrt \
-lpthread \
-lm
--
2.33.0

Tobias Klauser

unread,
Sep 2, 2021, 9:08:06 AM9/2/21
to Baruch Siach, netsn...@googlegroups.com
On 2021-09-02 at 11:56:00 +0200, Baruch Siach <bar...@tkos.co.il> wrote:
> When building statically the link command line must include all
> dependencies of all libraries. libpcap can optionally depend on libnl.
> mausezahn can't build statically in this case.
>
> Use pkg-config in configure and in the link command to construct the
> library flags we need to link with libpcap.
>
> Signed-off-by: Baruch Siach <bar...@tkos.co.il>

Applied, thanks.
Reply all
Reply to author
Forward
0 new messages