Fix bugs I introduced. Now
[metze/wireshark/wip.git] / configure.ac
index 8697d4dfc879261d05b19c1efb12cb548ae1c676..03343d20ae60139a6b5dc2f4cc93ba63270e13ec 100644 (file)
@@ -2,7 +2,13 @@
 #
 AC_PREREQ(2.60)
 
-AC_INIT(wireshark, 1.9.0, http://bugs.wireshark.org/, , http://www.wireshark.org/)
+m4_define([version_major], [1])
+m4_define([version_minor], [9])
+m4_define([version_micro], [0])
+m4_define([version_micro_extra], version_micro)
+m4_append([version_micro_extra], [])
+
+AC_INIT(wireshark, [version_major.version_minor.version_micro_extra], http://bugs.wireshark.org/, , http://www.wireshark.org/)
 
 dnl Check for CPU / vendor / OS
 dnl The user is encouraged to use either `AC_CANONICAL_BUILD', or
@@ -26,6 +32,11 @@ AC_CANONICAL_TARGET
 
 AM_INIT_AUTOMAKE([1.9 tar-ustar dist-bzip2 no-dist-gzip])
 
+# Make Wireshark's version available in config.h
+AC_DEFINE(VERSION_MAJOR, version_major, [Wireshark's major version])
+AC_DEFINE(VERSION_MINOR, version_minor, [Wireshark's minor version])
+AC_DEFINE(VERSION_MICRO, version_micro, [Wireshark's micro version])
+
 AM_DISABLE_STATIC
 
 dnl Checks for programs.
@@ -254,6 +265,16 @@ elif (test "${have_libnl1}" = "yes"); then
        enable_airpcap=no
 fi
 
+AC_MSG_CHECKING([if nl80211.h is new enough])
+  AC_TRY_COMPILE([#include <linux/nl80211.h>],
+    [int x = NL80211_FREQUENCY_ATTR_MAX_TX_POWER;
+       x = NL80211_ATTR_SUPPORTED_IFTYPES;
+       x = NL80211_ATTR_SUPPORTED_COMMANDS;
+       x = NL80211_ATTR_WIPHY_FREQ;
+       x = NL80211_CHAN_NO_HT;],
+    [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_NL80211, 1, [nl80211.h is new ehough])],
+    [AC_MSG_RESULT(no)])
+
 AC_MSG_CHECKING([for NL80211_SET_CHANNEL])
   AC_TRY_COMPILE([#include <linux/nl80211.h>],
     [enum nl80211_commands x = NL80211_CMD_SET_CHANNEL;],
@@ -390,10 +411,6 @@ AC_ARG_ENABLE(extra-gcc-checks,
                AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wmissing-prototypes)
                AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wmissing-declarations)
                #
-               # epan/dissectors/packet-afs.c blocks this one for now.
-               #
-               AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wshadow)
-               #
                # More cleanup needed for this on LP64.
                #
                AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wshorten-64-to-32)
@@ -409,6 +426,53 @@ 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)
+
+CFLAGS_before_pie=$CFLAGS
+AC_WIRESHARK_GCC_CFLAGS_CHECK(-fPIE, C)
+if test "x$CLFAGS" != "x$CFLAGS_before_pie"
+then
+       # Restore CFLAGS
+       CFLAGS=$CFLAGS_before_pie
+
+       LDFLAGS_before_pie=$LDFLAGS
+       AC_WIRESHARK_LDFLAGS_CHECK([-fPIE -pie])
+       if test "x$LDFLAGS" != "x$LDFLAGS_before_pie"
+       then
+               # We can use PIE
+               PIE_CFLAGS="-fPIE"
+               PIE_LDFLAGS="-pie"
+
+               # Restore LDFLAGS
+               LDFLAGS=$LDFLAGS_before_pie
+       fi
+
+fi
+AC_SUBST(PIE_CFLAGS)
+AC_SUBST(PIE_LDFLAGS)
+
+#
+# XXX - OK for C++?
+#
+# Make sure -Wshadow doesn't complain about variables in function and
+# function pointer declarations shadowing other variables; if not, don't
+# turn it on, as some versions of GCC (including the one in at least
+# some Xcode versions that came with Mac OS X 10.5) complain about
+# that.
+#
+AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wshadow, C,
+  [
+extern int bar(int a);
+extern int foo(int);
+
+int
+foo(int a)
+{
+       int (*fptr)(int a) = bar;
+
+       return fptr(a) * 2;
+}
+  ],
+  [warns about variables in function declarations shadowing other variables])
 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-error=unused-but-set-variable)    ##  for now
 #
 # Use the faster pre gcc 4.5 floating point precision if available;
@@ -429,18 +493,17 @@ AC_WIRESHARK_LDFLAGS_CHECK([-Wl,--as-needed])
 # AC_WIRESHARK_LDFLAGS_CHECK([-fwhole-program])
 
 #
-# If we're running GCC or clang, add '-D_U_="__attribute__((unused))"' to
-# CPPFLAGS as well, so we can use _U_ to flag unused function arguments and
-# not get warnings about them. Otherwise, add '-D_U_=""', so that _U_ used
-# to flag an unused function argument will compile with non-GCC, non-clang
-# compilers.
+# If we're running GCC or clang define _U_ to be "__attribute__((unused))"
+# so we can use _U_ to flag unused function parameters and not get warnings
+# about them. Otherwise, define _U_ to be an empty string so that _U_ used
+# to flag an unused function parameters will compile with other compilers.
 #
-# XXX - other compilers?
+# XXX - similar hints for other compilers?
 #
 if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
-  CPPFLAGS="-D_U_=\"__attribute__((unused))\" $CPPFLAGS"
+  AC_DEFINE(_U_, __attribute__((unused)), [Hint to the compiler that a function parameters is not used])
 else
-  CPPFLAGS="-D_U_=\"\" $CPPFLAGS"
+  AC_DEFINE(_U_, , [Hint to the compiler that a function parameters is not used])
 fi
 
 # If we're running GCC or CLang, use FORTIFY_SOURCE=2
@@ -499,28 +562,6 @@ if test "x$GCC" = "xyes" ; then
                CXXFLAGS="$CXXFLAGS -Wno-return-type"
                AC_MSG_RESULT(GCC on Solaris - added -Wno-return-type -DFUNCPROTO=15)
                ;;
-       darwin*)
-               #
-               # See comments above about Apple's lovely C compiler.
-               #
-               # NOTE: to AC_PROG_CC, "GCC" means "any compiler that
-               # defines __GNUC__"; clang defines __GNUC__, so that
-               # means we think clang is GCC.
-               #
-               # clang whines about -no-cpp-precomp being unused
-               # so we check whether this is really clang, and
-               # only add -no-cpp-precomp if it's not.
-               #
-               if test "x$CC" != "xclang" ; then
-                       CFLAGS="-no-cpp-precomp $CFLAGS"
-                       AC_MSG_RESULT(Apple GCC - added -no-cpp-precomp)
-               else
-                       #
-                       # Clang, clang, clang went the trolley....
-                       #
-                       AC_MSG_RESULT(none needed)
-               fi
-               ;;
        *)
                AC_MSG_RESULT(none needed)
                ;;
@@ -544,32 +585,6 @@ else
                CXXFLAGS="+O2 $CFLAGS"
                AC_MSG_RESULT(HP ANSI C compiler - added -Ae +O2)
                ;;
-       darwin*)
-               #
-               # It may be called "cc", but it's really a GCC derivative
-               # with a problematic special precompiler and precompiled
-               # headers; turn off the special precompiler, as some
-               # apparently-legal code won't compile with its precompiled
-               # headers.
-               #
-               # On the other hand, if it's called "clang", it's not a
-               # GCC derivative, and it whines if you pass it
-               # -no-cpp-precomp.
-               #
-               # XXX - is there any version of autoconf we support
-               # where it uses another way to decide if the compiler
-               # is GCC or not?
-               #
-               if test "x$CC" != "xclang" ; then
-                       CFLAGS="-no-cpp-precomp $CFLAGS"
-                       AC_MSG_RESULT(Apple CC - added -no-cpp-precomp)
-               else
-                       #
-                       # Clang, clang, clang went the trolley....
-                       #
-                       AC_MSG_RESULT(none needed)
-               fi
-               ;;
        *)
                AC_MSG_RESULT(none needed)
                ;;
@@ -619,57 +634,44 @@ AC_SUBST(LDFLAGS_SHAREDLIB)
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
 
 #
-# On OS X, if we find the headers for Core Foundation, Launch Services,
-# and Core Services, add -framework options to link with Application
-# Services (of which Launch Services is a subframework), Core Foundation
-# (required by the Launch Services APIs), and Core Services, so we can
-# use them to launch a Web browser from the Help menu and to use
-# Gestalt() to get the Mac OS X version number.
+# On "Darwin", which we assume to mean "OS X" rather than "iOS" or
+# "just Darwin" (as we don't currently support iOS, and as I don't
+# think you can build and run "just Darwin" as an OS for PCs), we
+# arrange to build some programs with Application Services so they
+# can launch Web browsers and Finder windows, arrange to build some
+# programs with System Configuration so they can get "friendly names"
+# and other information about interfaces, and build any programs that
+# use either of those frameworks or that report version information
+# with Core Foundation as the frameworks in question use it and as we
+# get version information from plists and thus need Core Foundation
+# to process those plists.
 #
 case "$host_os" in
 
 darwin*)
-       AC_MSG_CHECKING([whether we can build with Core Foundation, Launch Services, and Core Services])
+       AC_DEFINE(HAVE_OS_X_FRAMEWORKS, 1, [Define to 1 if you have OS X frameworks])
+       APPLICATIONSERVICES_FRAMEWORKS="-framework ApplicationServices"
+       SYSTEMCONFIGURATION_FRAMEWORKS="-framework SystemConfiguration"
+       COREFOUNDATION_FRAMEWORKS="-framework CoreFoundation"
+
+       #
+       # OK, so we have the OS X frameworks; do they include
+       # CFPropertyListCreateWithStream, or do we have
+       # to fall back on CFPropertyListCreateFromStream?
+       # (They only differ in the error return, which we
+       # don't care about.  And, no, we shouldn't just
+       # use CFPropertyListCreateFromStream, because it's
+       # deprecated in newer releases.)
+       #
        ac_save_LIBS="$LIBS"
-       ac_coreservices_frameworks="-framework CoreServices"
-       ac_launchservices_frameworks="-framework ApplicationServices -framework CoreFoundation $ac_coreservices_frameworks"
-       LIBS="$LIBS $ac_launchservices_frameworks $ac_coreservices_frameworks"
-       AC_TRY_LINK(
-          [
-#       include <CoreFoundation/CFBase.h>
-#       include <CoreFoundation/CFString.h>
-#       include <CoreFoundation/CFURL.h>
-#       include <ApplicationServices/ApplicationServices.h>
-#      include <CoreServices/CoreServices.h>
-          ],
-          [
-       CFStringRef url_CFString;
-       CFURLRef url_CFURL;
-       OSStatus status;
-       long os_version;
-
-       url_CFString = CFStringCreateWithCString(NULL, "", kCFStringEncodingASCII);
-       url_CFURL = CFURLCreateWithString(NULL, url_CFString, NULL);
-       status = LSOpenCFURLRef(url_CFURL, NULL);
-
-       Gestalt(gestaltSystemVersion, &os_version);
-          ],
-          ac_cv_can_use_osx_frameworks=yes,
-          ac_cv_can_use_osx_frameworks=no,
-          [echo $ac_n "cross compiling; assumed OK... $ac_c"])
-       if test "$ac_cv_can_use_osx_frameworks" = yes ; then
-               AC_DEFINE(HAVE_OS_X_FRAMEWORKS, 1, [Define to 1 if you have OS X frameworks])
-               CORESERVICES_FRAMEWORKS="$ac_coreservices_frameworks"
-               LAUNCHSERVICES_FRAMEWORKS="$ac_launchservices_frameworks"
-               AC_MSG_RESULT(yes)
-       else
-               AC_MSG_RESULT(no)
-       fi
+       LIBS="$LIBS $COREFOUNDATION_FRAMEWORKS"
+       AC_CHECK_FUNCS(CFPropertyListCreateWithStream)
        LIBS="$ac_save_LIBS"
        ;;
 esac
-AC_SUBST(CORESERVICES_FRAMEWORKS)
-AC_SUBST(LAUNCHSERVICES_FRAMEWORKS)
+AC_SUBST(APPLICATIONSERVICES_FRAMEWORKS)
+AC_SUBST(SYSTEMCONFIGURATION_FRAMEWORKS)
+AC_SUBST(COREFOUNDATION_FRAMEWORKS)
 
 #
 # If using $prefix we add "$prefix/include" to the include search path
@@ -856,6 +858,7 @@ AC_DEFINE_UNQUOTED(DOC_DIR, "$docdir", [Directory for docs])
 # 3.0.0:  10 Feb 2011
 # 3.2.0:  25 Sep 2011
 # 3.4.0:  26 Mar 2012
+# 3.6.0:  24 Sep 2012
 
 if test "x$enable_wireshark" = "xyes"; then
        if test "x$with_qt" = "xyes"; then
@@ -874,6 +877,31 @@ if test "x$enable_wireshark" = "xyes"; then
                        AC_MSG_ERROR([Qt is not available])
                ])
 
+               #
+               # Qt 5.0 appears to move the widgets out of Qt GUI
+               # to Qt Widgets; look for QtWidgets and, if we find
+               # it, add its flags to CFLAGS and CXXFLAGS, so that
+               # we find the include files for the widgets.  (If
+               # we don't find it, we assume it's Qt 4.)
+               #
+               PKG_CHECK_MODULES([QtWidgets], [QtWidgets],
+               [
+                       CFLAGS="$CFLAGS $QtWidgets_CFLAGS"
+                       CXXFLAGS="$CXXFLAGS $QtWidgets_CFLAGS"
+               ],
+               [])
+
+               #
+               # It also appears to move the printing support into
+               # the QtPrintSupport module.
+               #
+               PKG_CHECK_MODULES([QtPrintSupport], [QtPrintSupport],
+               [
+                       CFLAGS="$CFLAGS $QtPrintSupport_CFLAGS"
+                       CXXFLAGS="$CXXFLAGS $QtPrintSupport_CFLAGS"
+               ],
+               [])
+
                #
                # We don't know whether we have GTK+, but we
                # won't be using it, so it's as if we don't
@@ -934,6 +962,7 @@ fi
 # 2.28.0: 08 Feb 2011
 # 2.30.0: 27 Sep 2011
 # 2.32.0: 24 Mar 2012
+# 2.34.0: 24 Sep 2012
 
 if test "$have_gtk" = "no" ; then
        #
@@ -1194,6 +1223,24 @@ AC_SUBST(mergecap_bin)
 AC_SUBST(mergecap_man)
 
 
+# Enable/disable reordercap
+
+AC_ARG_ENABLE(reordercap,
+  AC_HELP_STRING( [--enable-reordercap],
+                  [build reordercap @<:@default=yes@:>@]),
+    enable_reordercap=$enableval,enable_reordercap=yes)
+
+if test "x$enable_reordercap" = "xyes" ; then
+       reordercap_bin="reordercap\$(EXEEXT)"
+       reordercap_man="reordercap.1"
+else
+       reordercap_bin=""
+       reordercap_man=""
+fi
+AC_SUBST(reordercap_bin)
+AC_SUBST(reordercap_man)
+
+
 # Enable/disable text2pcap
 
 AC_ARG_ENABLE(text2pcap,
@@ -1981,16 +2028,22 @@ AC_SUBST(PLUGIN_LIBS)
 # I haven't been able to write C code that reliably makes that determination
 # (different versions of GCC with or without optimization give different
 # results) so just assume everything except (32-bit) x86 needs 8-byte
-# alignment (64-bit x86 will get 8-byte alignment from G_MEM_ALIGN anyway).
+# alignment (64-bit platforms either require 8-byte alignment for pointers
+# and 64-bit integral data types or may get better performance from that;
+# 64-bit x86 will get 8-byte alignment from G_MEM_ALIGN anyway.  32-bit
+# platforms would only require it, or get better performance from it,
+# for 64-bit floating-point values.).
 #
 AC_MSG_CHECKING(whether we need memory allocations to be 8-byte aligned)
-if test x$host_cpu != xi386
-then
-  AC_MSG_RESULT(yes)
-  AC_DEFINE(NEED_8_BYTE_ALIGNMENT, 1, [Define if we need memory allocations to be 8-byte aligned])
-else
-  AC_MSG_RESULT(no)
-fi
+case $host_cpu in
+       i386|i486|i586|i686)
+               AC_MSG_RESULT(no)
+               ;;
+       *)
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(NEED_8_BYTE_ALIGNMENT, 1, [Define if we need memory allocations to be 8-byte aligned])
+               ;;
+esac
 
 dnl libtool defs
 #
@@ -2134,6 +2187,7 @@ AC_OUTPUT(
   epan/dissectors/dcerpc/Makefile
   epan/dissectors/pidl/Makefile
   epan/ftypes/Makefile
+  epan/wmem/Makefile
   epan/wslua/Makefile
   epan/wspython/Makefile
   codecs/Makefile
@@ -2289,6 +2343,7 @@ echo "                     Build capinfos : $enable_capinfos"
 echo "                      Build editcap : $enable_editcap"
 echo "                      Build dumpcap : $enable_dumpcap"
 echo "                     Build mergecap : $enable_mergecap"
+echo "                   Build reordercap : $enable_reordercap"
 echo "                    Build text2pcap : $enable_text2pcap"
 echo "                      Build randpkt : $enable_randpkt"
 echo "                       Build dftest : $enable_dftest"