From e.yimjia via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9289 :
[metze/wireshark/wip.git] / configure.ac
index 61e8896d8c5622cdc0990c9dfe1591cec6567309..6909f974962c8e92462679a93b443ba44df066c0 100644 (file)
@@ -3,7 +3,7 @@
 
 m4_define([version_major], [1])
 m4_define([version_minor], [11])
-m4_define([version_micro], [0])
+m4_define([version_micro], [1])
 m4_define([version_micro_extra], version_micro)
 m4_append([version_micro_extra], [])
 
@@ -51,36 +51,67 @@ AC_PROG_CC
 AM_PROG_CC_C_O
 AC_PROG_CXX
 AC_PROG_CPP
+AC_WIRESHARK_CLANG_CHECK
+
 dnl Work around libtool bug (fixed in the version 1.5a?)
 AC_DEFUN([AC_PROVIDE_AC_LIBTOOL_DLOPEN], )
 AC_LIBTOOL_DLOPEN
 AC_PROG_LIBTOOL
+if test ! -z "$CXX"; then
+       #
+       # OK, we found something AC_LANG_CXX thinks is a C++ compiler,
+       # but is it one?
+       #
+       # Some UN*Xes have, by default, a case-insensitive file
+       # system, and AC_PROG_CXX looks for, among other things,
+       # "CC" as a C++ compiler, and, if you have a case-insensitive
+       # file system and a C compiler named "cc" (both true, by
+       # default, on OS X), AC_PROG_CXX may end up thinking it's
+       # the C++ compiler.
+       #
+       # So we check by feeding the purported C++ compiler a
+       # program using C++ features (iostream).
+       #
+       # We do this after AC_PROG_LIBTOOL; if we did so before, and
+       # cleared CXX if what we had isn't a C++ compiler, that'd
+       # get undone by AC_PROG_LIBTOOL for some reason.
+       #
+       AC_MSG_CHECKING(whether $CXX is a C++ compiler)
+       AC_LANG_PUSH([C++])
+       AC_LINK_IFELSE([AC_LANG_PROGRAM(
+       [
+#include <iostream>
+       ],
+       [
+       std::cout << "Hello World! ";
+       return 0;
+       ])],
+               [AC_MSG_RESULT(yes)],
+               [
+                       AC_MSG_RESULT(no)
+                       CXX=""
+               ])
+       AC_LANG_POP([C++])
+fi
 AC_PATH_PROG(PERL, perl)
 
 # Check for Python.
 AC_PATH_PROG(PYTHON, python)
 if test ! -z "$PYTHON"; then
        #
-       # OK, we found Python; is it Python 2.x?
+       # OK, we found Python; is it Python 2.5 or later?
        # Note: we don't use named components for sys.version_info to get
        # the major version number, as named components for version_info
        # were apparently introduced in Python 2.7.
        #
-       AC_MSG_CHECKING([whether $PYTHON is Python 2])
-       python_major_version=`$PYTHON -c 'import sys; print sys.version_info[[0]]'`
-       if test "$python_major_version" = 2; then
-               AC_MSG_RESULT([yes])
+       AC_MSG_CHECKING([whether $PYTHON is Python 2.5 or later])
+       python_major_version=`$PYTHON -c 'import sys; print (sys.version_info[[0]])'`
+       python_minor_version=`$PYTHON -c 'import sys; print (sys.version_info[[1]])'`
+       if test "$python_major_version" -eq 2 -a "$python_minor_version" -lt 5 ; then
+               AC_MSG_RESULT(no)
+               AC_MSG_WARN([Building with Python $python_major_version.$python_minor_version may not work])
        else
-               #
-               # It's not 2.x.
-               #
-               AC_MSG_RESULT([no])
-
-               #
-               # Try looking for python2; if we find it, we assume it's
-               # Python 2
-               #
-               AC_PATH_PROG(PYTHON, python2)
+               AC_MSG_RESULT(yes)
        fi
 fi
 
@@ -223,11 +254,237 @@ AM_CONDITIONAL(HAVE_DOXYGEN, test x$HAVE_DOXYGEN = xyes)
 #
 PKG_PROG_PKG_CONFIG
 
+AC_ARG_ENABLE(osx-deploy-target,
+  AC_HELP_STRING( [--enable-osx-deploy-target],
+    [choose an OS X deployment target @<:@default=major release on which you're building@:>@]),
+[
+       #
+       # Is this OS X?
+       #
+       case "$host_os" in
+       darwin*)
+               #
+               # Yes.
+               #
+               # Let the user specify an OS X release to use as a
+               # deplayment target; if they specify that we should
+               # have a deployment target but don't specify the
+               # deployment target, then, if we have SDKs available,
+               # pick the OS version on which the build is being done.
+               # This also causes the build to be done against an SDK
+               # rather than against the headers and libraries in
+               # /usr/include and /usr/lib.
+               #
+               # Check for an OS X deployment target early, so that
+               # as many tests using the compiler are done using the
+               # flags that we'll be using when building.
+               #
+               if test $enableval = no
+               then
+                       #
+                       # The user explicitly said
+                       # --disable-osx-deploy-target, so don't build
+                       # against an SDK.
+                       #
+                       deploy_target=
+               elif test $enableval = yes
+               then
+                       #
+                       # The user said --enable-osx-deploy-target, but
+                       # didn't say what version to target; target the
+                       # major version number of the version of OS X on
+                       # which we're running.
+                       #
+                       # (We quote the command so that we can use
+                       # autoconf's M4 quoting characters, [ and ], in
+                       # the sed expression.)
+                       #
+                       [deploy_target=`sw_vers -productVersion | sed 's/\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.[0-9]*/\1.\2/'`]
+               else
+                       deploy_target="$enableval"
+               fi
+               ;;
+
+       *)
+               #
+               # No.  Fail, because whatever the user intended for us to
+               # do, we can't do it.
+               #
+               AC_MSG_ERROR([--enable-osx-deploy-target specified on an OS other than OS X])
+               ;;
+       esac
+],[
+       #
+       # Is this OS X?
+       #
+       case "$host_os" in
+       darwin*)
+               #
+               # Yes.
+               #
+               # If we have SDKs available, default to targeting the major
+               # version number of the version of OS X on which we're
+               # running.
+               #
+               # (We quote the command so that we can use autoconf's
+               # M4 quoting characters, [ and ], in the sed expression.)
+               #
+               for i in /Developer/SDKs \
+                   /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \
+                   /Library/Developer/CommandLineTools/SDKs
+               do
+                       if test -d "$i"
+                       then
+                               [deploy_target=`sw_vers -productVersion | sed 's/\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.[0-9]*/\1.\2/'`]
+                               break
+                       fi
+               done
+               ;;
+
+       *)
+               #
+               # No.  There's nothing to do.
+               #
+               ;;
+       esac
+])
+
+if test ! -z "$deploy_target"
+then
+       AC_MSG_CHECKING([whether we can build for OS X $deploy_target])
+       case $deploy_target in
+
+       10.0|10.1|10.2)
+               #
+               # I'm not sure this would even work.
+               #
+               AC_MSG_RESULT(no)
+               AC_ERROR([We don't support building for OS X $deploy_target])
+               ;;
+
+       10.3)
+               #
+               # XXX - never tested.
+               #
+               AC_MSG_RESULT(yes)
+               SDKPATH="/Developer/SDKs/MacOSX10.3.9.sdk"
+               ;;
+
+       *)
+               #
+               # XXX - for 10.4, do we need 10.4u?  We're
+               # not currently doing fat builds (we'd need
+               # fat versions of the support libraries for
+               # that to be useful), but, if we do, we'd
+               # need to use 10.4u.
+               #
+               for i in /Developer/SDKs \
+                   /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \
+                   /Library/Developer/CommandLineTools/SDKs
+               do
+                       if test -d "$i"/"MacOSX$deploy_target.sdk"
+                       then
+                               SDKPATH="$i"/"MacOSX$deploy_target.sdk"
+                               break
+                       fi
+               done
+               if test -z "$SDKPATH"
+               then
+                       AC_MSG_RESULT(no)
+                       AC_MSG_ERROR([We couldn't find the SDK for OS X $deploy_target])
+               fi
+               AC_MSG_RESULT(yes)
+               ;;
+       esac
+
+       #
+       # Add a -mmacosx-version-min flag to force tests that
+       # use the compiler, as well as the build itself, not to,
+       # for example, use compiler or linker features not supported
+       # by the minimum targeted version of the OS.
+       #
+       # Add an -isysroot flag to use the SDK.
+       #
+       CFLAGS="-mmacosx-version-min=$deploy_target -isysroot $SDKPATH $CFLAGS"
+       CXXFLAGS="-mmacosx-version-min=$deploy_target -isysroot $SDKPATH $CXXFLAGS"
+       LDFLAGS="-mmacosx-version-min=$deploy_target -isysroot $SDKPATH $LDFLAGS"
+
+       #
+       # Add a -sdkroot flag to use with osx-app.sh.
+       #
+       OSX_APP_FLAGS="-sdkroot $SDKPATH"
+
+       #
+       # XXX - do we need this to build the Wireshark wrapper?
+       # XXX - is this still necessary with the -mmacosx-version-min
+       # flag being set?
+       #
+       OSX_DEPLOY_TARGET="MACOSX_DEPLOYMENT_TARGET=$deploy_target"
+
+       #
+       # In the installer package XML file, give the deployment target
+       # as the minimum version.
+       #
+       OSX_MIN_VERSION="$deploy_target"
+
+       case $deploy_target in
+
+       10.4|10.5)
+               #
+               # Only 32-bit builds are supported.  10.5
+               # (and 10.4?) had a bug that causes some BPF
+               # functions not to work with 64-bit userland
+               # code, so capturing won't work.
+               #
+               CFLAGS="-m32 $CFLAGS"
+               CXXFLAGS="-m32 $CXXFLAGS"
+               LDFLAGS="-m32 $LDFLAGS"
+               ;;
+       esac
+else
+       #
+       # Is this OS X?
+       #
+       case "$host_os" in
+       darwin*)
+               #
+               # Yes.
+               #
+               # In the installer package XML file, give the current OS
+               # version, minor version and all, as the minimum version.
+               # We can't guarantee that the resulting binary will work
+               # on older OS versions, not even older minor versions
+               # (original release or earlier software updates).
+               #
+               OSX_MIN_VERSION=`sw_vers -productVersion`
+               ;;
+       esac
+fi
+AC_SUBST(OSX_MIN_VERSION)
+
 #
 # Try to arrange for large file support.
 #
 AC_SYS_LARGEFILE
 
+#
+# GUI toolkit options
+#
+AC_ARG_WITH([qt],
+  AC_HELP_STRING( [--with-qt=@<:@yes/no@:>@],
+                  [use Qt @<:@default=yes@:>@]),
+  with_qt="$withval", with_qt="unspecified")
+
+AC_ARG_WITH([gtk2],
+  AC_HELP_STRING( [--with-gtk2=@<:@yes/no@:>@],
+                  [use GTK+ 2.0 @<:@default=no@:>@]),
+  with_gtk2="$withval", with_gtk2="unspecified")
+
+AC_ARG_WITH([gtk3],
+  AC_HELP_STRING( [--with-gtk3=@<:@yes/no@:>@],
+                  [use GTK+ 3.0 instead of 2.0 @<:@default=yes@:>@]),
+  with_gtk3="$withval", with_gtk3="unspecified")
+
 # GnuTLS
 # Version 3.0 switched from LGPLv2.1+ to LGPLv3+, then switched back to
 # LGPLv2.1+ in version 3.1.10
@@ -282,11 +539,6 @@ if test "x$with_gcrypt" = "xyes"; then
   )
 fi
 
-AC_ARG_WITH([qt],
-  AC_HELP_STRING( [--with-qt=@<:@yes/no@:>@],
-                  [use Qt instead of GTK+ @<:@default=no@:>@]),
-  with_qt="$withval", with_qt="no")
-
 AC_ARG_WITH(libnl,
   AC_HELP_STRING([--with-libnl@<:@=VERSION@:>@],
                  [use libnl (force version VERSION, if supplied) @<:@default: yes, if available@:>@]),
@@ -406,11 +658,6 @@ linux*)
        fi
 esac
 
-AC_ARG_WITH([gtk3],
-  AC_HELP_STRING( [--with-gtk3=@<:@yes/no@:>@],
-                  [use GTK+ 3.0 instead of 2.0 @<:@default=no@:>@]),
-  with_gtk3="$withval", with_gtk3="no")
-
 # libsmi
 # FIXME: currently the path argument to with-libsmi is being ignored
 AX_LIBSMI
@@ -499,6 +746,12 @@ else
 fi
 AC_SUBST(HAVE_OSX_PACKAGING)
 
+#
+# Some compilers have to be told to fail on unknown warning errors;
+# make sure we do that.
+#
+AC_WIRESHARK_CHECK_UNKNOWN_WARNING_OPTION_ERROR
+
 #
 # Try to add some additional gcc checks to CFLAGS
 #
@@ -509,12 +762,12 @@ AC_ARG_ENABLE(extra-gcc-checks,
        wireshark_extra_gcc_flags=$enableval
        if test $enableval != no
        then
-               AC_WIRESHARK_GCC_CFLAGS_CHECK(-pedantic)
+               AC_WIRESHARK_COMPILER_FLAGS_CHECK(-pedantic)
                #
                # Various code blocks this one.
                #
-               AC_WIRESHARK_GCC_CFLAGS_CHECK(-Woverflow)
-               AC_WIRESHARK_GCC_CFLAGS_CHECK(-fstrict-overflow -Wstrict-overflow=4)
+               AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Woverflow)
+               AC_WIRESHARK_COMPILER_FLAGS_CHECK(-fstrict-overflow -Wstrict-overflow=4)
                #
                # Some memset() calls to clear out structures
                # on the stack are getting flagged as "will never
@@ -523,56 +776,62 @@ AC_ARG_ENABLE(extra-gcc-checks,
                # Apple Inc. build 5658) (LLVM build 2336.11.00), for
                # some unknown reason.
                #
-               AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wunreachable-code)
+               AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wunreachable-code)
                #
                # Due to various places where APIs we don't control
                # require us to cast away constness, we can probably
                # never enable these ones with -Werror.
                #
-               AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wcast-qual)
-               AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wbad-function-cast, C)
+               AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wcast-qual)
+               AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wbad-function-cast, C)
                #
                # Some generated ASN.1 dissectors block this one;
                # multiple function declarations for the same
                # function are being generated.
                #
-               AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wredundant-decls)
+               AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wredundant-decls)
                #
                # Some loops are safe, but it's hard to convince the
                # compiler of that.
                #
-               AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wunsafe-loop-optimizations)
+               AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wunsafe-loop-optimizations)
                #
                # All the registration functions block these for now.
                #
-               AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wmissing-prototypes)
-               AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wmissing-declarations)
+               AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wmissing-prototypes)
+               AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wmissing-declarations)
+               #
+               # A bunch of "that might not work on SPARC" code blocks
+               # this one for now.
+               #
+               AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wcast-align)
        fi
 ],)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wall -W) # -W is now known as -Wextra
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wextra) # -W is now known as -Wextra
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wdeclaration-after-statement, C)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wendif-labels)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wpointer-arith)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-pointer-sign, C)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Warray-bounds)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wcast-align)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wformat-security)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wold-style-definition, C)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wshorten-64-to-32)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wstrict-prototypes, C)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wjump-misses-init, C)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wvla)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Waddress)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Warray-bounds)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wattributes)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wdiv-by-zero)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wignored-qualifiers)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wpragmas)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-overlength-strings)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wwrite-strings)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-long-long)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wc++-compat, C)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wall -W) # -W is now known as -Wextra
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wextra) # -W is now known as -Wextra
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wdeclaration-after-statement, C)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wendif-labels)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wpointer-arith)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wno-pointer-sign, C)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Warray-bounds)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wformat-security)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wold-style-definition, C)
+# The Qt headers generate a ton of shortening errors on 64-bit systems
+# so only enable this for C for now.
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wshorten-64-to-32, C)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wstrict-prototypes, C)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wjump-misses-init, C)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wvla)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Waddress)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Warray-bounds)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wattributes)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wdiv-by-zero)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wignored-qualifiers)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wpragmas)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wno-overlength-strings)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wwrite-strings)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wno-long-long)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wc++-compat, C)
 
 #
 # XXX - OK for C++?
@@ -583,7 +842,7 @@ AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wc++-compat, C)
 # some Xcode versions that came with Mac OS X 10.5) complain about
 # that.
 #
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wshadow, C,
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wshadow, C,
   [
 extern int bar(int a);
 extern int foo(int);
@@ -601,7 +860,7 @@ foo(int a)
 # Unfortunately some versions of gcc generate logical-op warnings when strchr()
 # is given a constant string.
 # gcc versions 4.3.2 and 4.4.5 are known to have the problem.
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wlogical-op, C,
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wlogical-op, C,
   [
 #include <string.h>
 
@@ -626,21 +885,27 @@ bar(void)
   [generates warnings from strchr()])
 
 
-## AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-error=unused-but-set-variable)
+#
+# On OS X, suppress warnings about deprecated declarations, because
+# they apparently think everything on OS X is Shiny Happy Apple-
+# Framework-Based Apps and are deprecating some perfectly OK
+# multi-platform open-source libraries that we use in our multi-platform
+# open-source application in favor of various frameworks that are
+# OS X-only.
+#
+case "$host_os" in
+darwin*)
+       AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wno-deprecated-declarations)
+       ;;
+esac
 
 #
-# Use the faster pre gcc 4.5 floating point precision if available;
-# clang doesn't error out on -f options that it doesn't know about,
-# it just warns and ignores them, so this check doesn't cause us
-# to omit -fexcess-precision=fast, which produces a pile of
-# annoying warnings.
+# Use the faster pre gcc 4.5 floating point precision if available.
 #
-if test "x$CC" != "xclang" ; then
-  AC_WIRESHARK_GCC_CFLAGS_CHECK(-fexcess-precision=fast)
-fi
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-fexcess-precision=fast)
 
 CFLAGS_before_fvhidden=$CFLAGS
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-fvisibility=hidden)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-fvisibility=hidden)
 if test "x$CLFAGS" = "x$CFLAGS_before_fvhidden"
 then
        # TODO add other ways of hiding symbols
@@ -661,7 +926,7 @@ AC_WIRESHARK_LDFLAGS_CHECK([-Wl,--as-needed])
 # in the address space to make attacks more difficult.
 #
 CFLAGS_before_pie=$CFLAGS
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-fPIE, C)
+AC_WIRESHARK_COMPILER_FLAGS_CHECK(-fPIE, C)
 if test "x$CLFAGS" != "x$CFLAGS_before_pie"
 then
        # Restore CFLAGS
@@ -807,8 +1072,15 @@ darwin*)
        # with a static version installed in /usr/local/lib rather than
        # the system version in /usr/lib).
        #
-       LDFLAGS="-Wl,-search_paths_first $LDFLAGS"
-       AC_MSG_RESULT([Apple linker - added -Wl,-single_module and -Wl,-search_paths_first])
+       # Also add -Wl,-rpath,@executable_path/../lib and
+       # -Wl,-rpath,/usr/local/lib, so that, if we build an app
+       # bundle, we can tweak all the executable images, shared
+       # libraries, and plugins in the bundle to look for non-system
+       # libraries in the rpath, rather than having a script tweak
+       # DYLD_LIBRARY_PATH.
+       #
+       LDFLAGS="-Wl,-search_paths_first -Wl,-rpath,@executable_path/../lib -Wl,-rpath,@executable_path/../Frameworks -Wl,-rpath,/usr/local/lib $LDFLAGS"
+       AC_MSG_RESULT([Apple linker - added -Wl,-single_module and -Wl,-search_paths_first, and rpaths])
        ;;
 cygwin*)
        #
@@ -870,6 +1142,15 @@ AC_SUBST(APPLICATIONSERVICES_FRAMEWORKS)
 AC_SUBST(SYSTEMCONFIGURATION_FRAMEWORKS)
 AC_SUBST(COREFOUNDATION_FRAMEWORKS)
 
+#
+# On Solaris, check whether we have getexecname().
+#
+case "$host_os" in
+solaris*)
+       AC_CHECK_FUNC(getexecname)
+       ;;
+esac
+
 dnl Look in /usr/local for header files and libraries ?
 dnl XXX FIXME don't include /usr/local if it is already in the system
 dnl search path as this causes gcc 3.2 on Linux to complain about a change
@@ -954,10 +1235,9 @@ if test "$HAVE_GNU_SED" = no ; then
 fi
 
 # Enable/disable wireshark
-
 AC_ARG_ENABLE(wireshark,
   AC_HELP_STRING( [--enable-wireshark],
-                  [build GTK+-based Wireshark @<:@default=yes, if GTK+ available@:>@]),
+                  [build the Wireshark GUI (with Gtk+, Qt, or both) @<:@default=yes@:>@]),
     enable_wireshark=$enableval,enable_wireshark=yes)
 
 AC_ARG_ENABLE(packet-editor,
@@ -1040,70 +1320,87 @@ AC_SUBST(QT_MIN_VERSION)
 # 3.6.0:  24 Sep 2012
 # 3.8.0:  25 Mar 2013
 
+have_qt=no
+have_gtk=no
 if test "x$enable_wireshark" = "xyes"; then
+       if test "x$with_gtk2" = "xunspecified" -a \
+               "x$with_gtk3" = "xunspecified" -a \
+               "x$with_qt" = "xunspecified"; then
+               #
+               # No GUI toolkit was explicitly specified; pick Qt and GTK+ 3.
+               #
+               with_qt=yes
+               with_gtk3=yes
+       fi
        if test "x$with_qt" = "xyes"; then
+               #
+               # Qt was specified; Make sure we have a C++ compiler.
+               #
+               if test -z "$CXX"; then
+                       AC_MSG_ERROR(Need a working C++ compiler to build Wireshark with Qt)
+               fi
 
-               AC_MSG_CHECKING(whether we have a working C++ compiler)
-               AC_LANG_PUSH([C++])
-               AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
-                       [AC_MSG_RESULT(yes)],
-                       [
-                        AC_MSG_RESULT(no)
-                        AC_MSG_ERROR(Need a working C++ compiler to build Wireshark with Qt)
-                       ])
-               AC_LANG_POP([C++])
-
-               AM_PATH_QT($QT_MIN_VERSION,
+               #
+               # Now make sure we have Qt and, if so, add the flags
+               # for it to CFLAGS and CXXFLAGS.
+               #
+               AC_WIRESHARK_QT_CHECK($QT_MIN_VERSION,
                [
                        CFLAGS="$CFLAGS $Qt_CFLAGS"
                        CXXFLAGS="$CXXFLAGS $Qt_CFLAGS"
                        have_qt=yes
-               ]
-               , [AC_MSG_ERROR([Qt is not available])])
+                       GUI_CONFIGURE_FLAGS="$GUI_CONFIGURE_FLAGS --with-qt"
+                       OSX_APP_FLAGS="$OSX_APP_FLAGS -qt"
+                       OSX_DMG_FLAGS="-qt"
+               ],
+               [AC_MSG_ERROR([Qt is not available])])
 
                #
                # XXX - greasy hack to make ui/gtk/recent.c
                # compile.
                #
                CPPFLAGS="-DQT_GUI_LIB"
+       fi
 
+       if test "x$with_gtk3" = "xyes"; then
                #
-               # We don't know whether we have GTK+, but we
-               # won't be using it, so it's as if we don't
-               # have it.
+               # GTK+ 3 was specified; make sure they didn't also
+               # specify GTK+ 2, as we don't support building both
+               # GTK+ 2 and GTK+ 3 versions at the same time.
                #
-               have_gtk=no
-       else
+               if test "x$with_gtk2" = "xyes"; then
+                       AC_MSG_ERROR([Both GTK+ 2 and GTK+ 3 were specified; choose one but not both])
+               fi
+
                #
-               # Not Qt - either GTK+ 3.x or 2.x.
+               # Make sure we have GTK+ 3.
                #
-               if test "x$with_gtk3" = "xyes"; then
-                       AM_PATH_GTK_3_0(3.0.0,
-                       [
-                               CFLAGS="$CFLAGS $GTK_CFLAGS"
-                               CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
-                               have_gtk=yes
-                               AC_DEFINE(HAVE_GTK, 1,
-                                   [Define to 1 if compiling with GTK])
-                       ], have_gtk=no)
-
-               else
-                       AM_PATH_GTK_2_0($GTK2_MIN_VERSION,
-                       [
-                               CFLAGS="$CFLAGS $GTK_CFLAGS"
-                               CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
-                               have_gtk=yes
-                               AC_DEFINE(HAVE_GTK, 1,
-                                   [Define to 1 if compiling with GTK])
-                       ], have_gtk=no)
-               fi
+               AM_PATH_GTK_3_0(3.0.0,
+               [
+                       CFLAGS="$CFLAGS $GTK_CFLAGS"
+                       CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
+                       have_gtk=yes
+                       GUI_CONFIGURE_FLAGS="$GUI_CONFIGURE_FLAGS --with-gtk3"
+               ],
+               [AC_MSG_ERROR([GTK+ 3 is not available])])
+       elif test "x$with_gtk2" = "xyes"; then
+               #
+               # GTK+ 3 wasn't specified, and GTK+ 2 was specified;
+               # make sure we have GTK+ 2.
+               #
+               AM_PATH_GTK_2_0($GTK2_MIN_VERSION,
+               [
+                       CFLAGS="$CFLAGS $GTK_CFLAGS"
+                       CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
+                       have_gtk=yes
+                       GUI_CONFIGURE_FLAGS="$GUI_CONFIGURE_FLAGS --with-gtk2"
+               ],
+               [AC_MSG_ERROR([GTK+ 2 is not available])])
        fi
-else
-       have_qt=no
-       have_gtk=no
 fi
+AC_SUBST(GUI_CONFIGURE_FLAGS)
 
-GLIB_MIN_VERSION=2.14.0
+GLIB_MIN_VERSION=2.16.0
 AC_SUBST(GLIB_MIN_VERSION)
 # GLib checks; we require GLib $GLIB_MIN_VERSION or later, and require gmodule
 # support, as we need that for dynamically loading plugins.
@@ -1132,61 +1429,52 @@ AC_SUBST(GLIB_MIN_VERSION)
 # 2.34.0: 24 Sep 2012
 # 2.36.0: 25 Mar 2013
 
-have_wireshark_cxx="false"
-if test "$have_gtk" = "no" ; then
+use_glib_cflags="true"
+if test "$have_gtk" = "yes" -a "$have_qt" = "yes" ; then
+       # We have both GTK and Qt and thus will be building both wireshark
+       # and wireshark-qt.
+
+       wireshark_bin="wireshark\$(EXEEXT) wireshark-qt\$(EXEEXT)"
+       wireshark_man="wireshark.1"
+       wireshark_SUBDIRS="codecs ui/qt ui/gtk"
+fi
+if test "$have_gtk" = "no" -a "$have_qt" = "yes" ; then
+       # We don't have GTK+ but we have Qt.
+
+       wireshark_bin="wireshark-qt\$(EXEEXT)"
+       wireshark_man="wireshark.1"
+       wireshark_SUBDIRS="codecs ui/qt"
+fi
+if test "$have_gtk" = "yes" -a "$have_qt" = "no" ; then
+       # We have GTK+ but not Qt.
+
+       wireshark_bin="wireshark\$(EXEEXT)"
+       wireshark_man="wireshark.1"
+       wireshark_SUBDIRS="codecs ui/gtk"
+       use_glib_cflags="false"
+fi
+if test "$have_gtk" = "no" -a "$have_qt" = "no" ; then
+       # We have neither GTK+ nor Qt.
        #
-       # We don't have GTK+.
+       # If they didn't explicitly say "--disable-wireshark",
+       # fail (so that, unless they explicitly indicated that
+       # they don't want Wireshark, we stop so they know they
+       # won't be getting Wireshark unless they fix the GTK+/Qt
+       # problem).
        #
-       if test "$have_qt" = "yes" ; then
-               #
-               # However, we do have Qt, and thus will be building
-               # Wireshark (if the user had explicitly disabled
-               # Wireshark, we wouldn't have looked for Qt, so we
-               # wouldn't think we had it, and thus wouldn't be here).
-               #
-               wireshark_bin="wireshark\$(EXEEXT)"
-               # Give automake a hint that it needs to use c++ linking.
-                have_wireshark_cxx="yes"
-               wireshark_man="wireshark.1"
-               wireshark_SUBDIRS="codecs ui/qt"
-       else
-               #
-               # We don't have Qt, either, which means we have no UI
-               # toolkit.
-               #
-               # If they didn't explicitly say "--disable-wireshark",
-               # fail (so that, unless they explicitly indicated that
-               # they don't want Wireshark, we stop so they know they
-               # won't be getting Wireshark unless they fix the GTK+/Qt
-               # problem).
-               #
-               if test "x$enable_wireshark" = "xyes"; then
-                       if test "x$with_gtk3" = "xyes"; then
-                               AC_MSG_ERROR([GTK+ $GTK3_MIN_VERSION or later isn't available, so Wireshark can't be compiled])
-                       else
-                               AC_MSG_ERROR([Neither Qt nor GTK+ $GTK2_MIN_VERSION or later are available, so Wireshark can't be compiled])
-                       fi
+       if test "x$enable_wireshark" = "xyes"; then
+               if test "x$with_gtk3" = "xyes"; then
+                       AC_MSG_ERROR([Neither Qt nor GTK+ $GTK3_MIN_VERSION or later are available, so Wireshark can't be compiled])
+               else
+                       AC_MSG_ERROR([Neither Qt nor GTK+ $GTK2_MIN_VERSION or later are available, so Wireshark can't be compiled])
                fi
-               wireshark_bin=""
-               wireshark_man=""
        fi
-       # Use GLIB_CFLAGS
-       AM_PATH_GLIB_2_0($GLIB_MIN_VERSION,
-       [
-               CFLAGS="$CFLAGS $GLIB_CFLAGS"
-               CXXFLAGS="$CXXFLAGS $GLIB_CFLAGS"
-       ], AC_MSG_ERROR(GLib $GLIB_MIN_VERSION or later distribution not found.), gthread gmodule)
-else
-       #
-       # We have GTK+, and thus will be building Wireshark (if the user
-       # had explicitly disabled Wireshark, we wouldn't have looked for
-       # GTK+, so we wouldn't think we had it, and thus wouldn't be here).
-       #
-       wireshark_bin="wireshark\$(EXEEXT)"
-       wireshark_man="wireshark.1"
-       wireshark_SUBDIRS="codecs ui/gtk"
-       # Don't use GLIB_CFLAGS
-       AM_PATH_GLIB_2_0($GLIB_MIN_VERSION, , AC_MSG_ERROR(GLib $GLIB_MIN_VERSION or later distribution not found.), gthread gmodule)
+       wireshark_bin=""
+       wireshark_man=""
+fi
+
+if test "$have_gtk" = "yes" ; then
+       # If we have GTK then add flags for it.
 
        CPPFLAGS="-DGDK_PIXBUF_DISABLE_DEPRECATED $CPPFLAGS"
        CPPFLAGS="-DGDK_DISABLE_DEPRECATED $CPPFLAGS"
@@ -1199,6 +1487,19 @@ else
        fi
 fi
 
+# XXX - Is this really necessary?  When we build with both Gtk+ and Qt it works...
+if test "$use_glib_cflags" = "true"; then
+       # Use GLIB_CFLAGS
+       AM_PATH_GLIB_2_0($GLIB_MIN_VERSION,
+       [
+               CFLAGS="$CFLAGS $GLIB_CFLAGS"
+               CXXFLAGS="$CXXFLAGS $GLIB_CFLAGS"
+       ], AC_MSG_ERROR(GLib $GLIB_MIN_VERSION or later distribution not found.), gthread gmodule)
+else
+       # Don't use GLIB_CFLAGS
+       AM_PATH_GLIB_2_0($GLIB_MIN_VERSION, , AC_MSG_ERROR(GLib $GLIB_MIN_VERSION or later distribution not found.), gthread gmodule)
+fi
+
 #
 # "make dist" requires that we have the Qt build tools.
 #
@@ -1305,40 +1606,34 @@ else
 fi
 
 #
-# If we have <dlfcn.h>, check whether we can use dladdr to find a
-# filename (hopefully, a full pathname, but no guarantees) for
-# the executable.
+# If we have <dlfcn.h>, check whether we have dladdr.
 #
 if test "$ac_cv_header_dlfcn_h" = "yes"
 then
-       AC_MSG_CHECKING(whether dladdr can be used to find the pathname of an executable)
+       #
+       # Use GLib compiler flags and linker flags; GLib's gmodule
+       # stuff uses the dl APIs if available, so it might know
+       # what flags are needed.
+       #
        ac_save_CFLAGS="$CFLAGS"
        ac_save_LIBS="$LIBS"
        CFLAGS="$CFLAGS $GLIB_CFLAGS"
        LIBS="$GLIB_LIBS $LIBS"
-       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
+       AC_CHECK_FUNCS(dladdr)
+       if test x$ac_cv_func_dladdr = xno
        then
-               AC_DEFINE(DLADDR_FINDS_EXECUTABLE_PATH, 1, [Define if dladdr can be used to find the path of the executable])
+               #
+               # OK, try it with -ldl, in case you need that to get
+               # dladdr().  For some reason, on Linux, that's not
+               # part of the GLib flags; perhaps GLib itself is
+               # linked with libdl, so that you can link with
+               # Glib and it'll pull libdl in itself.
+               #
+               LIBS="$LIBS -ldl"
+               AC_CHECK_FUNCS(dladdr)
        fi
-       AC_MSG_RESULT($ac_cv_dladdr_finds_executable_path)
+       CFLAGS="$ac_save_CFLAGS"
+       LIBS="$ac_save_LIBS"
 fi
 
 #
@@ -1410,7 +1705,9 @@ fi
 AC_SUBST(wireshark_bin)
 AC_SUBST(wireshark_man)
 AM_CONDITIONAL(HAVE_Qt, test "$have_qt" = "yes")
-AM_CONDITIONAL(HAVE_WIRESHARK_CXX, test "$have_wireshark_cxx" = "yes")
+AM_CONDITIONAL(HAVE_GTK, test "$have_gtk" = "yes")
+AC_SUBST(OSX_APP_FLAGS)
+AC_SUBST(OSX_DMG_FLAGS)
 
 
 # Enable/disable tshark
@@ -1451,6 +1748,30 @@ fi
 AC_SUBST(editcap_bin)
 AC_SUBST(editcap_man)
 
+
+
+# Enable/disable echld
+
+AC_ARG_ENABLE(echld,
+  AC_HELP_STRING( [--enable-echld],
+                  [support echld]),
+    have_echld=$enableval,have_echld=no)
+
+AM_CONDITIONAL(HAVE_ECHLD, test "x$have_echld" = "xyes")
+if test "x$have_echld" = "xyes"
+then
+  AC_DEFINE(HAVE_ECHLD, 1, [Define if echld is enabled])
+  echld_test_bin="echld_test\$(EXEEXT)"
+  echld_dir="echld"
+else
+  have_echld="no"
+  echld_test_bin=""
+  echld_dir=""
+fi
+AC_SUBST(echld_test_bin)
+AC_SUBST(echld_dir)
+
+
 # Enabling/disabling of dumpcap is done later (after we know if we have PCAP
 # or not)
 
@@ -1928,7 +2249,7 @@ AC_SUBST(LIBCAP_LIBS)
 
 dnl Checks for header files.
 dnl Some of these may not be needed: http://hacks.owlfolio.org/header-survey/
-AC_CHECK_HEADERS(direct.h dirent.h fcntl.h grp.h inttypes.h netdb.h pwd.h stdarg.h stddef.h unistd.h)
+AC_CHECK_HEADERS(direct.h dirent.h fcntl.h getopt.h grp.h inttypes.h netdb.h pwd.h stdarg.h stddef.h unistd.h)
 AC_CHECK_HEADERS(sys/ioctl.h sys/param.h sys/socket.h sys/sockio.h sys/stat.h sys/time.h sys/types.h sys/utsname.h sys/wait.h)
 AC_CHECK_HEADERS(netinet/in.h)
 AC_CHECK_HEADERS(arpa/inet.h arpa/nameser.h)
@@ -2174,7 +2495,7 @@ AC_SEARCH_LIBS(inet_aton, [socket nsl], have_inet_aton=yes,
     have_inet_aton=no)
 if test "$have_inet_aton" = no; then
   INET_ATON_LO="inet_aton.lo"
-  AC_DEFINE(NEED_INET_ATON_H, 1, [Define if inet/aton.h needs to be included])
+  AC_DEFINE(HAVE_INET_ATON_H, 0, [Define unless inet/aton.h needs to be included])
 else
   INET_ATON_LO=""
 fi
@@ -2254,7 +2575,6 @@ AC_SUBST(STRPTIME_LO)
 AC_CHECK_FUNCS(getprotobynumber gethostbyname2)
 AC_CHECK_FUNCS(issetugid)
 AC_CHECK_FUNCS(mmap mprotect sysconf)
-AC_CHECK_FUNCS(strtoll)
 
 dnl blank for now, but will be used in future
 AC_SUBST(wireshark_SUBDIRS)
@@ -2351,6 +2671,9 @@ AC_OUTPUT(
   asn1/acse/Makefile
   asn1/ansi_map/Makefile
   asn1/ansi_tcap/Makefile
+  asn1/atn-cm/Makefile
+  asn1/atn-cpdlc/Makefile
+  asn1/atn-ulcs/Makefile
   asn1/c1222/Makefile
   asn1/camel/Makefile
   asn1/cdt/Makefile
@@ -2384,6 +2707,7 @@ AC_OUTPUT(
   asn1/HI2Operations/Makefile
   asn1/hnbap/Makefile
   asn1/idmp/Makefile
+  asn1/ilp/Makefile
   asn1/inap/Makefile
   asn1/isdn-sup/Makefile
   asn1/kerberos/Makefile
@@ -2472,6 +2796,7 @@ AC_OUTPUT(
   packaging/macosx/Info.plist
   packaging/macosx/Makefile
   packaging/macosx/osx-dmg.sh
+  packaging/macosx/Wireshark_package.pmdoc/index.xml
   packaging/nsis/Makefile
   packaging/rpm/Makefile
   packaging/rpm/SPECS/Makefile
@@ -2498,6 +2823,7 @@ AC_OUTPUT(
   tools/lemon/Makefile
   wiretap/Makefile
   wsutil/Makefile
+  echld/Makefile
   _CUSTOM_AC_OUTPUT_
   ,)
 dnl AC_CONFIG_FILES([tools/setuid-root.pl], [chmod +x tools/setuid-root.pl])
@@ -2505,23 +2831,25 @@ dnl AC_CONFIG_FILES([tools/setuid-root.pl], [chmod +x tools/setuid-root.pl])
 
 # Pretty messages
 
-if test "x$have_qt" = "xyes"; then
-       gui_lib_message=" (with Qt)"
-else
-       if test "x$have_gtk" = "xyes"; then
-               if test "x$with_gtk3" = "xyes"; then
-                       gui_lib_message=" (with GTK+ 3"
-               else
-                       gui_lib_message=" (with GTK+ 2"
-               fi
-               if test "x$have_ige_mac" = "xyes"; then
-                       gui_lib_message="$gui_lib_message and Mac OS X integration)"
-               else
-                       gui_lib_message="$gui_lib_message)"
-               fi
+if test "x$have_gtk" = "xyes"; then
+       if test "x$with_gtk3" = "xyes"; then
+               gtk_lib_message=" (with GTK+ 3"
+       else
+               gtk_lib_message=" (with GTK+ 2"
+       fi
+       if test "x$have_ige_mac" = "xyes"; then
+               gtk_lib_message="$gtk_lib_message and Mac OS X integration)"
+       else
+               gtk_lib_message="$gtk_lib_message)"
        fi
 fi
 
+if test "x$have_qt" = "xyes" ; then
+       enable_qtshark="yes"
+else
+       enable_qtshark="no"
+fi
+
 if test "x$enable_setcap_install" = "xyes" ; then
        setcap_message="yes"
 else
@@ -2606,7 +2934,8 @@ fi
 
 echo ""
 echo "The Wireshark package has been configured with the following options."
-echo "                    Build wireshark : $enable_wireshark""$gui_lib_message"
+echo "             Build wireshark (Gtk+) : $have_gtk""$gtk_lib_message"
+echo "                 Build wireshark-qt : $enable_qtshark"
 echo "                       Build tshark : $enable_tshark"
 echo "                     Build capinfos : $enable_capinfos"
 echo "                      Build editcap : $enable_editcap"
@@ -2617,6 +2946,7 @@ echo "                    Build text2pcap : $enable_text2pcap"
 echo "                      Build randpkt : $enable_randpkt"
 echo "                       Build dftest : $enable_dftest"
 echo "                     Build rawshark : $enable_rawshark"
+echo "                        Build echld : $have_echld"
 echo ""
 echo "   Save files as pcap-ng by default : $enable_pcap_ng_default"
 echo "  Install dumpcap with capabilities : $setcap_message"