]> The Tcpdump Group git mirrors - tcpdump/blobdiff - configure.ac
Makefile.in: don't remove configure and config.h.in in make distclean.
[tcpdump] / configure.ac
index 48f4dc959ab81015d63d1233ad95ff87fd03968a..0278e7c5cd77a564c464040430d97b3afbdd7caf 100644 (file)
@@ -13,8 +13,8 @@ dnl
 # config.sub.
 #
 
-AC_PREREQ(2.64)
-AC_INIT(tcpdump, m4_esyscmd_s([cat VERSION]))
+AC_PREREQ([2.69])
+AC_INIT([tcpdump],[m4_esyscmd_s(cat VERSION)])
 AC_CONFIG_SRCDIR(tcpdump.c)
 
 AC_CANONICAL_HOST
@@ -32,24 +32,12 @@ AC_LBL_C_INIT(V_CCOPT, V_INCLS)
 AC_LBL_C_INLINE
 
 AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h net/if.h)
-AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
-#include <sys/socket.h>
-#include <net/if.h>])
-if test "$ac_cv_header_net_pfvar_h" = yes; then
-       AC_CHECK_HEADERS(net/if_pflog.h, , , [#include <sys/types.h>
-       #include <sys/socket.h>
-       #include <net/if.h>
-       #include <net/pfvar.h>])
-       if test "$ac_cv_header_net_if_pflog_h" = yes; then
-               LOCALSRC="print-pflog.c $LOCALSRC"
-       fi
-fi
 
 case "$host_os" in
 
 darwin*)
        AC_ARG_ENABLE(universal,
-       AC_HELP_STRING([--disable-universal],[don't build universal on macOS]))
+       AS_HELP_STRING([--disable-universal],[don't build universal on macOS]))
        if test "$enable_universal" != "no"; then
                case "$host_os" in
 
@@ -76,10 +64,11 @@ darwin*)
 esac
 
 
-AC_ARG_WITH(smi,
-[  --with-smi              link with libsmi (allows to load MIBs on the fly to decode SNMP packets. [default=yes]
-  --without-smi           don't link with libsmi],,
-   with_smi=yes)
+AC_ARG_WITH([smi],
+   [AS_HELP_STRING([--with-smi],
+     [link with libsmi (allows to load MIBs on the fly to decode SNMP packets) [default=yes, if available]])],
+   [],
+   [with_smi=yes])
 
 if test "x$with_smi" != "xno" ; then
        AC_CHECK_HEADER(smi.h,
@@ -95,11 +84,13 @@ if test "x$with_smi" != "xno" ; then
                        AC_MSG_CHECKING([whether to enable libsmi])
                        savedlibs="$LIBS"
                        LIBS="-lsmi $LIBS"
-                       AC_TRY_RUN(
-                               [
+                       AC_RUN_IFELSE([AC_LANG_SOURCE([[
 /* libsmi available check */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <smi.h>
-main()
+int main()
 {
   int current, revision, age, n;
   const int required = 2;
@@ -114,6 +105,7 @@ main()
     exit(4);
   exit(0);
 }
+                               ]])
                                ],
                                [
                                        AC_MSG_RESULT(yes)
@@ -145,11 +137,39 @@ main()
        ])
 fi
 
+AC_MSG_CHECKING([whether to enable the instrument functions code])
+AC_ARG_ENABLE([instrument-functions],
+   [AS_HELP_STRING([--enable-instrument-functions],
+     [enable instrument functions code [default=no]])],
+   [],
+   [enableval=no])
+case "$enableval" in
+yes)   AC_MSG_RESULT(yes)
+       AC_CHECK_LIB([bfd], [bfd_init],
+           [true],
+           [AC_MSG_ERROR(
+              [--enable-instrument-functions was given, but test for library libbfd failed. Please install the 'binutils-dev' package.])],
+           [])
+       AC_DEFINE(ENABLE_INSTRUMENT_FUNCTIONS, 1,
+           [define if you want to build the instrument functions code])
+       LOCALSRC="$LOCALSRC instrument-functions.c"
+       # Add '-finstrument-functions' instrumentation option to generate
+       # instrumentation calls for entry and exit to functions.
+       # Try to avoid Address Space Layout Randomization (ALSR).
+       CFLAGS="$CFLAGS -O0 -ggdb -finstrument-functions -fno-stack-protector -fno-pic"
+       LDFLAGS="$LDFLAGS -O0 -ggdb -fno-stack-protector -no-pie"
+       LIBS="$LIBS -lbfd"
+       ;;
+*)     AC_MSG_RESULT(no)
+       ;;
+esac
+
 AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
-AC_ARG_ENABLE(smb,
-[  --enable-smb            enable possibly-buggy SMB printer [default=no]
-  --disable-smb           disable possibly-buggy SMB printer],,
-   enableval=no)
+AC_ARG_ENABLE([smb],
+   [AS_HELP_STRING([--enable-smb],
+     [enable possibly-buggy SMB printer [default=no]])],
+   [],
+   [enableval=no])
 case "$enableval" in
 yes)   AC_MSG_RESULT(yes)
        AC_DEFINE(ENABLE_SMB, 1,
@@ -198,7 +218,7 @@ AC_ARG_WITH(sandbox-capsicum,
 # XXX - do we need to check for all of them, or are there some that, if
 # present, imply others are present?
 #
-if test ! -z "$with_sandbox_capsicum" && test "$with_sandbox_capsicum" != "no" ; then
+if test -z "$with_sandbox_capsicum" || test "$with_sandbox_capsicum" != "no" ; then
        #
        # First, make sure we have the required header.
        #
@@ -247,6 +267,7 @@ AC_COMPILE_IFELSE(
     [
       AC_LANG_SOURCE(
        [[
+#include <string.h>
 /* AF_INET6 available check */
 #include <sys/types.h>
 #ifdef _WIN32
@@ -386,7 +407,7 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
 fi
 
 AC_REPLACE_FUNCS(strlcat strlcpy strdup strsep getservent getopt_long)
-AC_CHECK_FUNCS(fork vfork strftime)
+AC_CHECK_FUNCS(fork vfork)
 AC_CHECK_FUNCS(setlinebuf)
 
 #
@@ -397,6 +418,38 @@ AC_CHECK_FUNC(vsnprintf,,
 AC_CHECK_FUNC(snprintf,,
     AC_MSG_ERROR([snprintf() is required but wasn't found]))
 
+#
+# Define HAVE_NO_PRINTF_Z to make it possible to disable test cases that
+# depend on %zu.
+#
+AC_MSG_CHECKING([whether printf(3) supports the z length modifier])
+AC_RUN_IFELSE(
+    [
+        AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+
+int main()
+{
+  char buf[100];
+  snprintf(buf, sizeof(buf), "%zu", sizeof(buf));
+  return strncmp(buf, "100", sizeof(buf)) ? 1 : 0;
+}
+        ]])
+    ],
+    [
+        AC_MSG_RESULT(yes)
+    ],
+    [
+        AC_MSG_RESULT(no)
+        AC_DEFINE(HAVE_NO_PRINTF_Z, 1,
+            [Define to 1 if printf(3) does not support the z length modifier.])
+    ],
+    [
+        AC_MSG_RESULT(not while cross-compiling)
+    ]
+)
+
 AC_CHECK_LIB(rpc, main)                dnl It's unclear why we might need -lrpc
 
 dnl Some platforms may need -lnsl for getrpcbynumber.
@@ -422,8 +475,10 @@ AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
 #
 AC_CHECK_FUNCS(ether_ntohost, [
     AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
-       AC_TRY_RUN([
+       AC_RUN_IFELSE([AC_LANG_SOURCE([[
                #include <netdb.h>
+               #include <netinet/ether.h>
+               #include <stdlib.h>
                #include <sys/types.h>
                #include <sys/param.h>
                #include <sys/socket.h>
@@ -437,6 +492,7 @@ AC_CHECK_FUNCS(ether_ntohost, [
                        ether_ntohost(name, (struct ether_addr *)ea);
                        exit(0);
                }
+       ]])
        ], [ac_cv_buggy_ether_ntohost=no],
           [ac_cv_buggy_ether_ntohost=yes],
           [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
@@ -686,14 +742,14 @@ fi
 AC_CHECK_FUNCS(pcap_dump_flush pcap_lib_version)
 if test $ac_cv_func_pcap_lib_version = "no" ; then
     AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
-    AC_TRY_LINK([],
-       [
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
        extern char pcap_version[];
 
        return (int)pcap_version;
+       ]])
        ],
-       ac_lbl_cv_pcap_version_defined=yes,
-       ac_lbl_cv_pcap_version_defined=no)
+       [ac_lbl_cv_pcap_version_defined=yes],
+       [ac_lbl_cv_pcap_version_defined=no])
     if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
        AC_MSG_RESULT(yes)
        AC_DEFINE(HAVE_PCAP_VERSION, 1, [define if libpcap has pcap_version])
@@ -715,14 +771,14 @@ if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then
        # filter expression parser debug flag; can we directly set the
        # flag?
        AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
-       AC_TRY_LINK([],
-          [
+       AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
                extern int pcap_debug;
 
                return pcap_debug;
+          ]])
           ],
-          ac_lbl_cv_pcap_debug_defined=yes,
-          ac_lbl_cv_pcap_debug_defined=no)
+          [ac_lbl_cv_pcap_debug_defined=yes],
+          [ac_lbl_cv_pcap_debug_defined=no])
        if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
                AC_MSG_RESULT(yes)
                AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
@@ -732,14 +788,14 @@ if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then
                # OK, what about "yydebug"?
                #
                AC_MSG_CHECKING(whether yydebug is defined by libpcap)
-               AC_TRY_LINK([],
-                  [
+               AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
                        extern int yydebug;
 
                        return yydebug;
+                  ]])
                   ],
-                  ac_lbl_cv_yydebug_defined=yes,
-                  ac_lbl_cv_yydebug_defined=no)
+                  [ac_lbl_cv_yydebug_defined=yes],
+                  [ac_lbl_cv_yydebug_defined=no])
                if test "$ac_lbl_cv_yydebug_defined" = yes ; then
                        AC_MSG_RESULT(yes)
                        AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
@@ -988,12 +1044,13 @@ AC_SUBST(MAN_MISC_INFO)
 
 AC_PROG_INSTALL
 
-AC_CONFIG_HEADER(config.h)
+AC_CONFIG_HEADERS([config.h])
 
-AC_OUTPUT_COMMANDS([if test -f .devel; then
+AC_CONFIG_COMMANDS([.devel],[[if test -f .devel; then
        echo timestamp > stamp-h
        cat $srcdir/Makefile-devel-adds >> Makefile
-       make depend
-fi])
-AC_OUTPUT(Makefile tcpdump.1)
+       make depend || exit 1
+fi]])
+AC_CONFIG_FILES([Makefile tcpdump.1])
+AC_OUTPUT
 exit 0