1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-26 09:29:01 +00:00

Let nsock's configure take the same --with-libpcap as Nmap does

This commit is contained in:
dmiller
2013-12-11 23:17:50 +00:00
parent 44e251306e
commit 2506269bcc
4 changed files with 188 additions and 21 deletions

View File

@@ -14,7 +14,7 @@ CCOPT =
DEFS = @DEFS@ -DNSOCK_VERSION=\"$(NSOCK_VERSION)\"
# With GCC, add extra security checks to source code.
DEFS += -D_FORTIFY_SOURCE=2
INCLS = -I../include -I../../libpcap
INCLS = -I../include
CFLAGS = @CFLAGS@ $(CCOPT)
# CFLAGS = -g -Wall $(DEFS) $(INCLS)
CPPFLAGS = @CPPFLAGS@ $(DEFS) $(INCLS)

153
nsock/src/configure vendored
View File

@@ -686,7 +686,7 @@ ac_subst_files=''
ac_user_opts='
enable_option_checking
with_localdirs
with_pcap
with_libpcap
with_openssl
with_libnbase
'
@@ -1310,7 +1310,8 @@ Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-localdirs Explicitly ask compiler to use /usr/local/{include,libs} if they exist
--disable-pcap Disable pcap functions.
--with-libpcap=DIR Look for pcap in DIR/include and DIR/libs.
--without-libpcap Disable pcap functions.
--with-openssl=DIR Use optional openssl libs and includes from
[DIR]/lib/ and [DIR]/include/openssl/)
--with-libnbase=DIR Look for nbase include/libs in DIR
@@ -2323,18 +2324,6 @@ if test "$user_localdirs" = 1; then
fi
pcap_enabled=yes
# Check whether --with-pcap was given.
if test "${with_pcap+set}" = set; then :
withval=$with_pcap; pcap_enabled="$withval"
fi
if test "$pcap_enabled" != "no"; then
$as_echo "#define HAVE_PCAP 1" >>confdefs.h
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -3522,6 +3511,141 @@ fi
done
# Check whether --with-libpcap was given.
if test "${with_libpcap+set}" = set; then :
withval=$with_libpcap; case "$with_libpcap" in
yes)
ac_fn_c_check_header_mongrel "$LINENO" "pcap.h" "ac_cv_header_pcap_h" "$ac_includes_default"
if test "x$ac_cv_header_pcap_h" = xyes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_datalink in -lpcap" >&5
$as_echo_n "checking for pcap_datalink in -lpcap... " >&6; }
if ${ac_cv_lib_pcap_pcap_datalink+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lpcap $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char pcap_datalink ();
int
main ()
{
return pcap_datalink ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_pcap_pcap_datalink=yes
else
ac_cv_lib_pcap_pcap_datalink=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcap_pcap_datalink" >&5
$as_echo "$ac_cv_lib_pcap_pcap_datalink" >&6; }
if test "x$ac_cv_lib_pcap_pcap_datalink" = xyes; then :
pcap_enabled=yes
fi
fi
;;
no)
pcap_enabled=no
;;
*)
_cppflags=$CPPFLAGS
_ldflags=$LDFLAGS
CPPFLAGS="-I$with_libpcap/include $CPPFLAGS"
LDFLAGS="-L$with_libpcap/lib $LDFLAGS"
ac_fn_c_check_header_mongrel "$LINENO" "pcap.h" "ac_cv_header_pcap_h" "$ac_includes_default"
if test "x$ac_cv_header_pcap_h" = xyes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_datalink in -lpcap" >&5
$as_echo_n "checking for pcap_datalink in -lpcap... " >&6; }
if ${ac_cv_lib_pcap_pcap_datalink+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lpcap $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char pcap_datalink ();
int
main ()
{
return pcap_datalink ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_pcap_pcap_datalink=yes
else
ac_cv_lib_pcap_pcap_datalink=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcap_pcap_datalink" >&5
$as_echo "$ac_cv_lib_pcap_pcap_datalink" >&6; }
if test "x$ac_cv_lib_pcap_pcap_datalink" = xyes; then :
have_libpcap=yes
LIBPCAP_INC=$with_libpcap/include
LIBPCAP_LIB=$with_libpcap/lib
fi
fi
LDFLAGS=$_ldflags
CPPFLAGS=$_cppflags
;;
esac
else
pcap_enabled=yes
LIBPCAP_INC="../../libpcap"
LIBPCAP_LIB="../../libpcap"
fi
if test $pcap_enabled = yes; then
if test "${LIBPCAP_INC+set}" = "set"; then
CPPFLAGS="-I$LIBPCAP_INC $CPPFLAGS"
LDFLAGS="-L$LIBPCAP_LIB $LDFLAGS"
fi
$as_echo "#define HAVE_PCAP 1" >>confdefs.h
LIBPCAP_LIBS="-lpcap"
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 :
@@ -4805,6 +4929,7 @@ LIBNBASE_LIBS="$LIBS -lnbase"
ac_config_files="$ac_config_files Makefile"
cat >confcache <<\_ACEOF

View File

@@ -104,12 +104,49 @@ if test "$user_localdirs" = 1; then
fi
pcap_enabled=yes
AC_ARG_WITH(pcap,
AC_HELP_STRING([--disable-pcap], [Disable pcap functions.]),
[ pcap_enabled="$withval" ])
AC_ARG_WITH(libpcap,
AC_HELP_STRING([--with-libpcap=DIR], [Look for pcap in DIR/include and DIR/libs.])
AC_HELP_STRING([--without-libpcap], [Disable pcap functions.]),
[ case "$with_libpcap" in
yes)
AC_CHECK_HEADER(pcap.h,[
AC_CHECK_LIB(pcap, pcap_datalink,
[pcap_enabled=yes ])])
;;
no)
pcap_enabled=no
;;
*)
_cppflags=$CPPFLAGS
_ldflags=$LDFLAGS
CPPFLAGS="-I$with_libpcap/include $CPPFLAGS"
LDFLAGS="-L$with_libpcap/lib $LDFLAGS"
AC_CHECK_HEADER(pcap.h,[
AC_CHECK_LIB(pcap, pcap_datalink,
[have_libpcap=yes
LIBPCAP_INC=$with_libpcap/include
LIBPCAP_LIB=$with_libpcap/lib])])
LDFLAGS=$_ldflags
CPPFLAGS=$_cppflags
;;
esac],
[ pcap_enabled=yes
LIBPCAP_INC="../../libpcap"
LIBPCAP_LIB="../../libpcap"
]
)
if test $pcap_enabled = yes; then
if test "${LIBPCAP_INC+set}" = "set"; then
CPPFLAGS="-I$LIBPCAP_INC $CPPFLAGS"
LDFLAGS="-L$LIBPCAP_LIB $LDFLAGS"
fi
if test "$pcap_enabled" != "no"; then
AC_DEFINE(HAVE_PCAP)
LIBPCAP_LIBS="-lpcap"
fi
AX_HAVE_EPOLL([AC_DEFINE(HAVE_EPOLL)], )

View File

@@ -13,8 +13,13 @@ EXEC_MAIN=./tests_main
NCAT=${NCAT:-ncat}
if [ ! -x "$NCAT" -a -z "$(which $NCAT)" ]; then
echo "Can't find your ncat: $NCAT"
echo "Skipping nsock tests."
exit 0
echo "Trying ../../ncat/ncat"
NCAT="../../ncat/ncat"
if [ ! -x "$NCAT" ]; then
echo "You haven't built Ncat."
echo "Skipping nsock tests."
exit 0
fi
fi