Simplify config and build process for libpcap tool

This commit is contained in:
Hamish Coleman 2023-07-01 13:39:02 +01:00
parent 433b14c52f
commit 8dcc879ca0
6 changed files with 18 additions and 25 deletions

View File

@ -6,7 +6,6 @@ export AR
export CFLAGS
export LDFLAGS
export LDLIBS
export TOOLS_ADDITIONAL
-include config.mak

View File

@ -9,4 +9,3 @@ WINDRES=@WINDRES@
CFLAGS=@CFLAGS@
LDFLAGS=@LDFLAGS@
LDLIBS_EXTRA=@LIBS@
TOOLS_ADDITIONAL=@TOOLS_ADDITIONAL@

View File

@ -66,19 +66,7 @@ AC_ARG_ENABLE([pcap],
[AS_HELP_STRING([--enable-pcap], [support for pcap])],
[], [enable_pcap=no])
AS_IF([test "x$enable_pcap" != xno],
[AC_CHECK_LIB([pcap], [pcap_open_live],
[
AC_DEFINE([N2N_HAVE_PCAP], [1], [Have PCAP library])
LIBS="-lpcap ${LIBS}"
TOOLS_ADDITIONAL="$TOOLS_ADDITIONAL n2n-decode"
# TODO
# - pcap_set_immediate_mode has been available since libpcap 1.5
# in 2013 - probably should remove this check
AC_CHECK_LIB([pcap], [pcap_set_immediate_mode],
AC_DEFINE([HAVE_PCAP_IMMEDIATE_MODE], [1], [Have pcap_immediate_mode])
)
],
[AC_CHECK_LIB([pcap], [pcap_set_immediate_mode],,
[AC_MSG_ERROR([pcap library not found])]
)],
)
@ -104,7 +92,6 @@ AS_IF([test "x$enable_pthread" != xno],
AC_SUBST(host)
AC_SUBST(WINDRES)
AC_SUBST(TOOLS_ADDITIONAL)
AC_CONFIG_HEADERS(include/config.h)
AC_CONFIG_FILES(config.mak)

View File

@ -26,10 +26,6 @@ LDFLAGS=$LDFLAGS
LDLIBS_EXTRA=$LDLIBS
EOF
cat >tools/config.mak <<EOF
TOOLS_ADDITIONAL=
EOF
cat <<EOF >include/config.h
#define PACKAGE_VERSION "FIXME"
#define PACKAGE_BUILDDATE "$(date)"

View File

@ -15,8 +15,7 @@ LDFLAGS+=-L..
N2N_LIB=../libn2n.a
TOOLS=n2n-benchmark n2n-keygen n2n-route n2n-portfwd
TOOLS+=$(TOOLS_ADDITIONAL)
TOOLS=n2n-benchmark n2n-keygen n2n-route n2n-portfwd n2n-decode
TESTS=tests-compress tests-elliptic tests-hashing tests-transform
TESTS+=tests-wire
@ -29,9 +28,7 @@ n2n-benchmark.o: $(N2N_LIB) $(HEADERS) ../config.mak
n2n-keygen.o: $(N2N_LIB) $(HEADERS) ../config.mak
n2n-route.o: $(N2N_LIB) $(HEADERS) ../config.mak
n2n-portfwd.o: $(N2N_LIB) $(HEADERS) ../config.mak
n2n-decode: n2n-decode.c $(N2N_LIB) $(HEADERS) ../config.mak
$(CC) $(CFLAGS) $< $(LDFLAGS) $(LDLIBS) -lpcap -o $@
n2n-decode.o: $(N2N_LIB) $(HEADERS) ../config.mak
# See comments in the topdir Makefile about how to generate coverage
# data.

View File

@ -16,6 +16,10 @@
*
*/
#include "config.h"
#ifdef HAVE_LIBPCAP
#include <errno.h> // for errno
#include <pcap.h>
#include <signal.h> // for signal, SIGINT, SIGTERM
@ -372,3 +376,14 @@ int main(int argc, char* argv[]) {
return(rv);
}
#else
#include <stdio.h>
int main() {
printf("n2n was compiled without libpcap support");
return -1;
}
#endif /* HAVE_LIBPCAP */