From 2e047114f6b5feb8de44b84403d51cce1ff53972 Mon Sep 17 00:00:00 2001 From: dmiller Date: Sun, 26 Jan 2014 16:38:22 +0000 Subject: [PATCH] Improve support for non-included libpcap in nsock --- configure | 5 +++++ configure.ac | 6 ++++++ nsock/src/configure | 20 +++++++++++++++----- nsock/src/configure.ac | 17 ++++++++++++++--- nsock/tests/{Makefile => Makefile.in} | 10 +++++----- 5 files changed, 45 insertions(+), 13 deletions(-) rename nsock/tests/{Makefile => Makefile.in} (80%) diff --git a/configure b/configure index 97aa1c094..87bee60d4 100755 --- a/configure +++ b/configure @@ -2422,6 +2422,11 @@ if test "$user_localdirs" = 1; then fi fi +if test "${top_nmap_srcdir+set}" != set; then + top_nmap_srcdir=`cd "$srcdir" && pwd` + export top_nmap_srcdir +fi + libpcapdir=libpcap diff --git a/configure.ac b/configure.ac index 01a8775a1..1a8b024bb 100644 --- a/configure.ac +++ b/configure.ac @@ -30,6 +30,12 @@ if test "$user_localdirs" = 1; then fi fi +dnl Let subdirs configure scripts find the Nmap source dir +if test "${top_nmap_srcdir+set}" != set; then + top_nmap_srcdir=`cd "$srcdir" && pwd` + export top_nmap_srcdir +fi + libpcapdir=libpcap AC_SUBST(libpcapdir) diff --git a/nsock/src/configure b/nsock/src/configure index 0fcaac589..11b6ae25d 100755 --- a/nsock/src/configure +++ b/nsock/src/configure @@ -626,6 +626,7 @@ NBASEDIR LIBNBASE_LIBS OPENSSL_LIBS RANLIB +LIBPCAP_LIBS EGREP GREP CPP @@ -2107,6 +2108,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test "${top_nmap_srcdir+set}" != set; then + top_nmap_srcdir=../.. + export top_nmap_srcdir +fi + +ac_config_files="$ac_config_files Makefile ../tests/Makefile" + + ac_config_headers="$ac_config_headers ../include/nsock_config.h" @@ -3530,7 +3539,7 @@ fi ;; included) - LIBPCAP_INC=../../libpcap + LIBPCAP_INC=${top_nmap_srcdir}/libpcap have_libpcap=yes ;; no) @@ -3559,11 +3568,13 @@ fi if test "$have_libpcap" != "no"; then $as_echo "#define HAVE_PCAP 1" >>confdefs.h + LIBPCAP_LIBS=-lpcap if test "${LIBPCAP_INC+set}" = "set"; then CPPFLAGS="-I$LIBPCAP_INC $CPPFLAGS" fi fi + ax_have_epoll_cppflags="${CPPFLAGS}" ac_fn_c_check_header_mongrel "$LINENO" "linux/version.h" "ac_cv_header_linux_version_h" "$ac_includes_default" if test "x$ac_cv_header_linux_version_h" = xyes; then : @@ -4831,7 +4842,7 @@ if test "${with_libnbase+set}" = set; then : ;; esac else - NBASEDIR="../../nbase" + NBASEDIR="${top_nmap_srcdir}/nbase" fi @@ -4848,8 +4859,6 @@ LIBNBASE_LIBS="$LIBS -lnbase" -ac_config_files="$ac_config_files Makefile" - cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure @@ -5539,8 +5548,9 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 for ac_config_target in $ac_config_targets do case $ac_config_target in - "../include/nsock_config.h") CONFIG_HEADERS="$CONFIG_HEADERS ../include/nsock_config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "../tests/Makefile") CONFIG_FILES="$CONFIG_FILES ../tests/Makefile" ;; + "../include/nsock_config.h") CONFIG_HEADERS="$CONFIG_HEADERS ../include/nsock_config.h" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac diff --git a/nsock/src/configure.ac b/nsock/src/configure.ac index 2cdeeae08..b2a074b8b 100644 --- a/nsock/src/configure.ac +++ b/nsock/src/configure.ac @@ -9,6 +9,15 @@ AC_PREREQ(2.13) dnl Process this file with autoconf to produce a configure script. AC_INIT(nsock_core.c) +dnl Find the Nmap source for nbase, etc. +if test "${top_nmap_srcdir+set}" != set; then + top_nmap_srcdir=../.. + export top_nmap_srcdir +fi + +dnl Generate these files +AC_CONFIG_FILES([Makefile ../tests/Makefile]) + dnl use nsock_config.h instad of -D macros AC_CONFIG_HEADER(../include/nsock_config.h) @@ -119,7 +128,7 @@ AC_HELP_STRING([--without-libpcap], [Disable pcap functions.]), have_libpcap=yes ]) ;; included) - LIBPCAP_INC=../../libpcap + LIBPCAP_INC=${top_nmap_srcdir}/libpcap have_libpcap=yes ;; no) @@ -140,10 +149,12 @@ AC_HELP_STRING([--without-libpcap], [Disable pcap functions.]), if test "$have_libpcap" != "no"; then AC_DEFINE(HAVE_PCAP) + LIBPCAP_LIBS=-lpcap if test "${LIBPCAP_INC+set}" = "set"; then CPPFLAGS="-I$LIBPCAP_INC $CPPFLAGS" fi fi +AC_SUBST(LIBPCAP_LIBS) AX_HAVE_EPOLL([AC_DEFINE(HAVE_EPOLL)], ) AX_HAVE_POLL([AC_DEFINE(HAVE_POLL)], ) @@ -253,7 +264,7 @@ AC_ARG_WITH(libnbase, NBASEDIR="$with_libnbase" ;; esac], -NBASEDIR="../../nbase" +NBASEDIR="${top_nmap_srcdir}/nbase" ) NSOCKTESTDIR="../tests" @@ -268,4 +279,4 @@ AC_SUBST(NSOCKTESTDIR) AC_SUBST(CFLAGS) -AC_OUTPUT(Makefile) +AC_OUTPUT() diff --git a/nsock/tests/Makefile b/nsock/tests/Makefile.in similarity index 80% rename from nsock/tests/Makefile rename to nsock/tests/Makefile.in index a55020cdc..1562f5628 100644 --- a/nsock/tests/Makefile +++ b/nsock/tests/Makefile.in @@ -3,14 +3,14 @@ # Same license as nmap -- see http://nmap.org/book/man-legal.html ## -NBASEDIR=../../nbase +NBASEDIR=@NBASEDIR@ NSOCKLIB=../src/libnsock.a NBASELIB=$(NBASEDIR)/libnbase.a -CC = gcc -CFLAGS = -Wall -O0 -ggdb -I../include/ -I$(NBASEDIR) -LDFLAGS = -LIBS = -lssl -lpcap -lcrypto +CC = @CC@ +CFLAGS = -Wall -O0 -I../include -I$(NBASEDIR) +LDFLAGS = @LDFLAGS@ +LIBS = @OPENSSL_LIBS@ @LIBPCAP_LIBS@ SRC = tests_main.c \ basic.c \