# http://nplab.fh-muenster.de/groups/wiki/wiki/fb7a4/Building_Wireshark_on_SnowLeopard.html
#
+# To set up a GTK3 environment
+# GTK3=1
+# To build cmake
+# CMAKE=1
#
# Versions to download and install.
#
-# These are required.
+# The following libraries are required.
#
GETTEXT_VERSION=0.18.1.1
-GLIB_VERSION=2.29.8
+GLIB_VERSION=2.31.8
#
# pkg-config 0.26 appears to have broken the "we have our own GLib"
# stuff, even if you explicitly set GLIB_CFLAGS and GLIB_LIBS.
# so we use 0.25 instead.
#
PKG_CONFIG_VERSION=0.26
-ATK_VERSION=2.0.1
-PANGO_VERSION=1.29.3
-GDK_PIXBUF_VERSION=2.23.4
-GTK_VERSION=2.24.5
+ATK_VERSION=2.2.0
+PANGO_VERSION=1.29.5
+PNG_VERSION=1.5.7
+PIXMAN_VERSION=0.24.0
+CAIRO_VERSION=1.10.2
+GDK_PIXBUF_VERSION=2.25.0
+if [ -z "$GTK3" ]; then
+ GTK_VERSION=2.24.8
+else
+ GTK_VERSION=3.2.3
+fi
+
+#
+# Some package need xz to unpack their current source.
+# xz is not available on OSX (Snow Leopard).
+#
+XZ_VERSION=5.0.3
+
+# In case we want to build with cmake
+CMAKE_VERSION=2.8.7
#
-# These are optional. Comment them out if you don't want them.
+# The following libraries are optional.
+# Comment them out if you don't want them, but note that some of
+# the optional libraries are required by other optional libraries.
#
LIBSMI_VERSION=0.4.8
-GEOIP_VERSION=1.4.5
#
# libgpg-error is required for libgcrypt.
#
LIBGCRYPT_VERSION=1.4.6
GNUTLS_VERSION=2.12.7
LUA_VERSION=5.1.4
-PORTAUDIO_VERSION=pa_stable_v19_20110326
+PORTAUDIO_VERSION=pa_stable_v19_20111121
#
# XXX - they appear to have an unversioned gzipped tarball for the
# current version; should we just download that, with some other
# You need Xcode installed to get the compilers.
#
if [ ! -x /usr/bin/xcodebuild ]; then
- echo "Please install Xcode first (should be available on DVD)."
+ echo "Please install Xcode first (should be available on DVD or from http://developer.apple.com/xcode/index.php)."
+ exit 1
+fi
+
+#
+# You also need the X11 SDK; with at least some versions of OS X and
+# Xcode, that is, I think, an optional install. (Or it might be
+# installed with X11, but I think *that* is an optional install on
+# at least some versions of OS X.)
+#
+if [ ! -d /usr/X11/include ]; then
+ echo "Please install X11 and the X11 SDK first."
exit 1
fi
fi
cd macosx-support-libs
+# Start with xz: It is the sole download format of glib later than 2.31.2
+#
+echo "Downloading, building, and installing xz:"
+curl -O http://tukaani.org/xz/xz-$XZ_VERSION.tar.bz2 || exit 1
+tar xf xz-$XZ_VERSION.tar.bz2 || exit 1
+cd xz-$XZ_VERSION
+CFLAGS="-D_FORTIFY_SOURCE=0" ./configure || exit 1
+make -j 3 || exit 1
+$DO_MAKE_INSTALL || exit 1
+cd ..
+
+if [ -n "$CMAKE" ]; then
+ echo "Downloading, building, and installing CMAKE:"
+ cmake_dir=`expr $CMAKE_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
+ curl -O http://www.cmake.org/files/v$cmake_dir/cmake-$CMAKE_VERSION.tar.gz || exit 1
+ gzcat cmake-$CMAKE_VERSION.tar.gz | tar xf - || exit 1
+ cd cmake-$CMAKE_VERSION
+ ./bootstrap || exit 1
+ make -j 3 || exit 1
+ $DO_MAKE_INSTALL || exit 1
+ cd ..
+fi
+
#
# Start with GNU gettext; GLib requires it, and OS X doesn't have it
# or a BSD-licensed replacement.
#
+# At least on Lion with Xcode 4, _FORTIFY_SOURCE gets defined as 2
+# by default, which causes, for example, stpncpy to be defined as
+# a hairy macro that collides with the GNU gettext configure script's
+# attempts to workaround AIX's lack of a declaration for stpncpy,
+# with the result being a huge train wreck. Define _FORTIFY_SOURCE
+# as 0 in an attempt to keep the trains on separate tracks.
+#
echo "Downloading, building, and installing GNU gettext:"
curl -O http://ftp.gnu.org/pub/gnu/gettext/gettext-$GETTEXT_VERSION.tar.gz || exit 1
tar xf gettext-$GETTEXT_VERSION.tar.gz || exit 1
cd gettext-$GETTEXT_VERSION
-./configure || exit 1
+CFLAGS="-D_FORTIFY_SOURCE=0" ./configure || exit 1
make -j 3 || exit 1
$DO_MAKE_INSTALL || exit 1
cd ..
echo "Downloading, building, and installing GLib:"
glib_dir=`expr $GLIB_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
-curl -L -O http://ftp.gnome.org/pub/gnome/sources/glib/$glib_dir/glib-$GLIB_VERSION.tar.bz2 || exit 1
-bzcat glib-$GLIB_VERSION.tar.bz2 | tar xf - || exit 1
+curl -L -O http://ftp.gnome.org/pub/gnome/sources/glib/$glib_dir/glib-$GLIB_VERSION.tar.xz || exit 1
+xzcat glib-$GLIB_VERSION.tar.xz | tar xf - || exit 1
cd glib-$GLIB_VERSION
#
# OS X ships with libffi, but doesn't provide its pkg-config file;
# the GUI (Wireshark).
#
-#
-# Cairo is part of Mac OS X 10.6 (and, I think, 10.5).
-# However, it's an X11 library; if we build with "native" GTK+ rather
-# than X11 GTK+, we might have to build and install Cairo.
-#
-# echo "Downloading, building, and installing Cairo:"
-# curl -O http://cairographics.org/releases/cairo-1.10.2.tar.gz || exit 1
-# tar xvfz cairo-1.10.2.tar.gz || exit 1
-# cd cairo-1.10.2
-# ./configure --enable-quartz=no || exit 1
-# make -j 3 || exit 1
-# $DO_MAKE_INSTALL || exit 1
-# cd ..
+if [ -n "$GTK3" ]; then
+ #
+ # Cairo is part of Mac OS X 10.6 (and, I think, 10.5).
+ # However, it's an X11 library; if we build with "native" GTK+ rather
+ # than X11 GTK+, we might have to build and install Cairo.
+ # GTK+-3 requires a newer cairo build as well.
+ #
+ # Requirements for cairo first
+ #
+ echo "Downloading, building, and installing libpng:"
+ curl -O ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-$PNG_VERSION.tar.xz
+ xzcat libpng-$PNG_VERSION.tar.xz | tar xf - || exit 1
+ cd libpng-$PNG_VERSION
+ ./configure || exit 1
+ make -j 3 || exit 1
+ $DO_MAKE_INSTALL || exit 1
+ cd ..
+
+ echo "Downloading, building, and installing pixman:"
+ curl -O http://www.cairographics.org/releases/pixman-$PIXMAN_VERSION.tar.gz
+ gzcat pixman-$PIXMAN_VERSION.tar.gz | tar xf - || exit 1
+ cd pixman-$PIXMAN_VERSION
+ ./configure || exit 1
+ make -j 3 || exit 1
+ $DO_MAKE_INSTALL || exit 1
+ cd ..
+
+ #
+ # And now cairo itself.
+ #
+ echo "Downloading, building, and installing Cairo:"
+ curl -O http://cairographics.org/releases/cairo-$CAIRO_VERSION.tar.gz || exit 1
+ tar xvfz cairo-$CAIRO_VERSION.tar.gz || exit 1
+ cd cairo-$CAIRO_VERSION
+ #./configure --enable-quartz=no || exit 1
+ # Maybe follow http://cairographics.org/end_to_end_build_for_mac_os_x/
+ ./configure --enable-quartz=yes || exit 1
+ make -j 3 || exit 1
+ $DO_MAKE_INSTALL || exit 1
+ cd ..
+fi
echo "Downloading, building, and installing ATK:"
atk_dir=`expr $ATK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
echo "Downloading, building, and installing gdk-pixbuf:"
gdk_pixbuf_dir=`expr $GDK_PIXBUF_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
-curl -L -O http://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/$gdk_pixbuf_dir/gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.bz2 || exit 1
-bzcat gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.bz2 | tar xf - || exit 1
+curl -L -O http://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/$gdk_pixbuf_dir/gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.xz || exit 1
+xzcat gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.xz | tar xf - || exit 1
cd gdk-pixbuf-$GDK_PIXBUF_VERSION
./configure --without-libtiff --without-libjpeg || exit 1
make -j 3 || exit 1
echo "Downloading, building, and installing GTK+:"
gtk_dir=`expr $GTK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
-curl -L -O http://ftp.gnome.org/pub/gnome/sources/gtk+/$gtk_dir/gtk+-$GTK_VERSION.tar.bz2
-bzcat gtk+-$GTK_VERSION.tar.bz2 | tar xf - || exit 1
+curl -L -O http://ftp.gnome.org/pub/gnome/sources/gtk+/$gtk_dir/gtk+-$GTK_VERSION.tar.xz
+xzcat gtk+-$GTK_VERSION.tar.xz | tar xf - || exit 1
cd gtk+-$GTK_VERSION
./configure || exit 1
make -j 3 || exit 1
#
./configure --with-libgcrypt || exit 1
make -j 3 || exit 1
+ #
+ # The pkgconfig file for GnuTLS says "requires zlib", but OS X,
+ # while it supplies zlib, doesn't supply a pkgconfig file for
+ # it.
+ #
+ # Patch the GnuTLS pkgconfig file not to require zlib.
+ # (If the capabilities of GnuTLS that Wireshark uses don't
+ # depend on building GnuTLS with zlib, an alternative would be
+ # to configure it not to use zlib.)
+ #
+ patch -p0 lib/gnutls.pc <../../macosx-support-lib-patches/gnutls-pkgconfig.patch || exit 1
$DO_MAKE_INSTALL || exit 1
cd ..
fi
echo ""
echo "You are now prepared to build Wireshark. To do so do:"
-echo "Download Wireshark source"
+echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig"
+echo ""
+if [ -n "$CMAKE" ]; then
+ echo "mkdir build; cd build"
+ echo "cmake .."
+ echo
+ echo "or"
+ echo
+fi
echo "./autogen.sh"
-echo "./configure"
+echo "mkdir build; cd build"
+echo "../configure"
+echo ""
echo "make -j 3"
echo "make install"