summaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-11-29 18:18:01 -0800
committerGuy Harris <guy@alum.mit.edu>2017-11-29 18:18:18 -0800
commitcfc4c750a225e893eeeca78eddb95fdc7125aabf (patch)
tree14ad37d2788614dc85b5d5a26effc47e8d242d81 /configure
parent415160c0c2d210358a0225be53922728f7cd9651 (diff)
downloadtcpdump-cfc4c750a225e893eeeca78eddb95fdc7125aabf.tar.gz
Fix the handling of libpcap.
We have four possibilities: 1) local library, with a pcap-config; 2) local library, without a pcap-config; 3) installed library, with a pcap-config; 4) installed library, without a pcap-config. If we have a local library, i.e. one in ../libpcap{whatever}, we: add -I flags to the C compiler flags to point it at whatever directories in ../libpcap{whatever}; add ../libpcap{whatever}/libpcap.a to $LIBS and: if it has a pcap-config, we use it, with --additional-libraries, to find the additional libraries with which we need to link; otherwise, we do the usual OS-dependent hacks to try to figure out with what additional flags we need to link; and add them to $LIBS after libpcap.a. If we have an installed library: if it has a pcap-config we use it, with --cflags, to find what flags to add to the C compiler flags, and use it, with --libs, to see what flags to add to $LIBS; if it doesn't have a pcap-config, we search for -lpcap and, if that succeeds, we assume the headers are under /usr/local/include or /usr/include, search for them there, and, if we don't find pcap.h there, we look for it in a pcap subdirectory under there, and add the appropriate -I flag to the C compiler flags, and then do the usual OS-dependent hacks to try to figure out with what additional flags we need to link. While we're at it, we do the libdlpi check only on Solaris, as part of "the usual OS-dependent hacks".
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure253
1 files changed, 145 insertions, 108 deletions
diff --git a/configure b/configure
index 858c28e3..2512d791 100755
--- a/configure
+++ b/configure
@@ -5264,39 +5264,62 @@ $as_echo "Using $pfopen" >&6; }
fi
fi
libpcap=FAIL
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for local pcap library" >&5
-$as_echo_n "checking for local pcap library... " >&6; }
# Check whether --with-system-libpcap was given.
if test "${with_system_libpcap+set}" = set; then :
withval=$with_system_libpcap;
-fi
+ #
+ # Don't look for a local libpcap.
+ #
+ using_local_libpcap=no
- if test "x$with_system_libpcap" != xyes ; then
- lastdir=FAIL
- places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
- egrep '/libpcap-[0-9]+\.[0-9]+(\.[0-9]*)?([ab][0-9]*|-PRE-GIT)?$'`
- places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \
- egrep '/libpcap-[0-9]+\.[0-9]+(\.[0-9]*)?([ab][0-9]*|-PRE-GIT)?$'`
- for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do
- basedir=`echo $dir | sed -e 's/[ab][0-9]*$//' | \
- sed -e 's/-PRE-GIT$//' `
- if test $lastdir = $basedir ; then
- continue;
- fi
- lastdir=$dir
- if test -r $dir/libpcap.a ; then
- libpcap=$dir/libpcap.a
- d=$dir
- fi
- done
- fi
- if test $libpcap = FAIL ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+else
+
+ #
+ # Look for a local pcap library.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for local pcap library" >&5
+$as_echo_n "checking for local pcap library... " >&6; }
+ lastdir=FAIL
+ places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
+ egrep '/libpcap-[0-9]+\.[0-9]+(\.[0-9]*)?([ab][0-9]*|-PRE-GIT)?$'`
+ places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \
+ egrep '/libpcap-[0-9]+\.[0-9]+(\.[0-9]*)?([ab][0-9]*|-PRE-GIT)?$'`
+ for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do
+ basedir=`echo $dir | sed -e 's/[ab][0-9]*$//' | \
+ sed -e 's/-PRE-GIT$//' `
+ if test $lastdir = $basedir ; then
+ continue;
+ fi
+ lastdir=$dir
+ if test -r $dir/libpcap.a ; then
+ libpcap=$dir/libpcap.a
+ local_pcap_dir=$dir
+ fi
+ done
+ if test $libpcap = FAIL ; then
+ #
+ # We didn't find a local libpcap.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
$as_echo "not found" >&6; }
+ using_local_libpcap=no;
+ else
+ #
+ # We found a local libpcap.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libpcap" >&5
+$as_echo "$libpcap" >&6; }
+ using_local_libpcap=yes
+ fi
+
+fi
+
+ if test $using_local_libpcap = no ; then
#
- # Look for pcap-config.
+ # We didn't find a local libpcap.
+ # Look for an installed pcap-config.
#
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}pcap-config", so it can be a program name with args.
@@ -5413,7 +5436,7 @@ fi
libpcap=`"$PCAP_CONFIG" --libs`
else
#
- # Not found; look for pcap.
+ # Not found; look for an installed pcap.
#
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lpcap" >&5
$as_echo_n "checking for main in -lpcap... " >&6; }
@@ -5472,28 +5495,10 @@ $as_echo "found -- -I$d added" >&6; }
fi
fi
else
- V_PCAPDEP=$libpcap
- places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
- egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'`
- places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \
- egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'`
- pcapH=FAIL
- if test -r $d/pcap.h; then
- pcapH=$d
- else
- for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do
- if test -r $dir/pcap.h ; then
- pcapH=$dir
- fi
- done
- fi
-
- if test $pcapH = FAIL ; then
- as_fn_error $? "cannot find pcap.h: see INSTALL" "$LINENO" 5
- fi
- V_INCLS="-I$pcapH $V_INCLS"
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libpcap" >&5
-$as_echo "$libpcap" >&6; }
+ #
+ # We found a local libpcap.
+ # Look for its pcap-config script.
+ #
# Extract the first word of "pcap-config", so it can be a program name with args.
set dummy pcap-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -5507,7 +5512,7 @@ else
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $d
+for as_dir in $local_pcap_dir
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
@@ -5534,25 +5539,55 @@ $as_echo "no" >&6; }
fi
+
+ if test -n "$PCAP_CONFIG"; then
+ #
+ # We don't want its --cflags or --libs output, because
+ # those presume it's installed. For the C compiler flags,
+ # we add the source directory for the local libpcap, so
+ # we pick up its header files.
+ #
+ # We do, however, want its additional libraries, because
+ # it makes calls to routines in those libraries, so we'll
+ # need to link with them.
+ #
+ V_INCLS="-I$local_pcap_dir $V_INCLS"
+ additional_libs=`"$PCAP_CONFIG" --additinoal-libs`
+ libpcap="$libpcap $additional_libs"
+ else
+ #
+ # It doesn't have a pcap-config script.
+ # Make sure it has a pcap.h file.
+ #
+ V_PCAPDEP=$libpcap
+ places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
+ egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'`
+ places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \
+ egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'`
+ pcapH=FAIL
+ if test -r $local_pcap_dir/pcap.h; then
+ pcapH=$local_pcap_dir
+ else
+ for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do
+ if test -r $dir/pcap.h ; then
+ pcapH=$dir
+ fi
+ done
+ fi
+
+ if test $pcapH = FAIL ; then
+ as_fn_error $? "cannot find pcap.h: see INSTALL" "$LINENO" 5
+ fi
+
+ #
+ # Force the compiler to look for header files in the
+ # directory containing pcap.h.
+ #
+ V_INCLS="-I$pcapH $V_INCLS"
+ fi
fi
- if test -n "$PCAP_CONFIG"; then
- #
- # The libpcap directory has a pcap-config script.
- # Use it to get any additional libraries needed
- # to link with the libpcap archive library in
- # that directory.
- #
- # Please read section 11.6 "Shell Substitutions"
- # in the autoconf manual before doing anything
- # to this that involves quoting. Especially note
- # the statement "There is just no portable way to use
- # double-quoted strings inside double-quoted back-quoted
- # expressions (pfew!)."
- #
- additional_libs=`"$PCAP_CONFIG" --additional-libs --static`
- libpcap="$libpcap $additional_libs"
- else
+ if test -z "$PCAP_CONFIG"; then
#
# We don't have pcap-config; find out any additional link flags
# we need. (If we have pcap-config, we assume it tells us what
@@ -5584,6 +5619,50 @@ $as_echo "yes" >&6; }
#
LIBS="$LIBS -lodm -lcfg"
;;
+
+ solaris*)
+ # libdlpi is needed for Solaris 11 and later.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlpi_walk in -ldlpi" >&5
+$as_echo_n "checking for dlpi_walk in -ldlpi... " >&6; }
+if ${ac_cv_lib_dlpi_dlpi_walk+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldlpi -L/lib $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 dlpi_walk ();
+int
+main ()
+{
+return dlpi_walk ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_dlpi_dlpi_walk=yes
+else
+ ac_cv_lib_dlpi_dlpi_walk=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_dlpi_dlpi_walk" >&5
+$as_echo "$ac_cv_lib_dlpi_dlpi_walk" >&6; }
+if test "x$ac_cv_lib_dlpi_dlpi_walk" = xyes; then :
+ LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS"
+fi
+
+ ;;
esac
fi
@@ -5787,48 +5866,6 @@ $as_echo "#define HAVE_DECL_ETHER_NTOHOST 1" >>confdefs.h
fi
fi
-# libdlpi is needed for Solaris 11 and later.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlpi_walk in -ldlpi" >&5
-$as_echo_n "checking for dlpi_walk in -ldlpi... " >&6; }
-if ${ac_cv_lib_dlpi_dlpi_walk+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldlpi -L/lib $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 dlpi_walk ();
-int
-main ()
-{
-return dlpi_walk ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_dlpi_dlpi_walk=yes
-else
- ac_cv_lib_dlpi_dlpi_walk=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_dlpi_dlpi_walk" >&5
-$as_echo "$ac_cv_lib_dlpi_dlpi_walk" >&6; }
-if test "x$ac_cv_lib_dlpi_dlpi_walk" = xyes; then :
- LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS"
-fi
-
-
ac_fn_c_check_func "$LINENO" "pcap_list_datalinks" "ac_cv_func_pcap_list_datalinks"
if test "x$ac_cv_func_pcap_list_datalinks" = xyes; then :