Simplify the test in a loop.
[obnox/wireshark/wip.git] / acinclude.m4
index 7c91260d54ca076cfb59ce4dc056260df57f6ce1..2ef985fe73969eccd4fe40076dda460ac198aa42 100644 (file)
@@ -329,13 +329,15 @@ AC_DEFUN([AC_WIRESHARK_PCAP_CHECK],
          #
          AC_PATH_PROG(PCAP_CONFIG, pcap-config)
 
-         #
-         # Now check whether it's the libpcap 1.0 version, which
-         # put a space after "-L" - on some platforms, that doesn't
-         # work.
-         #
-         AC_MSG_CHECKING(for broken pcap-config)
          if test -n "$PCAP_CONFIG" ; then
+           #
+           # Found it.
+           #
+           # Now check whether it's the libpcap 1.0 version, which
+           # put a space after "-L" - on some platforms, that doesn't
+           # work.
+           #
+           AC_MSG_CHECKING(for broken pcap-config)
            case "`\"$PCAP_CONFIG\" --libs`" in
 
            "-L "*)
@@ -356,8 +358,8 @@ AC_DEFUN([AC_WIRESHARK_PCAP_CHECK],
          fi
          if test -n "$PCAP_CONFIG" ; then
            #
-           # Found - use it to get the include flags for
-           # libpcap.
+           # Found it, and it's usable; use it to get the include flags
+           # for libpcap.
            #
            CFLAGS="$CFLAGS `\"$PCAP_CONFIG\" --cflags`"
            CPPFLAGS="$CPPFLAGS `\"$PCAP_CONFIG\" --cflags`"
@@ -612,6 +614,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)
        fi
        LIBS="$ac_save_LIBS"
 ])
@@ -1414,8 +1417,10 @@ AC_DEFUN([AC_WIRESHARK_KRB5_CHECK],
          CFLAGS="$CFLAGS -I$krb5_dir/include"
          CPPFLAGS="$CPPFLAGS -I$krb5_dir/include"
          ac_heimdal_version=`grep heimdal $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*heimdal.*$/HEIMDAL/'`
-         ac_mit_version=`grep 'Massachusetts Institute of Technology' $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*Massachusetts Institute of Technology.*$/MIT/'`
-         ac_krb5_version="$ac_heimdal_version$ac_mit_version"
+         # 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_krb5_version="$ac_heimdal_version$ac_mit_version_olddir$ac_mit_version_newdir"
          if test "x$ac_krb5_version" = "xHEIMDAL"
              KRB5_LIBS="-L$krb5_dir/lib -lkrb5 -lasn1 $SSL_LIBS -lroken -lcrypt"
          then
@@ -1676,18 +1681,19 @@ AC_DEFUN([AC_WIRESHARK_GEOIP_CHECK],
        fi
 ])
 
-#AC_WIRESHARK_GCC_LDFLAGS_CHECK
+#AC_WIRESHARK_LDFLAGS_CHECK
 #
 # $1 : ldflag(s) to test
 #
-# The macro first determines if the compiler is GCC. Then compile with the
-# defined ldflags. The defined flags are added to LDFLAGS only if the
-# compilation succeeds.
+# 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.
 #
-AC_DEFUN([AC_WIRESHARK_GCC_LDFLAGS_CHECK],
+AC_DEFUN([AC_WIRESHARK_LDFLAGS_CHECK],
 [GCC_OPTION="$1"
 AC_MSG_CHECKING(whether we can add $GCC_OPTION to LDFLAGS)
-if test "x$GCC" != "x"; then
+if test "x$ac_supports_W_linker_passthrough" = "xyes"; then
   LDFLAGS_saved="$CFLAGS"
   LDFLAGS="$LDFLAGS $GCC_OPTION"
   AC_LINK_IFELSE([
@@ -1711,16 +1717,28 @@ fi
 #
 # $1 : cflags to test
 #
-# The macro first determines if the compiler is GCC. Then compile with the
-# defined cflags. The defined flags are added to CFLAGS only if the compilation
-# succeeds.
+# The macro first determines if the compiler supports GCC-style flags.
+# Then it attempts to compile with the defined cflags.  The defined
+# flags are added to CFLAGS only if the compilation succeeds.
+#
+# We do this because not all such options are necessarily supported by
+# the version of the particular compiler we're using.
+#
+# NOTE: clang, by default, only warns about unknown -W options.
+# If we're using clang, we turn on -Werror=unknown-warning-option
+# so that it fails if we pass it a -W option it doesn't know about
+# but doesn't fail for any other warning that the test program might
+# produce.
 #
 AC_DEFUN([AC_WIRESHARK_GCC_CFLAGS_CHECK],
 [GCC_OPTION="$1"
 AC_MSG_CHECKING(whether we can add $GCC_OPTION to CFLAGS)
-if test "x$GCC" != "x"; then
+if test "x$ac_supports_gcc_flags" = "xyes" ; then
   CFLAGS_saved="$CFLAGS"
   CFLAGS="$CFLAGS $GCC_OPTION"
+  if test "x$CC" = "xclang" ; then
+    CFLAGS="$CFLAGS -Werror=unknown-warning-option"
+  fi
   AC_COMPILE_IFELSE([
     AC_LANG_SOURCE([[
                       int foo;
@@ -1738,35 +1756,68 @@ fi
 ])
 
 #
-# AC_WIRESHARK_IGE_MAC_INTEGRATION_CHECK
+# AC_WIRESHARK_OSX_INTEGRATION_CHECK
 #
 # Checks for the presence of OS X integration functions in the GTK+ framework
 # or as a separate library.
 #
-# http://developer.imendio.com/projects/gtk-macosx/integration
+# http://sourceforge.net/apps/trac/gtk-osx/wiki/Integrate
+#
+# http://live.gnome.org/GTK%2B/OSX/Integration
+#    for the old Carbon-based integration functions
+#
+# http://gtk-osx.sourceforge.net/ige-mac-integration/
+#    for the new Cocoa-based integration functions
 #
-AC_DEFUN([AC_WIRESHARK_IGE_MAC_INTEGRATION_CHECK],
+AC_DEFUN([AC_WIRESHARK_OSX_INTEGRATION_CHECK],
 [
        ac_save_CFLAGS="$CFLAGS"
        ac_save_LIBS="$LIBS"
        CFLAGS="$CFLAGS $GTK_CFLAGS"
        LIBS="$GTK_LIBS $LIBS"
-       AC_CHECK_LIB(Gtk, ige_mac_menu_set_menu_bar,
+
+       #
+       # Check for the new integration functions in a -ligemacintegration
+       # library.
+       #
+       AC_CHECK_LIB(igemacintegration, gtk_osxapplication_set_menu_bar,
        [
-               AC_DEFINE(HAVE_IGE_MAC_INTEGRATION, 1,
-                       [Define to 1 if the the Gtk+ framework or a separate library inclues the Imendio IGE Mac OS X Integration functions.])
+               AC_DEFINE(HAVE_GTKOSXAPPLICATION, 1,
+                       [Define to 1 if -ligemacintegration includes the GtkOSXApplication Integration functions.])
                have_ige_mac=yes
                # We don't want gtk stuff in LIBS (which is reset below) so
                # manually set GTK_LIBS (which is more appropriate)
-               GTK_LIBS="$GTK_LIBS -lGtk"
+               GTK_LIBS="$GTK_LIBS -ligemacintegration"
        ])
 
-       if test x$have_ige_mac == x
+       if test x$have_ige_mac = x
        then
+               #
+               # Not found - check for the old integration functions in
+               # the Gtk framework.
+               #
+               AC_CHECK_LIB(Gtk, ige_mac_menu_set_menu_bar,
+               [
+                       AC_DEFINE(HAVE_IGE_MAC_INTEGRATION, 1,
+                               [Define to 1 if the the Gtk+ framework or a separate library includes the Imendio IGE Mac OS X Integration functions.])
+                       have_ige_mac=yes
+                       # We don't want gtk stuff in LIBS (which is reset below) so
+                       # manually set GTK_LIBS (which is more appropriate)
+                       GTK_LIBS="$GTK_LIBS -lGtk"
+               ])
+       fi
+
+       if test x$have_ige_mac = x
+       then
+               #
+               # Not found - check for the old integration functions in
+               # a -ligemacintegration library.
+               #
                AC_CHECK_LIB(igemacintegration, ige_mac_menu_set_menu_bar,
                [
                        AC_DEFINE(HAVE_IGE_MAC_INTEGRATION, 1,
-                               [Define to 1 if the the Gtk+ framework or a separate library inclues the Imendio IGE Mac OS X Integration functions.])
+                               [Define to 1 if the the Gtk+ framework or a separate library includes the Imendio IGE Mac OS X Integration functions.])
+                       have_ige_mac=yes
                        # We don't want gtk stuff in LIBS (which is reset below) so
                        # manually set GTK_LIBS (which is more appropriate)
                        GTK_LIBS="$GTK_LIBS -ligemacintegration"