diff --git a/acinclude.m4 b/acinclude.m4 index bce585ef02..36f125c6f8 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -290,40 +290,54 @@ AC_DEFUN([AC_WIRESHARK_PCAP_CHECK], # XXX need to set a var AC_CHECK_HEADER(pcap.h,,) # - # The user didn't specify a directory in which libpcap resides; - # we assume that the current library search path will work, - # but we may have to look for the header in a "pcap" - # subdirectory of "/usr/include" or "/usr/local/include", - # as some systems apparently put "pcap.h" in a "pcap" - # subdirectory, and we also check "$prefix/include" - and - # "$prefix/include/pcap", in case $prefix is set to - # "/usr/include" or "/usr/local/include". + # The user didn't specify a directory in which libpcap resides. + # First, look for a pcap-config script. # - # XXX - should we just add "$prefix/include" to the include - # search path and "$prefix/lib" to the library search path? - # - AC_MSG_CHECKING(for extraneous pcap header directories) - found_pcap_dir="" - pcap_dir_list="/usr/include/pcap $prefix/include/pcap $prefix/include" - if test "x$ac_cv_enable_usr_local" = "xyes" ; then - pcap_dir_list="$pcap_dir_list /usr/local/include/pcap" - fi - for pcap_dir in $pcap_dir_list - do - if test -d $pcap_dir ; then + AC_PATH_PROG(PCAP_CONFIG, pcap-config) + if test -n "$PCAP_CONFIG" ; then + # + # Found - use it to get the include flags for + # libpcap. + # + CFLAGS="$CFLAGS `\"$PCAP_CONFIG\" --cflags`" + CPPFLAGS="$CPPFLAGS `\"$PCAP_CONFIG\" --cflags`" + else + # + # Didn't find it; we have to look for libpcap ourselves. + # We assume that the current library search path will work, + # but we may have to look for the header in a "pcap" + # subdirectory of "/usr/include" or "/usr/local/include", + # as some systems apparently put "pcap.h" in a "pcap" + # subdirectory, and we also check "$prefix/include" - and + # "$prefix/include/pcap", in case $prefix is set to + # "/usr/include" or "/usr/local/include". + # + # XXX - should we just add "$prefix/include" to the include + # search path and "$prefix/lib" to the library search path? + # + AC_MSG_CHECKING(for extraneous pcap header directories) + found_pcap_dir="" + pcap_dir_list="/usr/include/pcap $prefix/include/pcap $prefix/include" + if test "x$ac_cv_enable_usr_local" = "xyes" ; then + pcap_dir_list="$pcap_dir_list /usr/local/include/pcap" + fi + for pcap_dir in $pcap_dir_list + do + if test -d $pcap_dir ; then if test x$pcap_dir != x/usr/include -a x$pcap_dir != x/usr/local/include ; then CFLAGS="$CFLAGS -I$pcap_dir" CPPFLAGS="$CPPFLAGS -I$pcap_dir" fi found_pcap_dir=" $found_pcap_dir -I$pcap_dir" break - fi - done + fi + done - if test "$found_pcap_dir" != "" ; then - AC_MSG_RESULT(found --$found_pcap_dir added to CFLAGS) - else - AC_MSG_RESULT(not found) + if test "$found_pcap_dir" != "" ; then + AC_MSG_RESULT(found --$found_pcap_dir added to CFLAGS) + else + AC_MSG_RESULT(not found) + fi fi else # @@ -350,20 +364,33 @@ from source, did you also do \"make install-incl\", and if you installed a binary package of libpcap, is there also a developer's package of libpcap, and did you also install that package?]])) - # - # Check to see if we find "pcap_open_live" in "-lpcap". - # Also check for various additional libraries that libpcap might - # require. - # - AC_CHECK_LIB(pcap, pcap_open_live, - [ - PCAP_LIBS=-lpcap - AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library]) - ], [ - ac_wireshark_extras_found=no - ac_save_LIBS="$LIBS" - for extras in "-lcfg -lodm" "-lpfring" - do + if test -n "$PCAP_CONFIG" ; then + # + # We have pcap-config; we assume that means we have libpcap + # installed and that pcap-config will tell us whatever + # libraries libpcap needs. + # + if test x$enable_static = xyes; then + PCAP_LIBS="`\"$PCAP_CONFIG\" --libs --static`" + else + PCAP_LIBS="`\"$PCAP_CONFIG\" --libs`" + fi + AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library]) + else + # + # Check to see if we find "pcap_open_live" in "-lpcap". + # Also check for various additional libraries that libpcap might + # require. + # + AC_CHECK_LIB(pcap, pcap_open_live, + [ + PCAP_LIBS=-lpcap + AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library]) + ], [ + ac_wireshark_extras_found=no + ac_save_LIBS="$LIBS" + for extras in "-lcfg -lodm" "-lpfring" + do AC_MSG_CHECKING([for pcap_open_live in -lpcap with $extras]) LIBS="-lpcap $extras" # @@ -389,13 +416,14 @@ and did you also install that package?]])) then break fi - done - if test x$ac_wireshark_extras_found = xno - then + done + if test x$ac_wireshark_extras_found = xno + then AC_MSG_ERROR([Can't link with library libpcap.]) - fi - LIBS=$ac_save_LIBS - ], $SOCKET_LIBS $NSL_LIBS) + fi + LIBS=$ac_save_LIBS + ], $SOCKET_LIBS $NSL_LIBS) + fi AC_SUBST(PCAP_LIBS) #