capture_file.h (Qt): missing ]
[metze/wireshark/wip.git] / acinclude.m4
index e825dc1e93fb5d492dd3789e0fb29bd02dd27260..47457f634bd0d8d155d77ead4e998c469e5336ea 100644 (file)
@@ -170,6 +170,10 @@ yes
 #endif],
                                [v6type=$i; v6lib=v6;
                                v6libdir=/usr/local/v6/lib;
+                               #
+                               # XXX - this doesn't define INET6;
+                               # is that a mistake?
+                               #
                                CPPFLAGS="-I/usr/local/v6/include $CPPFLAGS"])
                        ;;
                toshiba)
@@ -180,7 +184,7 @@ yes
 #endif],
                                [v6type=$i; v6lib=inet6;
                                v6libdir=/usr/local/v6/lib;
-                               CPPFLAGS="-DINET6 $CPPFLAGS"])
+                               AC_DEFINE(INET6, 1, [Define if the platform supports IPv6])])
                        ;;
                kame)
                        AC_EGREP_CPP(yes, [
@@ -190,7 +194,7 @@ yes
 #endif],
                                [v6type=$i; v6lib=inet6;
                                v6libdir=/usr/local/v6/lib;
-                               CPPFLAGS="-DINET6 $CPPFLAGS"])
+                               AC_DEFINE(INET6, 1, [Define if the platform supports IPv6])])
                        ;;
                inria)
                        AC_EGREP_CPP(yes, [
@@ -198,7 +202,8 @@ yes
 #ifdef IPV6_INRIA_VERSION
 yes
 #endif],
-                               [v6type=$i; CPPFLAGS="-DINET6 $CPPFLAGS"])
+                               [v6type=$i;
+                               AC_DEFINE(INET6, 1, [Define if the platform supports IPv6])])
                        ;;
                zeta)
                        AC_EGREP_CPP(yes, [
@@ -208,14 +213,14 @@ yes
 #endif],
                                [v6type=$i; v6lib=inet6;
                                v6libdir=/usr/local/v6/lib;
-                               CPPFLAGS="-DINET6 $CPPFLAGS"])
+                               AC_DEFINE(INET6, 1, [Define if the platform supports IPv6])])
                        ;;
                linux)
                        if test -d /usr/inet6; then
                                v6type=$i
                                v6lib=inet6
                                v6libdir=/usr/inet6
-                               CPPFLAGS="-DINET6 $CPPFLAGS"
+                               AC_DEFINE(INET6, 1, [Define if the platform supports IPv6])
                        fi
                        ;;
                linux-glibc)
@@ -226,13 +231,20 @@ yes
 yes
 #endif
 #endif],
-                       [v6type=$i; v6lib=inet6; CPPFLAGS="-DINET6 $CPPFLAGS"])
+                       [v6type=$i; v6lib=inet6;
+                       AC_DEFINE(INET6, 1, [Define if the platform supports IPv6])])
                        ;;
                solaris)
+                       #
+                       # There's nothing we can check for in the header
+                       # file, so we just check for SunOS (pre-SunOS 5
+                       # versions didn't include IPv6 support, so we
+                       # just check the OS, not the version).
+                       #
                        if test "`uname -s`" = "SunOS"; then
                                v6type=$i
                                v6lib=inet6
-                               [CPPFLAGS="-DINET6 $CPPFLAGS"]
+                               AC_DEFINE(INET6, 1, [Define if the platform supports IPv6])
                        fi
                        ;;
                esac
@@ -533,7 +545,7 @@ and did you also install that package?]]))
        # header.
        #
        # However, it might also happen on some others OSes with some erroneous
-       # system manipulations where multiple versions of libcap might co-exist
+       # system manipulations where multiple versions of libpcap might co-exist
        # e.g. hand made symbolic link from libpcap.so -> libpcap.so.0.8 but
        # having the pcap header version 0.7.
        #
@@ -615,7 +627,7 @@ install a newer version of the header file.])
          AC_CHECK_FUNCS(pcap_datalink_val_to_description)
          AC_CHECK_FUNCS(pcap_list_datalinks pcap_set_datalink pcap_lib_version)
          AC_CHECK_FUNCS(pcap_get_selectable_fd pcap_free_datalinks)
-         AC_CHECK_FUNCS(pcap_create bpf_image)
+         AC_CHECK_FUNCS(pcap_create bpf_image pcap_set_tstamp_precision)
        fi
        LIBS="$ac_save_LIBS"
 ])
@@ -637,42 +649,6 @@ AC_DEFUN([AC_WIRESHARK_PCAP_REMOTE_CHECK],
     LIBS="$ac_save_LIBS"
 ])
 
-#
-# AC_WIRESHARK_CHECK_DLADDR
-#
-AC_DEFUN([AC_WIRESHARK_CHECK_DLADDR],
-[
-       ac_save_CFLAGS="$CFLAGS"
-       ac_save_LIBS="$LIBS"
-       CFLAGS="$CFLAGS $GLIB_CFLAGS"
-       LIBS="$GLIB_LIBS $LIBS $1"
-       AC_TRY_RUN(
-[
-#define _GNU_SOURCE    /* required on Linux, sigh */
-#include <dlfcn.h>
-
-int
-main(void)
-{
-       Dl_info info;
-
-       if (!dladdr((void *)main, &info))
-               return 1;       /* failure */
-       return 0;               /* assume success */
-}
-],
-   ac_cv_dladdr_finds_executable_path=yes,
-   ac_cv_dladdr_finds_executable_path=no,
-   [echo $ac_n "cross compiling; assumed OK... $ac_c"
-    ac_cv_dladdr_finds_executable_path=yes])
-       CFLAGS="$ac_save_CFLAGS"
-       LIBS="$ac_save_LIBS"
-       if test x$ac_cv_dladdr_finds_executable_path = xyes
-       then
-               AC_DEFINE(DLADDR_FINDS_EXECUTABLE_PATH, 1, [Define if dladdr can be used to find the path of the executable])
-       fi
-])
-
 #
 # AC_WIRESHARK_ZLIB_CHECK
 #
@@ -981,7 +957,7 @@ AC_DEFUN([AC_WIRESHARK_LIBLUA_CHECK],[
                                LUA_LIBS="-llua -lm"
                                LUA_INCLUDES=""
                        fi
-                       AC_DEFINE(HAVE_LUA, 1, [Define to use Lua ${lua_ver}])
+                       AC_DEFINE(HAVE_LUA, 1, [Define to use Lua])
                        want_lua=yes
 
                ],[
@@ -997,7 +973,7 @@ AC_DEFUN([AC_WIRESHARK_LIBLUA_CHECK],[
                            #  Lua found
                            #
                            LUA_LIBS=" -llua${lua_ver} -lm"
-                           AC_DEFINE(HAVE_LUA, 1, [Define to use Lua ${lua_ver}])
+                           AC_DEFINE(HAVE_LUA, 1, [Define to use Lua])
                            want_lua=yes
                        ],[
                                #
@@ -1318,8 +1294,8 @@ AC_DEFUN([AC_WIRESHARK_KRB5_CHECK],
          CPPFLAGS="$CPPFLAGS -I$krb5_dir/include"
          ac_heimdal_version=`grep heimdal $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*heimdal.*$/HEIMDAL/'`
          # MIT Kerberos moved krb5.h to krb5/krb5.h starting with release 1.5
-         ac_mit_version_olddir=`grep 'Massachusetts Institute of Technology' $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*Massachusetts Institute of Technology.*$/MIT/'`
-         ac_mit_version_newdir=`grep 'Massachusetts Institute of Technology' $krb5_dir/include/krb5/krb5.h | head -n 1 | sed 's/^.*Massachusetts Institute of Technology.*$/MIT/'`
+         ac_mit_version_olddir=`grep 'Massachusetts' $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*Massachusetts.*$/MIT/'`
+         ac_mit_version_newdir=`grep 'Massachusetts' $krb5_dir/include/krb5/krb5.h | head -n 1 | sed 's/^.*Massachusetts.*$/MIT/'`
          ac_krb5_version="$ac_heimdal_version$ac_mit_version_olddir$ac_mit_version_newdir"
          if test "x$ac_krb5_version" = "xHEIMDAL"
          then
@@ -1358,7 +1334,7 @@ AC_DEFUN([AC_WIRESHARK_KRB5_CHECK],
                    KRB5_LIBS=`echo $KRB5_LIBS | sed 's/-lcrypto//'`
                    KRB5_LIBS="$KRB5_LIBS $SSL_LIBS"
                else
-                   AC_MSG_ERROR([Kerberos library requires -lcrypto but --with-ssl not specified])
+                   AC_MSG_ERROR([Kerberos library requires -lcrypto, so you must specify --with-ssl])
                fi
                ;;
            esac
@@ -1589,31 +1565,25 @@ AC_DEFUN([AC_WIRESHARK_GEOIP_CHECK],
 #
 # $1 : ldflag(s) to test
 #
-# The macro first determines if the compiler supports "-Wl,{option}" to
-# pass options through to the linker. Then it attempts to compile with
-# the defined ldflags. The defined flags are added to LDFLAGS only if
-# the compilation succeeds.
+# We attempt to compile and link a test program with the specified linker
+# flag. The defined flag is added to LDFLAGS only if the link succeeds.
 #
 AC_DEFUN([AC_WIRESHARK_LDFLAGS_CHECK],
-[GCC_OPTION="$1"
-AC_MSG_CHECKING(whether we can add $GCC_OPTION to LDFLAGS)
-if test "x$ac_supports_W_linker_passthrough" = "xyes"; then
-  LDFLAGS_saved="$LDFLAGS"
-  LDFLAGS="$LDFLAGS $GCC_OPTION"
-  AC_LINK_IFELSE([
-    AC_LANG_SOURCE([[
-               main() { return; }
-                  ]])],
-                  [
-                    AC_MSG_RESULT(yes)
-                  ],
-                  [
-                    AC_MSG_RESULT(no)
-                    LDFLAGS="$LDFLAGS_saved"
-                  ])
-else
-  AC_MSG_RESULT(no)
-fi
+[LD_OPTION="$1"
+AC_MSG_CHECKING(whether we can add $LD_OPTION to LDFLAGS)
+LDFLAGS_saved="$LDFLAGS"
+LDFLAGS="$LDFLAGS $LD_OPTION"
+AC_LINK_IFELSE(
+  [
+    AC_LANG_SOURCE([[main() { return; }]])
+  ],
+  [
+    AC_MSG_RESULT(yes)
+  ],
+  [
+    AC_MSG_RESULT(no)
+    LDFLAGS="$LDFLAGS_saved"
+  ])
 ])
 
 dnl
@@ -1646,6 +1616,73 @@ AC_DEFUN([AC_WIRESHARK_CHECK_UNKNOWN_WARNING_OPTION_ERROR],
        CFLAGS="$save_CFLAGS"
     ])
 
+dnl
+dnl Check whether, if you pass a valid-for-C-but-not-C++ option to the
+dnl compiler, it fails or just prints a warning message and succeeds.
+dnl Set ac_wireshark_non_cxx_warning_option_error to the appropriate flag
+dnl to force an error if it would otherwise just print a warning message
+dnl and succeed.
+dnl
+AC_DEFUN([AC_WIRESHARK_CHECK_NON_CXX_WARNING_OPTION_ERROR],
+    [
+       AC_MSG_CHECKING([whether the compiler fails when given an warning option not supported for C++])
+       #
+       # Some C+ compilers warn about -Wmissing-prototypes, and some warn
+       # about -Wmissing-declarations.  Check both.
+       #
+       AC_LANG_PUSH(C++)
+       save_CXXFLAGS="$CXXFLAGS"
+       for flag in -Wmissing-prototypes -Wmissing-declarations; do
+           CXXFLAGS="$save_CXXFLAGS $flag"
+           AC_TRY_COMPILE(
+               [],
+               [return 0],
+               [
+                   #
+                   # We're assuming this is g++, where -Werror is the
+                   # appropriate option to force the compiler to fail.
+                   # Check whether it fails with -Werror.
+                   #
+                   # NOTE: it's important to put -Werror *before*
+                   # the flag, otherwise, when it sees the flag,
+                   # it doesn't yet know that warnings should be
+                   # treated as errors, and doesn't treat the
+                   # "that's C-only" warning as an error.
+                   #
+                   CXXFLAGS="$save_CXXFLAGS -Werror $flag"
+                   AC_TRY_COMPILE(
+                       [],
+                       [return 0],
+                       [
+                           #
+                           # No, so this option is actually OK
+                           # with our C++ compiler.
+                           #
+                           # (We need an empty command here to
+                           # prevent some versions of autoconf
+                           # from generating a script with an
+                           # empty "then" clause for an if statement.)
+                           #
+                           :
+                       ],
+                       [
+                           #
+                           # Yes, so we need -Werror for the tests.
+                           #
+                           ac_wireshark_non_cxx_warning_option_error="-Werror"
+                           break
+                       ])
+               ])
+       done
+       CXXFLAGS="$save_CXXFLAGS"
+       AC_LANG_POP
+       if test x$ac_wireshark_non_cxx_warning_option_error = x; then
+           AC_MSG_RESULT([yes])
+       else
+           AC_MSG_RESULT([no, adding -Werror])
+       fi
+    ])
+
 #
 # AC_WIRESHARK_COMPILER_FLAGS_CHECK
 #
@@ -1681,8 +1718,8 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
     # compilers treat unknown warning options as errors (I'm looking at
     # you, clang).
     #
-    # If the option begins with "-f", add -Werror to make sure that
-    # we'll get an error if we get "argument unused during compilation"
+    # If the option begins with "-f" or "-m", add -Werror to make sure
+    # that we'll get an error if we get "argument unused during compilation"
     # warnings, as those will either cause a failure for files compiled
     # with -Werror or annoying noise for files compiled without it.
     # (Yeah, you, clang.)
@@ -1695,6 +1732,11 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
     elif expr "x$GCC_OPTION" : "x-f.*" >/dev/null
     then
       CFLAGS="$CFLAGS -Werror $GCC_OPTION"
+    elif expr "x$GCC_OPTION" : "x-m.*" >/dev/null
+    then
+      CFLAGS="$CFLAGS -Werror $GCC_OPTION"
+    else
+      CFLAGS="$CFLAGS $GCC_OPTION"
     fi
     AC_COMPILE_IFELSE(
       [
@@ -1756,14 +1798,35 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
     #
     # Not C-only; if this can be added to the C++ compiler flags, add them.
     #
+    # If the option begins with "-W", add
+    # $ac_wireshark_unknown_warning_option_error, as per the above, and
+    # also add $ac_wireshark_non_cxx_warning_option_error, because at
+    # lease some versions of g++ whine about -Wmissing-prototypes, the
+    # fact that at least one of those versions refuses to warn about
+    # function declarations without an earlier declaration nonwithstanding;
+    # perhaps there's a reason not to warn about that with C++ even though
+    # warning about it can be a Good Idea with C, but it's not obvious to
+    # me).
+    #
+    # If the option begins with "-f" or "-m", add -Werror to make sure
+    # that we'll get an error if we get "argument unused during compilation"
+    # warnings, as those will either cause a failure for files compiled
+    # with -Werror or annoying noise for files compiled without it.
+    # (Yeah, you, clang++.)
+    #
     AC_MSG_CHECKING(whether we can add $GCC_OPTION to CXXFLAGS)
     CXXFLAGS_saved="$CXXFLAGS"
     if expr "x$GCC_OPTION" : "x-W.*" >/dev/null
     then
-      CXXFLAGS="$CXXFLAGS $ac_wireshark_unknown_warning_option_error $GCC_OPTION"
+      CXXFLAGS="$CXXFLAGS $ac_wireshark_unknown_warning_option_error $ac_wireshark_non_cxx_warning_option_error $GCC_OPTION"
     elif expr "x$GCC_OPTION" : "x-f.*" >/dev/null
     then
       CXXFLAGS="$CXXFLAGS -Werror $GCC_OPTION"
+    elif expr "x$GCC_OPTION" : "x-m.*" >/dev/null
+    then
+      CXXFLAGS="$CXXFLAGS -Werror $GCC_OPTION"
+    else
+      CXXFLAGS="$CXXFLAGS $GCC_OPTION"
     fi
     AC_LANG_PUSH([C++])
     AC_COMPILE_IFELSE(
@@ -1818,10 +1881,19 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
   if test "(" "$can_add_to_cflags" = "yes" -a "$can_add_to_cxxflags" = "no" ")" \
        -o "(" "$can_add_to_cflags" = "no" -a "$can_add_to_cxxflags" = "yes" ")"
   then
-    AC_MSG_WARN([$CC and $CXX appear to be a mismatched pair])
+    #
+    # Confusingly, some C++ compilers like -Wmissing-prototypes but
+    # don't like -Wmissing-declarations and others like
+    # -Wmissing-declarations but don't like -Wmissing-prototypes,
+    # the fact that the corresponding C compiler likes both.  Don't
+    # warn about them.
+    #
+    if test "(" x$GCC_OPTION != x-Wmissing-prototypes ")" \
+         -a "(" x$GCC_OPTION != x-Wmissing-declarations ")"
+    then
+       AC_MSG_WARN([$CC and $CXX appear to be a mismatched pair])
+    fi
   fi
-else
-  AC_MSG_RESULT(no)
 fi
 ])
 
@@ -2049,6 +2121,13 @@ AC_DEFUN([AC_WIRESHARK_QT_CHECK],
                #
                AC_WIRESHARK_QT_MODULE_CHECK(PrintSupport, $1)
 
+               #
+               # Qt 5.0 added multimedia widgets in the Qt
+               # MultimediaWidgets module.
+               #
+               AC_WIRESHARK_QT_MODULE_CHECK(MultimediaWidgets, $1,
+                       AC_DEFINE(QT_MULTIMEDIAWIDGETS_LIB, 1, [Define if we have QtMultimediaWidgets]))
+
                #
                # While we're at it, look for QtMacExtras.  (Presumably
                # if we're not building for OS X, it won't be present.)
@@ -2069,84 +2148,3 @@ AC_DEFUN([AC_WIRESHARK_QT_CHECK],
        fi
 
 ])
-
-#
-# AC_WIRESHARK_PYTHON_CHECK
-#
-# Check whether python devel package is present
-#
-AC_DEFUN([AC_WIRESHARK_PYTHON_CHECK],
-  [
-    #
-    # Checking whether we have a python devel environment available
-    #
-#  AC_CACHE_CHECK([checking python devel package], ac_cv_wireshark_python_devel,
-#    [
-    AC_CHECK_PROG([ac_ws_python_config], python-config, "yes", "no")
-    if test "x$ac_ws_python_config" = "xno"; then
-      ac_cv_wireshark_python_devel=no
-        if test "x$want_python" = "xyes"
-        then
-            #
-            # The user tried to force us to use Python, but we
-            # couldn't find the python-config tool; report an error.
-            #
-            AC_MSG_ERROR("python-config not found")
-        fi
-        #
-        # Set want_python to no, so we report that we aren't using
-        # the Python interpreter.
-        #
-        want_python=no
-    else
-      AC_MSG_CHECKING([python devel])
-      ac_save_ws_cflags=$CFLAGS
-      ac_save_ws_libs=$LIBS
-      CFLAGS=$(python-config --includes)
-      LIBS=$(python-config --ldflags)
-      AC_COMPILE_IFELSE(
-        [
-          AC_LANG_PROGRAM(
-            [[#include <Python.h>]],
-            [[Py_Initialiaze();]]
-          )
-        ],
-        [
-          #
-          # Compilation successful, we have python devel available
-          #
-          ac_cv_wireshark_python_devel=yes
-          PY_LIBS=$LIBS
-          PY_CFLAGS=$CFLAGS
-          AC_SUBST(PY_LIBS)
-          AC_SUBST(PY_CFLAGS)
-          CFLAGS="$ac_save_ws_cflags"
-          LIBS="$ac_save_ws_libs"
-          AC_DEFINE(HAVE_PYTHON, 1, [Define if python devel package available])
-          AC_MSG_RESULT([yes])
-        ],
-        [
-          #
-          # Compilation unsuccessful, python devel not available
-          #
-          ac_cv_wireshark_python_devel=no
-          CFLAGS=$ac_save_ws_cflags
-          LIBS=$ac_save_ws_libs
-          if test "x$want_python" = "xyes"
-          then
-            #
-            # The user tried to force us to use Python, but we
-            # couldn't compile the test program; report an error.
-            #
-            AC_MSG_ERROR("Python test program failed compilation")
-          fi
-          AC_MSG_RESULT([no])
-          #
-          # Set want_python to no, so we report that we aren't using
-          # the Python interpreter.
-          #
-          want_python=no
-        ])
-    fi
-#    ])
-])