Allow the Gtk+ and Qt versions to be built simultaneously (with autotools).
authorJeff Morriss <jeff.morriss.ws@gmail.com>
Tue, 25 Jun 2013 19:51:53 +0000 (19:51 -0000)
committerJeff Morriss <jeff.morriss.ws@gmail.com>
Tue, 25 Jun 2013 19:51:53 +0000 (19:51 -0000)
./configure now accepts:
--with-gtk2 :  enabled by default; exclusive of --with-gtk3
--with-gtk3 : disabled by default; exclusive of --with-gtk2
--with-qt   : disabled by default, can be specified with gtk
--enable-wireshark : controls whether *any* GUI is built

If Qt is enabled then a new program is created: "wireshark-qt".  "wireshark"
remains the Gtk+ version.

svn path=/trunk/; revision=50147

Makefile.am
Makefile.common
Makefile.nmake
configure.ac

index 9ccc8c3b7d2aaf88612b68716e6bf4e42e3f4009..69349653e3285c8fc9d120f3084328de479321e9 100644 (file)
@@ -35,24 +35,22 @@ AM_CLEAN_CFLAGS = -Werror
 endif
 
 bin_PROGRAMS = \
-       @wireshark_bin@ \
-       @tshark_bin@    \
-       @text2pcap_bin@ \
-       @mergecap_bin@  \
-       @capinfos_bin@  \
-       @editcap_bin@   \
-       @randpkt_bin@   \
-       @dftest_bin@    \
-       @dumpcap_bin@   \
+       @wireshark_bin@         \
+       @tshark_bin@            \
+       @text2pcap_bin@         \
+       @mergecap_bin@          \
+       @capinfos_bin@          \
+       @editcap_bin@           \
+       @randpkt_bin@           \
+       @dftest_bin@            \
+       @dumpcap_bin@           \
        @reordercap_bin@        \
-       @rawshark_bin@ \
+       @rawshark_bin@          \
        @echld_test_bin@ 
 
-
-EXTRA_PROGRAMS = wireshark tshark capinfos editcap mergecap dftest \
-       randpkt text2pcap dumpcap reordercap rawshark wireshark_cxx echld_test
-
-
+EXTRA_PROGRAMS = wireshark wireshark-qt tshark capinfos editcap mergecap \
+       dftest randpkt text2pcap dumpcap reordercap rawshark wireshark_cxx \
+       echld_test
 
 #
 # Wireshark configuration files are put in $(pkgdatadir).
@@ -323,10 +321,20 @@ endif             # HAVE_PLUGINS
 include Makefile.common
 
 if ENABLE_STATIC
+if HAVE_GTK
 wireshark_LDFLAGS = -Wl,-static -all-static
+endif
+if HAVE_Qt
+wireshark_qt_LDFLAGS = -Wl,-static -all-static
+endif
 else
+if HAVE_GTK
 wireshark_LDFLAGS = -export-dynamic
 endif
+if HAVE_Qt
+wireshark_qt_LDFLAGS = -export-dynamic
+endif
+endif
 
 # Libraries and plugin flags with which to link wireshark.
 #
@@ -350,14 +358,7 @@ endif
 # although it's also possible that -lgmodule is in GTK_LIBS but not
 # GLIB_LIBS (that's the case on my machine right now, for example).
 #
-if HAVE_Qt
-wireshark_ui_ldadd = ui/qt/libqtui.a
-else
-wireshark_ui_ldadd = ui/gtk/libgtkui.a
-endif
-
-wireshark_LDADD = \
-       $(wireshark_ui_ldadd)           \
+wireshark_ldadd = \
        ui/libui.a                      \
        ui/libui_dirty.a                \
        codecs/libcodec.a               \
@@ -383,7 +384,21 @@ wireshark_LDADD = \
        @GLIB_LIBS@                     \
        -lm
 
+if HAVE_Qt
+wireshark_qt_SOURCES = $(WIRESHARK_COMMON_SRC)
+wireshark_qt_INCLUDES = $(WIRESHARK_COMMON_INCLUDES)
+wireshark_qt_CFLAGS = $(AM_CLEAN_CFLAGS) $(py_dissectors_dir)
+wireshark_qt_LDADD =  ui/qt/libqtui.a $(wireshark_ldadd)
+wireshark_qt_LINK = $(CXXLINK)
+endif
+
+if HAVE_GTK
+wireshark_SOURCES = $(WIRESHARK_COMMON_SRC)
+wireshark_INCLUDES = $(WIRESHARK_COMMON_INCLUDES)
 wireshark_CFLAGS = $(AM_CLEAN_CFLAGS) $(py_dissectors_dir)
+wireshark_LDADD = ui/gtk/libgtkui.a $(wireshark_ldadd)
+wireshark_LINK = $(LINK)
+endif
 
 # Ideally we could trigger automatic c++ linking here with
 #   nodist_EXTRA_wireshark_SOURCES = dummy.cpp
@@ -393,12 +408,6 @@ wireshark_CFLAGS = $(AM_CLEAN_CFLAGS) $(py_dissectors_dir)
 nodist_EXTRA_wireshark_cxx_SOURCES = dummy.cpp
 wireshark_cxx_SOURCES =
 
-if HAVE_WIRESHARK_CXX
-wireshark_LINK = $(CXXLINK)
-else
-wireshark_LINK = $(LINK)
-endif
-
 if ENABLE_STATIC
 tshark_LDFLAGS = -Wl,-static -all-static
 else
@@ -1196,3 +1205,4 @@ if HAVE_DOXYGEN
        rm -f wsar_html.zip
        zip -rq wsar_html.zip wsar_html
 endif
+
index a22b3c7c2e13c56ebe170d90e6ad524368c61052..635e8c4ff05e638458835820661e384f00fe1e4c 100644 (file)
@@ -44,7 +44,7 @@ GENERATED_C_FILES = \
 GENERATED_FILES = $(GENERATED_C_FILES) $(GENERATED_HEADER_FILES)
 
 # sources common for wireshark, tshark, and rawshark
-WIRESHARK_COMMON_SRC = \
+SHARK_COMMON_SRC =     \
        $(PLATFORM_SRC)         \
        capture-pcap-util.c     \
        cfile.c                 \
@@ -62,7 +62,7 @@ WIRESHARK_COMMON_SRC =        \
        version_info.c
 
 # corresponding headers
-WIRESHARK_COMMON_INCLUDES =    \
+SHARK_COMMON_INCLUDES =        \
        svnversion.h            \
        capture-pcap-util.h     \
        capture-pcap-util-int.h \
@@ -102,8 +102,8 @@ SHARK_COMMON_CAPTURE_INCLUDES =     \
        capture_ui_utils.h
 
 # wireshark specifics
-wireshark_SOURCES =    \
-       $(WIRESHARK_COMMON_SRC) \
+WIRESHARK_COMMON_SRC = \
+       $(SHARK_COMMON_SRC)     \
        $(SHARK_COMMON_CAPTURE_SRC) \
        airpcap_loader.c \
        capture.c       \
@@ -123,7 +123,7 @@ wireshark_SOURCES = \
        ws80211_utils.c
 
 # corresponding headers
-wireshark_INCLUDES =   \
+WIRESHARK_COMMON_INCLUDES =    \
        airpcap.h       \
        airpcap_loader.h \
        capture.h       \
@@ -145,7 +145,7 @@ wireshark_INCLUDES =        \
 
 # tshark specifics
 tshark_SOURCES =       \
-       $(WIRESHARK_COMMON_SRC) \
+       $(SHARK_COMMON_SRC)     \
        $(SHARK_COMMON_CAPTURE_SRC) \
        capture_opts.c          \
        tempfile.c              \
@@ -153,7 +153,7 @@ tshark_SOURCES =    \
 
 # rawshark specifics
 rawshark_SOURCES =     \
-       $(WIRESHARK_COMMON_SRC) \
+       $(SHARK_COMMON_SRC)     \
        rawshark.c
 
 # text2pcap specifics
@@ -223,7 +223,7 @@ dumpcap_INCLUDES = \
 
 # this target needed for distribution only
 noinst_HEADERS =       \
-       $(WIRESHARK_COMMON_INCLUDES) \
+       $(SHARK_COMMON_INCLUDES) \
        $(SHARK_COMMON_CAPTURE_INCLUDES) \
-       $(wireshark_INCLUDES) \
+       $(WIRESHARK_COMMON_INCLUDES) \
        $(dumpcap_INCLUDES)
index 61989c1d9c9caf67fb8af2e42ff49db024e622a2..0aac1709e9a66365e2aa776e6b6f44decac08686 100644 (file)
@@ -60,7 +60,7 @@ WTAP_PLUGIN_SOURCES = \
 
 include Makefile.common
 
-wireshark_OBJECTS = $(wireshark_SOURCES:.c=.obj)
+wireshark_OBJECTS = $(WIRESHARK_COMMON_SRC:.c=.obj)
 tshark_OBJECTS = $(tshark_SOURCES:.c=.obj)
 rawshark_OBJECTS = $(rawshark_SOURCES:.c=.obj)
 ###text2pcap_OBJECTS = $(text2pcap_SOURCES:.c=.obj)
@@ -1287,7 +1287,7 @@ install-all: install-generated-files
 
 checkapi_local:
        $(PERL) tools/checkAPIs.pl -build \
-       $(wireshark_SOURCES) \
+       $(WIRESHARK_COMMON_SRC) \
        $(TSHARK_TAP_SRC) \
 #      $(EXTRA_wireshark_SOURCES)
 
index 942db32fe848449f1f07ddccf8305c96e0b50d62..d58e7c68de1f9fc094dd03b3c4f40b97b589da77 100644 (file)
@@ -282,11 +282,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,6 +401,16 @@ linux*)
        fi
 esac
 
+AC_ARG_WITH([qt],
+  AC_HELP_STRING( [--with-qt=@<:@yes/no@:>@],
+                  [use Qt @<:@default=no@:>@]),
+  with_qt="$withval", with_qt="no")
+
+AC_ARG_WITH([gtk2],
+  AC_HELP_STRING( [--with-gtk2=@<:@yes/no@:>@],
+                  [use GTK+ 2.0 @<:@default=yes@:>@]),
+  with_gtk2="$withval", with_gtk2="no")
+
 AC_ARG_WITH([gtk3],
   AC_HELP_STRING( [--with-gtk3=@<:@yes/no@:>@],
                   [use GTK+ 3.0 instead of 2.0 @<:@default=no@:>@]),
@@ -954,10 +959,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,6 +1044,8 @@ 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_qt" = "xyes"; then
 
@@ -1066,41 +1072,33 @@ if test "x$enable_wireshark" = "xyes"; then
                # compile.
                #
                CPPFLAGS="-DQT_GUI_LIB"
+       fi
 
-               #
-               # 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.
-               #
-               have_gtk=no
-       else
-               #
-               # Not Qt - either GTK+ 3.x or 2.x.
-               #
-               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)
+       if test "x$with_gtk3" = "xyes" -a "x$with_gtk2" = "xyes" ; then
+               AC_MSG_ERROR(--with-gtk2 and --with-gtk3 are mutually exclusive)
+       fi
 
-               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
+       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)
+       fi
+
+       if test "x$with_gtk2" = "xyes"; then
+               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
-else
-       have_qt=no
-       have_gtk=no
 fi
 
 GLIB_MIN_VERSION=2.16.0
@@ -1132,61 +1130,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 +1188,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.
 #
@@ -1410,7 +1412,8 @@ 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")
+# XXX - is it bad form for HAVE_GTK to be both a define and a conditional?
+AM_CONDITIONAL(HAVE_GTK, test "$have_gtk" = "yes")
 
 
 # Enable/disable tshark
@@ -2532,21 +2535,23 @@ 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
@@ -2633,7 +2638,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"