2 # Setup development environment on Mac OS X (tested with 10.6.8 and Xcode 3.2.6)
6 # Trying to follow "Building Wireshark on SnowLeopard"
7 # given by Michael Tuexen at
8 # http://nplab.fh-muenster.de/groups/wiki/wiki/fb7a4/Building_Wireshark_on_SnowLeopard.html
12 # Versions to download and install.
14 # The following libraries and tools are required.
16 GETTEXT_VERSION=0.18.2
18 PKG_CONFIG_VERSION=0.28
24 GDK_PIXBUF_VERSION=2.28.0
25 if [ -z "$GTK3" ]; then
32 # Some package need xz to unpack their current source.
33 # xz is not available on OSX (Snow Leopard).
37 # In case we want to build with cmake
38 CMAKE_VERSION=2.8.10.2
41 # The following libraries are optional.
42 # Comment them out if you don't want them, but note that some of
43 # the optional libraries are required by other optional libraries.
47 # libgpg-error is required for libgcrypt.
49 LIBGPG_ERROR_VERSION=1.10
51 # libgcrypt is required for GnuTLS.
52 # XXX - the link for "Libgcrypt source code" at
53 # http://www.gnupg.org/download/#libgcrypt is for 1.5.0, and is a bzip2
54 # file, but http://directory.fsf.org/project/libgcrypt/ lists only
57 LIBGCRYPT_VERSION=1.5.0
58 GNUTLS_VERSION=2.12.19
59 # Stay with Lua 5.1 when updating until the code has been changed
62 PORTAUDIO_VERSION=pa_stable_v19_20111121
64 # XXX - they appear to have an unversioned gzipped tarball for the
65 # current version; should we just download that, with some other
66 # way of specifying whether to download the GeoIP API?
72 AUTOMAKE_VERSION=1.13.3
76 if [ -d macosx-support-libs ]
78 cd macosx-support-libs
81 # Uninstall items in the reverse order from the order in which they're
82 # installed. Only uninstall if we're configured to install them and
83 # if the download/build/install process completed.
85 # We also do a "make distclean", so that we don't have leftovers from
88 if [ "$GEOIP_VERSION" -a -f geoip-$GEOIP_VERSION-done ]
90 echo "Uninstalling GeoIP API:"
91 cd GeoIP-$GEOIP_VERSION
92 $DO_MAKE_UNINSTALL || exit 1
93 make distclean || exit 1
95 rm geoip-$GEOIP_VERSION-done
98 if [ "$PORTAUDIO_VERSION" -a -f portaudio-done ] ; then
99 echo "Uninstalling PortAudio:"
101 $DO_MAKE_UNINSTALL || exit 1
102 make distclean || exit 1
107 if [ "$LUA_VERSION" -a -f lua-$LUA_VERSION-done ] ; then
108 echo "Uninstalling Lua:"
110 # Lua has no "make uninstall", so just remove stuff manually.
111 # There's no configure script, so there's no need for
112 # "make distclean", either; just do "make clean".
114 (cd /usr/local/bin; $DO_RM -f lua luac)
115 (cd /usr/local/include; $DO_RM -f lua.h luaconf.h lualib.h lauxlib.h lua.hpp)
116 (cd /usr/local/lib; $DO_RM -f liblua.a)
117 (cd /usr/local/man; $DO_RM -f lua.1 luac.1)
121 rm lua-$LUA_VERSION-done
124 if [ "$GNUTLS_VERSION" -a -f gnutls-$GNUTLS_VERSION-done ] ; then
125 echo "Uninstalling GnuTLS:"
126 cd gnutls-$GNUTLS_VERSION
127 $DO_MAKE_UNINSTALL || exit 1
128 make distclean || exit 1
130 rm gnutls-$GNUTLS_VERSION-done
133 if [ "$LIBGCRYPT_VERSION" -a -f libgcrypt-$LIBGCRYPT_VERSION-done ] ; then
134 echo "Uninstalling libgcrypt:"
135 cd libgcrypt-$LIBGCRYPT_VERSION
136 $DO_MAKE_UNINSTALL || exit 1
137 make distclean || exit 1
139 rm libgcrypt-$LIBGCRYPT_VERSION-done
142 if [ "$LIBGPG_ERROR_VERSION" -a -f libgpg-error-$LIBGPG_ERROR_VERSION-done ] ; then
143 echo "Uninstalling libgpg-error:"
144 cd libgpg-error-$LIBGPG_ERROR_VERSION
145 $DO_MAKE_UNINSTALL || exit 1
146 make distclean || exit 1
148 rm libgpg-error-$LIBGPG_ERROR_VERSION-done
151 if [ "$LIBSMI_VERSION" -a -f libsmi-$LIBSMI_VERSION-done ] ; then
152 echo "Uninstalling libsmi:"
153 cd libsmi-$LIBSMI_VERSION
154 $DO_MAKE_UNINSTALL || exit 1
155 make distclean || exit 1
157 rm libsmi-$LIBSMI_VERSION-done
160 if [ -f gtk+-$GTK_VERSION-done ] ; then
161 echo "Uninstalling GTK+:"
163 $DO_MAKE_UNINSTALL || exit 1
164 make distclean || exit 1
166 rm gtk+-$GTK_VERSION-done
169 if [ -f gdk-pixbuf-$GDK_PIXBUF_VERSION-done ] ; then
170 echo "Uninstalling gdk-pixbuf:"
171 cd gdk-pixbuf-$GDK_PIXBUF_VERSION
172 $DO_MAKE_UNINSTALL || exit 1
173 make distclean || exit 1
175 rm gdk-pixbuf-$GDK_PIXBUF_VERSION-done
178 if [ -f pango-$PANGO_VERSION-done ] ; then
179 echo "Uninstalling Pango:"
180 cd pango-$PANGO_VERSION
181 $DO_MAKE_UNINSTALL || exit 1
182 make distclean || exit 1
184 rm pango-$PANGO_VERSION-done
187 if [ -f atk-$ATK_VERSION-done ] ; then
188 echo "Uninstalling ATK:"
190 $DO_MAKE_UNINSTALL || exit 1
191 make distclean || exit 1
193 rm atk-$ATK_VERSION-done
196 if [ -f cairo-$CAIRO_VERSION-done ] ; then
197 echo "Uninstalling Cairo:"
198 cd cairo-$CAIRO_VERSION
199 $DO_MAKE_INSTALL || exit 1
200 make distclean || exit 1
202 rm cairo-$CAIRO_VERSION-done
205 if [ -f pixman-$PIXMAN_VERSION-done ] ; then
206 echo "Uninstalling pixman:"
207 cd pixman-$PIXMAN_VERSION
208 $DO_MAKE_UNINSTALL || exit 1
209 make distclean || exit 1
211 rm pixman-$PIXMAN_VERSION-done
214 if [ -f libpng-$PNG_VERSION-done ] ; then
215 echo "Uninstalling libpng:"
216 cd libpng-$PNG_VERSION
217 $DO_MAKE_UNINSTALL || exit 1
218 make distclean || exit 1
220 rm libpng-$PNG_VERSION-done
223 if [ -f pkg-config-$PKG_CONFIG_VERSION-done ] ; then
224 echo "Uninstalling pkg-config:"
225 cd pkg-config-$PKG_CONFIG_VERSION
226 $DO_MAKE_UNINSTALL || exit 1
227 make distclean || exit 1
229 rm pkg-config-$PKG_CONFIG_VERSION-done
232 if [ -f glib-$GLIB_VERSION-done ] ; then
233 echo "Uninstalling GLib:"
234 cd glib-$GLIB_VERSION
235 $DO_MAKE_UNINSTALL || exit 1
236 make distclean || exit 1
238 rm glib-$GLIB_VERSION-done
241 if [ -f gettext-$GETTEXT_VERSION-done ] ; then
242 echo "Uninstalling GNU gettext:"
243 cd gettext-$GETTEXT_VERSION
244 $DO_MAKE_UNINSTALL || exit 1
245 make distclean || exit 1
247 rm gettext-$GETTEXT_VERSION-done
250 if [ -n "$CMAKE" -a -f cmake-$CMAKE_VERSION-done ]; then
251 echo "Uninstalling CMAKE:"
252 cd cmake-$CMAKE_VERSION
253 $DO_MAKE_UNINSTALL || exit 1
254 make distclean || exit 1
256 rm cmake-$CMAKE_VERSION-done
259 if [ "$LIBTOOL_VERSION" -a -f libtool-$LIBTOOL_VERSION-done ] ; then
260 echo "Uninstalling GNU libtool:"
261 cd libtool-$LIBTOOL_VERSION
262 mv /usr/local/bin/glibtool /usr/local/bin/libtool
263 mv /usr/local/bin/glibtoolize /usr/local/bin/libtoolize
264 $DO_MAKE_UNINSTALL || exit 1
265 make distclean || exit 1
267 rm libtool-$LIBTOOL_VERSION-done
270 if [ "$AUTOMAKE_VERSION" -a -f automake-$AUTOMAKE_VERSION-done ] ; then
271 echo "Uninstalling GNU automake:"
272 cd automake-$AUTOMAKE_VERSION
273 $DO_MAKE_UNINSTALL || exit 1
274 make distclean || exit 1
276 rm automake-$AUTOMAKE_VERSION-done
279 if [ "$AUTOCONF_VERSION" -a -f autoconf-$AUTOCONF_VERSION-done ] ; then
280 echo "Uninstalling GNU autoconf:"
281 cd autoconf-$AUTOCONF_VERSION
282 $DO_MAKE_UNINSTALL || exit 1
283 make distclean || exit 1
285 rm autoconf-$AUTOCONF_VERSION-done
288 if [ "$XZ_VERSION" -a -f xz-$XZ_VERSION-done ] ; then
289 echo "Uninstalling xz:"
291 $DO_MAKE_UNINSTALL || exit 1
292 make distclean || exit 1
294 rm xz-$XZ_VERSION-done
300 # Do we have permission to write in /usr/local?
302 # If so, assume we have permission to write in its subdirectories.
303 # (If that's not the case, this test needs to check the subdirectories
306 # If not, do "make install", "make uninstall", and the removes for Lua
311 DO_MAKE_INSTALL="make install"
312 DO_MAKE_UNINSTALL="make uninstall"
315 DO_MAKE_INSTALL="sudo make install"
316 DO_MAKE_UNINSTALL="sudo make uninstall"
321 # Parse command-line flags:
324 # -u - do an uninstall.
326 while getopts hu name
333 echo "Usage: macosx-setup.sh [ -u ]" 1>&1
339 if [ "$do_uninstall" = "yes" ]
345 DARWIN_MAJOR_VERSION=`uname -r | sed 's/\([0-9]*\).*/\1/'`
348 # To make this work on Leopard will take a lot of work.
350 # First of all, Leopard's /usr/X11/lib/libXdamage.la claims, at least
351 # with all software updates applied, that the Xdamage shared library
352 # is libXdamage.1.0.0.dylib, but it is, in fact, libXdamage.1.1.0.dylib.
353 # This causes problems when building GTK+, so the script would have to
356 # Second of all, the version of fontconfig that comes with Leopard
357 # doesn't support FC_WEIGHT_EXTRABLACK, so we can't use any version
358 # of Pango newer than 1.22.4.
360 # However, Pango 1.22.4 doesn't work with versions of GLib after
361 # 2.29.6, because Pango 1.22.4 uses G_CONST_RETURN and GLib 2.29.8
362 # and later deprecate it (there doesn't appear to be a GLib 2.29.7).
363 # That means we'd either have to patch Pango not to use it (just
364 # use "const"; G_CONST_RETURN was there to allow code to choose whether
365 # to use "const" or not), or use GLib 2.29.6 or earlier.
367 # GLib 2.29.6 includes an implementation of g_bit_lock() that, on x86
368 # (32-bit and 64-bit), uses asms in a fashion ("asm volatile goto") that
369 # doesn't work with the Apple version of GCC 4.0.1, which is the compiler
370 # you get with Leopard+updates. Apparently, that requires GCC 4.5 or
371 # later; recent versions of GLib check for that, but 2.29.6 doesn't.
372 # Therefore, we would have to patch glib/gbitlock.c to do what the
373 # newer versions of GLib do:
375 # define a USE_ASM_GOTO macro that indicates whether "asm goto"
377 # #if (defined (i386) || defined (__amd64__))
378 # #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
379 # #define USE_ASM_GOTO 1
383 # replace all occurrences of
385 # #if defined (__GNUC__) && (defined (i386) || defined (__amd64__))
389 # #ifdef USE_ASM_GOTO
391 # Using GLib 2.29.6 or earlier, however, would mean that we can't
392 # use a version of ATK later than 2.3.93, as those versions don't
393 # work with GLib 2.29.6. The same applies to gdk-pixbuf; versions
394 # of gdk-pixbuf after 2.24.1 won't work with GLib 2.29.6.
396 # Once you've set this script up to use the older versions of the
397 # libraries, and built and installed them, you find that Wireshark,
398 # when built with them, crashes the X server that comes with Leopard,
399 # at least with all updates from Apple. Maybe patching Pango rather
400 # than going with an older version of Pango would work.
402 # The Leopard Wireshark buildbot uses GTK+ 2.12.9, Cairo 1.6.4,
403 # Pango 1.20.2, and GLib 2.16.3, with an unknown version of ATK,
404 # and, I think, without gdk-pixbuf, as it hadn't been made a
405 # separate library from GTK+ as of GTK+ 2.12.9. Its binaries
406 # don't crash the X server.
408 # However, if you try various older versions of Cairo, including
409 # 1.6.4 and at least some 1.8.x versions, when you try to build
410 # it, the build fails because it can't find png_set_longjmp_fn().
411 # I vaguely remember dealing with that, ages ago, but don't
412 # remember what I did; fixing *that* is left as an exercise for
415 # Oh, and if you're building with a version of GTK+ that doesn't
416 # have the gdk-pixbuf stuff in a separate library, you probably
417 # don't want to bother downloading or installing the gdk-pixbuf
418 # library, *and* you will need to configure GTK+ with
419 # --without-libtiff and --without-libjpeg (as we currently do
422 if [[ $DARWIN_MAJOR_VERSION -le 9 ]]; then
423 echo "This script does not support any versions of OS X before Snow Leopard" 1>&2
427 # To set up a GTK3 environment
432 # To build all libraries as 32-bit libraries uncomment the following three lines.
433 # export CFLAGS="$CFLAGS -arch i386"
434 # export CXXFLAGS="$CXXFLAGS -arch i386"
435 # export LDFLAGS="$LDFLAGS -arch i386"
438 # if no make options are present, set default options
439 if [ -z "$MAKE_BUILD_OPTS" ] ; then
440 # by default use 1.5x number of cores for parallel build
441 MAKE_BUILD_OPTS="-j $(( $(sysctl -n hw.logicalcpu) * 3 / 2))"
445 # You need Xcode installed to get the compilers.
447 if [ ! -x /usr/bin/xcodebuild ]; then
448 echo "Please install Xcode first (should be available on DVD or from http://developer.apple.com/xcode/index.php)."
453 # You also need the X11 SDK; with at least some versions of OS X and
454 # Xcode, that is, I think, an optional install. (Or it might be
455 # installed with X11, but I think *that* is an optional install on
456 # at least some versions of OS X.)
458 if [ ! -d /usr/X11/include ]; then
459 echo "Please install X11 and the X11 SDK first."
463 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig
466 # Do all the downloads and untarring in a subdirectory, so all that
467 # stuff can be removed once we've installed the support libraries.
469 if [ ! -d macosx-support-libs ]
471 mkdir macosx-support-libs || exit 1
473 cd macosx-support-libs
475 # Start with xz: It is the sole download format of glib later than 2.31.2
477 if [ "$XZ_VERSION" -a ! -f xz-$XZ_VERSION-done ] ; then
478 echo "Downloading, building, and installing xz:"
479 [ -f xz-$XZ_VERSION.tar.bz2 ] || curl -O http://tukaani.org/xz/xz-$XZ_VERSION.tar.bz2 || exit 1
480 bzcat xz-$XZ_VERSION.tar.bz2 | tar xf - || exit 1
482 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0" ./configure || exit 1
483 make $MAKE_BUILD_OPTS || exit 1
484 $DO_MAKE_INSTALL || exit 1
486 touch xz-$XZ_VERSION-done
489 if [ "$AUTOCONF_VERSION" -a ! -f autoconf-$AUTOCONF_VERSION-done ] ; then
490 echo "Downloading, building and installing GNU autoconf..."
491 [ -f autoconf-$AUTOCONF_VERSION.tar.xz ] || curl -O ftp://ftp.gnu.org/gnu/autoconf/autoconf-$AUTOCONF_VERSION.tar.xz || exit 1
492 xzcat autoconf-$AUTOCONF_VERSION.tar.xz | tar xf - || exit 1
493 cd autoconf-$AUTOCONF_VERSION
494 ./configure || exit 1
495 make $MAKE_BUILD_OPTS || exit 1
496 $DO_MAKE_INSTALL || exit 1
498 touch autoconf-$AUTOCONF_VERSION-done
501 if [ "$AUTOMAKE_VERSION" -a ! -f automake-$AUTOMAKE_VERSION-done ] ; then
502 echo "Downloading, building and installing GNU automake..."
503 [ -f automake-$AUTOMAKE_VERSION.tar.xz ] || curl -O ftp://ftp.gnu.org/gnu/automake/automake-$AUTOMAKE_VERSION.tar.xz || exit 1
504 xzcat automake-$AUTOMAKE_VERSION.tar.xz | tar xf - || exit 1
505 cd automake-$AUTOMAKE_VERSION
506 ./configure || exit 1
507 make $MAKE_BUILD_OPTS || exit 1
508 $DO_MAKE_INSTALL || exit 1
510 touch automake-$AUTOMAKE_VERSION-done
513 if [ "$LIBTOOL_VERSION" -a ! -f libtool-$LIBTOOL_VERSION-done ] ; then
514 echo "Downloading, building and installing GNU libtool..."
515 [ -f libtool-$LIBTOOL_VERSION.tar.xz ] || curl -O ftp://ftp.gnu.org/gnu/libtool/libtool-$LIBTOOL_VERSION.tar.xz || exit 1
516 xzcat libtool-$LIBTOOL_VERSION.tar.xz | tar xf - || exit 1
517 cd libtool-$LIBTOOL_VERSION
518 ./configure || exit 1
519 make $MAKE_BUILD_OPTS || exit 1
520 $DO_MAKE_INSTALL || exit 1
521 mv /usr/local/bin/libtool /usr/local/bin/glibtool
522 mv /usr/local/bin/libtoolize /usr/local/bin/glibtoolize
524 touch libtool-$LIBTOOL_VERSION-done
527 if [ -n "$CMAKE" -a ! -f cmake-$CMAKE_VERSION-done ]; then
528 echo "Downloading, building, and installing CMAKE:"
529 cmake_dir=`expr $CMAKE_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
530 [ -f cmake-$CMAKE_VERSION.tar.gz ] || curl -O http://www.cmake.org/files/v$cmake_dir/cmake-$CMAKE_VERSION.tar.gz || exit 1
531 gzcat cmake-$CMAKE_VERSION.tar.gz | tar xf - || exit 1
532 cd cmake-$CMAKE_VERSION
533 ./bootstrap || exit 1
534 make $MAKE_BUILD_OPTS || exit 1
535 $DO_MAKE_INSTALL || exit 1
537 touch cmake-$CMAKE_VERSION-done
541 # Start with GNU gettext; GLib requires it, and OS X doesn't have it
542 # or a BSD-licensed replacement.
544 # At least on Lion with Xcode 4, _FORTIFY_SOURCE gets defined as 2
545 # by default, which causes, for example, stpncpy to be defined as
546 # a hairy macro that collides with the GNU gettext configure script's
547 # attempts to workaround AIX's lack of a declaration for stpncpy,
548 # with the result being a huge train wreck. Define _FORTIFY_SOURCE
549 # as 0 in an attempt to keep the trains on separate tracks.
551 if [ ! -f gettext-$GETTEXT_VERSION-done ] ; then
552 echo "Downloading, building, and installing GNU gettext:"
553 [ -f gettext-$GETTEXT_VERSION.tar.gz ] || curl -O http://ftp.gnu.org/pub/gnu/gettext/gettext-$GETTEXT_VERSION.tar.gz || exit 1
554 gzcat gettext-$GETTEXT_VERSION.tar.gz | tar xf - || exit 1
555 cd gettext-$GETTEXT_VERSION
556 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0" ./configure || exit 1
557 make $MAKE_BUILD_OPTS || exit 1
558 $DO_MAKE_INSTALL || exit 1
560 touch gettext-$GETTEXT_VERSION-done
563 if [ ! -f glib-$GLIB_VERSION-done ] ; then
564 echo "Downloading, building, and installing GLib:"
565 glib_dir=`expr $GLIB_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
566 [ -f glib-$GLIB_VERSION.tar.xz ] || curl -L -O http://ftp.gnome.org/pub/gnome/sources/glib/$glib_dir/glib-$GLIB_VERSION.tar.xz || exit 1
567 xzcat glib-$GLIB_VERSION.tar.xz | tar xf - || exit 1
568 cd glib-$GLIB_VERSION
570 # OS X ships with libffi, but doesn't provide its pkg-config file;
571 # explicitly specify LIBFFI_CFLAGS and LIBFFI_LIBS, so the configure
572 # script doesn't try to use pkg-config to get the appropriate
573 # C flags and loader flags.
575 # And, what's worse, at least with the version of Xcode that comes
576 # with Leopard, /usr/include/ffi/fficonfig.h doesn't define MACOSX,
577 # which causes the build of GLib to fail. If we don't find
578 # "#define.*MACOSX" in /usr/include/ffi/fficonfig.h, explictly
581 # While we're at it, suppress -Wformat-nonliteral to avoid a case
582 # where clang's stricter rules on when not to complain about
583 # non-literal format arguments cause it to complain about code
584 # that's safe but it wasn't told that. See my comment #25 in
587 # https://bugzilla.gnome.org/show_bug.cgi?id=691608#c25
589 # First, determine where the system include files are. (It's not
590 # necessarily /usr/include.) There's a bit of a greasy hack here;
591 # pre-5.x versions of the developer tools don't support the
592 # --show-sdk-path option, and will produce no output, so includedir
593 # will be set to /usr/include (in those older versions of the
594 # developer tools, there is a /usr/include directory).
596 includedir=`xcrun --show-sdk-path 2>/dev/null`/usr/include
597 if grep -qs '#define.*MACOSX' $includedir/ffi/fficonfig.h
599 # It's defined, nothing to do
600 LIBFFI_CFLAGS="-I $includedir/ffi" LIBFFI_LIBS="-lffi" CFLAGS="$CFLAGS -Wno-format-nonliteral" ./configure || exit 1
602 LIBFFI_CFLAGS="-I $includedir/ffi" LIBFFI_LIBS="-lffi" CFLAGS="$CFLAGS -DMACOSX -Wno-format-nonliteral" ./configure || exit 1
604 make $MAKE_BUILD_OPTS || exit 1
605 # Apply patch: we depend on libffi, but pkg-config doesn't get told.
606 patch -p0 <../../macosx-support-lib-patches/glib-pkgconfig.patch || exit 1
607 $DO_MAKE_INSTALL || exit 1
609 touch glib-$GLIB_VERSION-done
612 if [ ! -f pkg-config-$PKG_CONFIG_VERSION-done ] ; then
613 echo "Downloading, building, and installing pkg-config:"
614 [ -f pkg-config-$PKG_CONFIG_VERSION.tar.gz ] || curl -O http://pkgconfig.freedesktop.org/releases/pkg-config-$PKG_CONFIG_VERSION.tar.gz || exit 1
615 gzcat pkg-config-$PKG_CONFIG_VERSION.tar.gz | tar xf - || exit 1
616 cd pkg-config-$PKG_CONFIG_VERSION
617 # Avoid another pkgconfig call
618 GLIB_CFLAGS="$CFLAGS -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include" GLIB_LIBS="$LDFLAGS -L/usr/local/lib -lglib-2.0 -lintl" ./configure || exit 1
619 make $MAKE_BUILD_OPTS || exit 1
620 $DO_MAKE_INSTALL || exit 1
622 touch pkg-config-$PKG_CONFIG_VERSION-done
626 # Now we have reached a point where we can build everything but
627 # the GUI (Wireshark).
629 # Cairo is part of Mac OS X 10.6 and 10.7.
630 # The *headers* are supplied by 10.5, but the *libraries* aren't, so
631 # we have to build it on 10.5.
632 # GTK+ 3 requires a newer Cairo build than the one that comes with
633 # 10.6, so we build Cairo if we are using GTK+ 3.
634 # In 10.6 and 10.7, it's an X11 library; if we build with "native" GTK+
635 # rather than X11 GTK+, we might have to build and install Cairo.
636 # The major version number of Darwin in 10.5 is 9.
638 if [[ -n "$GTK3" || $DARWIN_MAJOR_VERSION = "9" ]]; then
640 # Requirements for Cairo first
642 # The libpng that comes with the X11 for leopard has a bogus
643 # pkg-config file that lies about where the header files are,
644 # which causes other packages not to be able to find its
647 if [ ! -f libpng-$PNG_VERSION-done ] ; then
648 echo "Downloading, building, and installing libpng:"
649 [ -f libpng-$PNG_VERSION.tar.xz ] || curl -O ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-$PNG_VERSION.tar.xz
650 xzcat libpng-$PNG_VERSION.tar.xz | tar xf - || exit 1
651 cd libpng-$PNG_VERSION
652 ./configure || exit 1
653 make $MAKE_BUILD_OPTS || exit 1
654 $DO_MAKE_INSTALL || exit 1
656 touch libpng-$PNG_VERSION-done
660 # The libpixman that comes with the X11 for Leopard is too old
661 # to support Cairo's image surface backend feature (which requires
662 # pixman-1 >= 0.22.0).
664 if [ ! -f pixman-$PIXMAN_VERSION-done ] ; then
665 echo "Downloading, building, and installing pixman:"
666 [ -f pixman-$PIXMAN_VERSION.tar.gz ] || curl -O http://www.cairographics.org/releases/pixman-$PIXMAN_VERSION.tar.gz
667 gzcat pixman-$PIXMAN_VERSION.tar.gz | tar xf - || exit 1
668 cd pixman-$PIXMAN_VERSION
669 ./configure || exit 1
670 make $MAKE_BUILD_OPTS || exit 1
671 $DO_MAKE_INSTALL || exit 1
673 touch pixman-$PIXMAN_VERSION-done
677 # And now Cairo itself.
679 if [ ! -f cairo-$CAIRO_VERSION-done ] ; then
680 echo "Downloading, building, and installing Cairo:"
681 CAIRO_MAJOR_VERSION="`expr $CAIRO_VERSION : '\([0-9][0-9]*\).*'`"
682 CAIRO_MINOR_VERSION="`expr $CAIRO_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
683 CAIRO_DOTDOT_VERSION="`expr $CAIRO_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
684 if [[ $CAIRO_MAJOR_VERSION -gt 1 ||
685 $CAIRO_MINOR_VERSION -gt 12 ||
686 ($CAIRO_MINOR_VERSION -eq 12 && $CAIRO_DOTDOT_VERSION -ge 2) ]]
689 # Starting with Cairo 1.12.2, the tarballs are compressed with
690 # xz rather than gzip.
692 [ -f cairo-$CAIRO_VERSION.tar.xz ] || curl -O http://cairographics.org/releases/cairo-$CAIRO_VERSION.tar.xz || exit 1
693 xzcat cairo-$CAIRO_VERSION.tar.xz | tar xf - || exit 1
695 [ -f cairo-$CAIRO_VERSION.tar.gz ] || curl -O http://cairographics.org/releases/cairo-$CAIRO_VERSION.tar.gz || exit 1
696 gzcat cairo-$CAIRO_VERSION.tar.gz | tar xf - || exit 1
698 cd cairo-$CAIRO_VERSION
699 #./configure --enable-quartz=no || exit 1
700 # Maybe follow http://cairographics.org/end_to_end_build_for_mac_os_x/
701 ./configure --enable-quartz=yes || exit 1
703 # We must avoid the version of libpng that comes with X11; the
704 # only way I've found to force that is to forcibly set INCLUDES
705 # when we do the build, so that this comes before CAIRO_CFLAGS,
706 # which has -I/usr/X11/include added to it before anything
707 # connected to libpng is.
709 INCLUDES="-I/usr/local/include/libpng15" make $MAKE_BUILD_OPTS || exit 1
710 $DO_MAKE_INSTALL || exit 1
712 touch cairo-$CAIRO_VERSION-done
716 if [ ! -f atk-$ATK_VERSION-done ] ; then
717 echo "Downloading, building, and installing ATK:"
718 atk_dir=`expr $ATK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
719 [ -f atk-$ATK_VERSION.tar.xz ] || curl -O http://ftp.gnome.org/pub/gnome/sources/atk/$atk_dir/atk-$ATK_VERSION.tar.xz || exit 1
720 xzcat atk-$ATK_VERSION.tar.xz | tar xf - || exit 1
722 ./configure || exit 1
723 make $MAKE_BUILD_OPTS || exit 1
724 $DO_MAKE_INSTALL || exit 1
726 touch atk-$ATK_VERSION-done
729 if [ ! -f pango-$PANGO_VERSION-done ] ; then
730 echo "Downloading, building, and installing Pango:"
731 pango_dir=`expr $PANGO_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
732 PANGO_MAJOR_VERSION="`expr $PANGO_VERSION : '\([0-9][0-9]*\).*'`"
733 PANGO_MINOR_VERSION="`expr $PANGO_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
734 if [[ $PANGO_MAJOR_VERSION -gt 1 ||
735 $PANGO_MINOR_VERSION -ge 29 ]]
738 # Starting with Pango 1.29, the tarballs are compressed with
739 # xz rather than bzip2.
741 [ -f pango-$PANGO_VERSION.tar.xz ] || curl -L -O http://ftp.gnome.org/pub/gnome/sources/pango/$pango_dir/pango-$PANGO_VERSION.tar.xz || exit 1
742 xzcat pango-$PANGO_VERSION.tar.xz | tar xf - || exit 1
744 [ -f pango-$PANGO_VERSION.tar.bz2 ] || curl -L -O http://ftp.gnome.org/pub/gnome/sources/pango/$pango_dir/pango-$PANGO_VERSION.tar.bz2 || exit 1
745 gzcat pango-$PANGO_VERSION.tar.bz2 | tar xf - || exit 1
747 cd pango-$PANGO_VERSION
748 ./configure || exit 1
749 make $MAKE_BUILD_OPTS || exit 1
750 $DO_MAKE_INSTALL || exit 1
752 touch pango-$PANGO_VERSION-done
755 if [ ! -f gdk-pixbuf-$GDK_PIXBUF_VERSION-done ] ; then
756 echo "Downloading, building, and installing gdk-pixbuf:"
757 gdk_pixbuf_dir=`expr $GDK_PIXBUF_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
758 [ -f gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.xz ] || curl -L -O http://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/$gdk_pixbuf_dir/gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.xz || exit 1
759 xzcat gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.xz | tar xf - || exit 1
760 cd gdk-pixbuf-$GDK_PIXBUF_VERSION
761 ./configure --without-libtiff --without-libjpeg || exit 1
762 make $MAKE_BUILD_OPTS || exit 1
763 $DO_MAKE_INSTALL || exit 1
765 touch gdk-pixbuf-$GDK_PIXBUF_VERSION-done
768 if [ ! -f gtk+-$GTK_VERSION-done ] ; then
769 echo "Downloading, building, and installing GTK+:"
770 gtk_dir=`expr $GTK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
771 GTK_MAJOR_VERSION="`expr $GTK_VERSION : '\([0-9][0-9]*\).*'`"
772 GTK_MINOR_VERSION="`expr $GTK_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
773 GTK_DOTDOT_VERSION="`expr $GTK_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
774 if [[ $GTK_MAJOR_VERSION -gt 2 ||
775 $GTK_MINOR_VERSION -gt 24 ||
776 ($GTK_MINOR_VERSION -eq 24 && $GTK_DOTDOT_VERSION -ge 5) ]]
779 # Starting with GTK+ 2.24.5, the tarballs are compressed with
780 # xz rather than gzip, in addition to bzip2; use xz, as we've
781 # built and installed it, and as xz compresses better than
782 # bzip2 so the tarballs take less time to download.
784 [ -f gtk+-$GTK_VERSION.tar.xz ] || curl -L -O http://ftp.gnome.org/pub/gnome/sources/gtk+/$gtk_dir/gtk+-$GTK_VERSION.tar.xz || exit 1
785 xzcat gtk+-$GTK_VERSION.tar.xz | tar xf - || exit 1
787 [ -f gtk+-$GTK_VERSION.tar.bz2 ] || curl -L -O http://ftp.gnome.org/pub/gnome/sources/gtk+/$gtk_dir/gtk+-$GTK_VERSION.tar.bz2 || exit 1
788 gzcat gtk+-$GTK_VERSION.tar.bz2 | tar xf - || exit 1
791 if [ $DARWIN_MAJOR_VERSION -ge "12" ]
794 # GTK+ 2.24.10, at least, doesn't build on Mountain Lion with the
795 # CUPS printing backend - either the CUPS API changed incompatibly
796 # or the backend was depending on non-API implementation details.
798 # Configure it out, on Mountain Lion and later, for now.
799 # (12 is the Darwin major version number in Mountain Lion.)
801 ./configure --disable-cups || exit 1
803 ./configure || exit 1
805 make $MAKE_BUILD_OPTS || exit 1
806 $DO_MAKE_INSTALL || exit 1
808 touch gtk+-$GTK_VERSION-done
812 # Now we have reached a point where we can build everything including
813 # the GUI (Wireshark), but not with any optional features such as
814 # SNMP OID resolution, some forms of decryption, Lua scripting, playback
815 # of audio, or GeoIP mapping of IP addresses.
817 # We now conditionally download optional libraries to support them;
818 # the default is to download them all.
821 if [ "$LIBSMI_VERSION" -a ! -f libsmi-$LIBSMI_VERSION-done ] ; then
822 echo "Downloading, building, and installing libsmi:"
823 [ -f libsmi-$LIBSMI_VERSION.tar.gz ] || curl -L -O ftp://ftp.ibr.cs.tu-bs.de/pub/local/libsmi/libsmi-$LIBSMI_VERSION.tar.gz || exit 1
824 gzcat libsmi-$LIBSMI_VERSION.tar.gz | tar xf - || exit 1
825 cd libsmi-$LIBSMI_VERSION
826 ./configure || exit 1
827 make $MAKE_BUILD_OPTS || exit 1
828 $DO_MAKE_INSTALL || exit 1
830 touch libsmi-$LIBSMI_VERSION-done
833 if [ "$LIBGPG_ERROR_VERSION" -a ! -f libgpg-error-$LIBGPG_ERROR_VERSION-done ] ; then
834 echo "Downloading, building, and installing libgpg-error:"
835 [ -f libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 ] || curl -L -O ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 || exit 1
836 bzcat libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 | tar xf - || exit 1
837 cd libgpg-error-$LIBGPG_ERROR_VERSION
838 ./configure || exit 1
839 make $MAKE_BUILD_OPTS || exit 1
840 $DO_MAKE_INSTALL || exit 1
842 touch libgpg-error-$LIBGPG_ERROR_VERSION-done
845 if [ "$LIBGCRYPT_VERSION" -a ! -f libgcrypt-$LIBGCRYPT_VERSION-done ] ; then
847 # libgpg-error is required for libgcrypt.
849 if [ -z $LIBGPG_ERROR_VERSION ]
851 echo "libgcrypt requires libgpg-error, but you didn't install libgpg-error." 1>&2
855 echo "Downloading, building, and installing libgcrypt:"
856 [ -f libgcrypt-$LIBGCRYPT_VERSION.tar.gz ] || curl -L -O ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-$LIBGCRYPT_VERSION.tar.gz || exit 1
857 gzcat libgcrypt-$LIBGCRYPT_VERSION.tar.gz | tar xf - || exit 1
858 cd libgcrypt-$LIBGCRYPT_VERSION
860 # The assembler language code is not compatible with the OS X
861 # x86 assembler (or is it an x86-64 vs. x86-32 issue?).
863 # libgcrypt expects gnu89, not c99/gnu99, semantics for
864 # "inline". See, for example:
866 # http://lists.freebsd.org/pipermail/freebsd-ports-bugs/2010-October/198809.html
868 CFLAGS="$CFLAGS -std=gnu89" ./configure --disable-asm || exit 1
869 make $MAKE_BUILD_OPTS || exit 1
870 $DO_MAKE_INSTALL || exit 1
872 touch libgcrypt-$LIBGCRYPT_VERSION-done
875 if [ "$GNUTLS_VERSION" -a ! -f gnutls-$GNUTLS_VERSION-done ] ; then
877 # GnuTLS requires libgcrypt (or nettle, in newer versions).
879 if [ -z $LIBGCRYPT_VERSION ]
881 echo "GnuTLS requires libgcrypt, but you didn't install libgcrypt" 1>&2
885 echo "Downloading, building, and installing GnuTLS:"
886 [ -f gnutls-$GNUTLS_VERSION.tar.bz2 ] || curl -L -O http://ftp.gnu.org/gnu/gnutls/gnutls-$GNUTLS_VERSION.tar.bz2 || exit 1
887 bzcat gnutls-$GNUTLS_VERSION.tar.bz2 | tar xf - || exit 1
888 cd gnutls-$GNUTLS_VERSION
890 # Use libgcrypt, not nettle.
891 # XXX - is there some reason to prefer nettle? Or does
892 # Wireshark directly use libgcrypt routines?
894 ./configure --with-libgcrypt --without-p11-kit || exit 1
895 make $MAKE_BUILD_OPTS || exit 1
897 # The pkgconfig file for GnuTLS says "requires zlib", but OS X,
898 # while it supplies zlib, doesn't supply a pkgconfig file for
901 # Patch the GnuTLS pkgconfig file not to require zlib.
902 # (If the capabilities of GnuTLS that Wireshark uses don't
903 # depend on building GnuTLS with zlib, an alternative would be
904 # to configure it not to use zlib.)
906 patch -p0 lib/gnutls.pc.in <../../macosx-support-lib-patches/gnutls-pkgconfig.patch || exit 1
907 $DO_MAKE_INSTALL || exit 1
909 touch gnutls-$GNUTLS_VERSION-done
912 if [ "$LUA_VERSION" -a ! -f lua-$LUA_VERSION-done ] ; then
913 echo "Downloading, building, and installing Lua:"
914 [ -f lua-$LUA_VERSION.tar.gz ] || curl -L -O http://www.lua.org/ftp/lua-$LUA_VERSION.tar.gz || exit 1
915 gzcat lua-$LUA_VERSION.tar.gz | tar xf - || exit 1
917 make $MAKE_BUILD_OPTS macosx || exit 1
918 $DO_MAKE_INSTALL || exit 1
920 touch lua-$LUA_VERSION-done
923 if [ "$PORTAUDIO_VERSION" -a ! -f portaudio-done ] ; then
924 echo "Downloading, building, and installing PortAudio:"
925 [ -f $PORTAUDIO_VERSION.tgz ] || curl -L -O http://www.portaudio.com/archives/$PORTAUDIO_VERSION.tgz || exit 1
926 gzcat $PORTAUDIO_VERSION.tgz | tar xf - || exit 1
929 # Un-comment an include that's required on Lion.
931 patch -p0 include/pa_mac_core.h <../../macosx-support-lib-patches/portaudio-pa_mac_core.h.patch
933 # Fix a bug that showed up with clang (but is a bug with any
936 patch -p0 src/hostapi/coreaudio/pa_mac_core.c <../../macosx-support-lib-patches/portaudio-pa_mac_core.c.patch
938 # Disable fat builds - the configure script doesn't work right
939 # with Xcode 4 if you leave them enabled, and we don't build
940 # any other libraries fat (GLib, for example, would be very
941 # hard to build fat), so there's no advantage to having PortAudio
944 # Set the minimum OS X version to 10.4, to suppress some
945 # deprecation warnings.
947 CFLAGS="$CFLAGS -mmacosx-version-min=10.4" ./configure --disable-mac-universal || exit 1
948 make $MAKE_BUILD_OPTS || exit 1
949 $DO_MAKE_INSTALL || exit 1
954 if [ "$GEOIP_VERSION" -a ! -f geoip-$GEOIP_VERSION-done ]
956 echo "Downloading, building, and installing GeoIP API:"
957 [ -f GeoIP-$GEOIP_VERSION.tar.gz ] || curl -L -O http://geolite.maxmind.com/download/geoip/api/c/GeoIP-$GEOIP_VERSION.tar.gz || exit 1
958 gzcat GeoIP-$GEOIP_VERSION.tar.gz | tar xf - || exit 1
959 cd GeoIP-$GEOIP_VERSION
960 ./configure || exit 1
962 # Grr. Their man pages "helpfully" have an ISO 8859-1
963 # copyright symbol in the copyright notice, but OS X's
964 # default character encoding is UTF-8. sed on Mountain
965 # Lion barfs at the "illegal character sequence" represented
966 # by an ISO 8859-1 copyright symbol, as it's not a valid
969 # iconv the relevant man pages into UTF-8.
971 for i in geoipupdate.1.in geoiplookup6.1.in geoiplookup.1.in
973 iconv -f iso8859-1 -t utf-8 man/"$i" >man/"$i".tmp &&
974 mv man/"$i".tmp man/"$i"
976 make $MAKE_BUILD_OPTS || exit 1
977 $DO_MAKE_INSTALL || exit 1
979 touch geoip-$GEOIP_VERSION-done
984 echo "You are now prepared to build Wireshark. To do so do:"
985 echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig"
987 if [ -n "$CMAKE" ]; then
988 echo "mkdir build; cd build"
995 echo "mkdir build; cd build"
998 echo "make $MAKE_BUILD_OPTS"
1003 echo "Make sure you are allowed capture access to the network devices"
1004 echo "See: http://wiki.wireshark.org/CaptureSetup/CapturePrivileges"