Add UDT dissector. Bug 8741 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id...
[metze/wireshark/wip.git] / macosx-setup.sh
1 #!/bin/sh
2 # Setup development environment on Mac OS X (tested with 10.6.8 and Xcode 3.2.6)
3 #
4 # $Id$
5 #
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
9 #
10
11 DARWIN_MAJOR_VERSION=`uname -r | sed 's/\([0-9]*\).*/\1/'`
12
13 #
14 # To make this work on Leopard will take a lot of work.
15 #
16 # First of all, Leopard's /usr/X11/lib/libXdamage.la claims, at least
17 # with all software updates applied, that the Xdamage shared library
18 # is libXdamage.1.0.0.dylib, but it is, in fact, libXdamage.1.1.0.dylib.
19 # This causes problems when building GTK+, so the script would have to
20 # fix that file.
21 #
22 # Second of all, the version of fontconfig that comes with Leopard
23 # doesn't support FC_WEIGHT_EXTRABLACK, so we can't use any version
24 # of Pango newer than 1.22.4.
25 #
26 # However, Pango 1.22.4 doesn't work with versions of GLib after
27 # 2.29.6, because Pango 1.22.4 uses G_CONST_RETURN and GLib 2.29.8
28 # and later deprecate it (there doesn't appear to be a GLib 2.29.7).
29 # That means we'd either have to patch Pango not to use it (just
30 # use "const"; G_CONST_RETURN was there to allow code to choose whether
31 # to use "const" or not), or use GLib 2.29.6 or earlier.
32 #
33 # GLib 2.29.6 includes an implementation of g_bit_lock() that, on x86
34 # (32-bit and 64-bit), uses asms in a fashion ("asm volatile goto") that
35 # doesn't work with the Apple version of GCC 4.0.1, which is the compiler
36 # you get with Leopard+updates.  Apparently, that requires GCC 4.5 or
37 # later; recent versions of GLib check for that, but 2.29.6 doesn't.
38 # Therefore, we would have to patch glib/gbitlock.c to do what the
39 # newer versions of GLib do:
40 #
41 #  define a USE_ASM_GOTO macro that indicates whether "asm goto"
42 #  can be used:
43 #    #if (defined (i386) || defined (__amd64__))
44 #      #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
45 #        #define USE_ASM_GOTO 1
46 #      #endif
47 #    #endif
48 #
49 #  replace all occurrences of
50 #
51 #    #if defined (__GNUC__) && (defined (i386) || defined (__amd64__))
52 #
53 #  with
54 #
55 #    #ifdef USE_ASM_GOTO
56 #
57 # Using GLib 2.29.6 or earlier, however, would mean that we can't
58 # use a version of ATK later than 2.3.93, as those versions don't
59 # work with GLib 2.29.6.  The same applies to gdk-pixbuf; versions
60 # of gdk-pixbuf after 2.24.1 won't work with GLib 2.29.6.
61 #
62 # Once you've set this script up to use the older versions of the
63 # libraries, and built and installed them, you find that Wireshark,
64 # when built with them, crashes the X server that comes with Leopard,
65 # at least with all updates from Apple.  Maybe patching Pango rather
66 # than going with an older version of Pango would work.
67 #
68 # The Leopard Wireshark buildbot uses GTK+ 2.12.9, Cairo 1.6.4,
69 # Pango 1.20.2, and GLib 2.16.3, with an unknown version of ATK,
70 # and, I think, without gdk-pixbuf, as it hadn't been made a
71 # separate library from GTK+ as of GTK+ 2.12.9.  Its binaries
72 # don't crash the X server.
73 #
74 # However, if you try various older versions of Cairo, including
75 # 1.6.4 and at least some 1.8.x versions, when you try to build
76 # it, the build fails because it can't find png_set_longjmp_fn().
77 # I vaguely remember dealing with that, ages ago, but don't
78 # remember what I did; fixing *that* is left as an exercise for
79 # the reader.
80 #
81 # Oh, and if you're building with a version of GTK+ that doesn't
82 # have the gdk-pixbuf stuff in a separate library, you probably
83 # don't want to bother downloading or installing the gdk-pixbuf
84 # library, *and* you will need to configure GTK+ with
85 # --without-libtiff and --without-libjpeg (as we currently do
86 # with gdk-pixbuf).
87 #
88 if [[ $DARWIN_MAJOR_VERSION -le 9 ]]; then
89         echo "This script does not support any versions of OS X before Snow Leopard" 1>&2 
90         exit 1
91 fi
92
93 # To set up a GTK3 environment
94 # GTK3=1
95 # To build cmake
96 # CMAKE=1
97 #
98 # To build all libraries as 32-bit libraries uncomment the following three lines.
99 # export CFLAGS="$CFLAGS -arch i386"
100 # export CXXFLAGS="$CXXFLAGS -arch i386"
101 # export LDFLAGS="$LDFLAGS -arch i386"
102 #
103
104 # Versions to download and install.
105 #
106 # The following libraries and tools are required.
107 #
108 GETTEXT_VERSION=0.18.2
109 GLIB_VERSION=2.36.0
110 PKG_CONFIG_VERSION=0.28
111 ATK_VERSION=2.8.0
112 PANGO_VERSION=1.30.1
113 PNG_VERSION=1.5.14
114 PIXMAN_VERSION=0.26.0
115 CAIRO_VERSION=1.12.2
116 GDK_PIXBUF_VERSION=2.28.0
117 if [ -z "$GTK3" ]; then
118   GTK_VERSION=2.24.17
119 else
120   GTK_VERSION=3.5.2
121 fi
122
123 #
124 # Some package need xz to unpack their current source.
125 # xz is not available on OSX (Snow Leopard).
126 #
127 XZ_VERSION=5.0.4
128
129 # In case we want to build with cmake
130 CMAKE_VERSION=2.8.10.2
131
132 #
133 # The following libraries are optional.
134 # Comment them out if you don't want them, but note that some of
135 # the optional libraries are required by other optional libraries.
136 #
137 LIBSMI_VERSION=0.4.8
138 #
139 # libgpg-error is required for libgcrypt.
140 #
141 LIBGPG_ERROR_VERSION=1.10
142 #
143 # libgcrypt is required for GnuTLS.
144 # XXX - the link for "Libgcrypt source code" at
145 # http://www.gnupg.org/download/#libgcrypt is for 1.5.0, and is a bzip2
146 # file, but http://directory.fsf.org/project/libgcrypt/ lists only
147 # 1.4.6.
148 #
149 LIBGCRYPT_VERSION=1.5.0
150 GNUTLS_VERSION=2.12.19
151 # Stay with Lua 5.1 when updating until the code has been changed
152 # to support 5.2
153 LUA_VERSION=5.1.5
154 PORTAUDIO_VERSION=pa_stable_v19_20111121
155 #
156 # XXX - they appear to have an unversioned gzipped tarball for the
157 # current version; should we just download that, with some other
158 # way of specifying whether to download the GeoIP API?
159 #
160 GEOIP_VERSION=1.4.8
161
162 #
163 # You need Xcode installed to get the compilers.
164 #
165 if [ ! -x /usr/bin/xcodebuild ]; then
166         echo "Please install Xcode first (should be available on DVD or from http://developer.apple.com/xcode/index.php)."
167         exit 1
168 fi
169
170 #
171 # You also need the X11 SDK; with at least some versions of OS X and
172 # Xcode, that is, I think, an optional install.  (Or it might be
173 # installed with X11, but I think *that* is an optional install on
174 # at least some versions of OS X.)
175 #
176 if [ ! -d /usr/X11/include ]; then
177         echo "Please install X11 and the X11 SDK first."
178         exit 1
179 fi
180
181 #
182 # Do we have permission to write in /usr/local?
183 #
184 # If so, assume we have permission to write in its subdirectories.
185 # (If that's not the case, this test needs to check the subdirectories
186 # as well.)
187 #
188 # If not, do "make install" with sudo.
189 #
190 if [ -w /usr/local ]
191 then
192         DO_MAKE_INSTALL="make install"
193 else
194         DO_MAKE_INSTALL="sudo make install"
195 fi
196
197 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig
198
199 #
200 # Do all the downloads and untarring in a subdirectory, so all that
201 # stuff can be removed once we've installed the support libraries.
202 #
203 if [ ! -d macosx-support-libs ]
204 then
205         mkdir macosx-support-libs || exit 1
206 fi
207 cd macosx-support-libs
208
209 # Start with xz: It is the sole download format of glib later than 2.31.2
210 #
211 echo "Downloading, building, and installing xz:"
212 curl -O http://tukaani.org/xz/xz-$XZ_VERSION.tar.bz2 || exit 1
213 tar xf xz-$XZ_VERSION.tar.bz2 || exit 1
214 cd xz-$XZ_VERSION
215 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0" ./configure || exit 1
216 make -j 3 || exit 1
217 $DO_MAKE_INSTALL || exit 1
218 cd ..
219
220 if [ -n "$CMAKE" ]; then
221   echo "Downloading, building, and installing CMAKE:"
222   cmake_dir=`expr $CMAKE_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
223   curl -O http://www.cmake.org/files/v$cmake_dir/cmake-$CMAKE_VERSION.tar.gz || exit 1
224   gzcat cmake-$CMAKE_VERSION.tar.gz | tar xf - || exit 1
225   cd cmake-$CMAKE_VERSION
226   ./bootstrap || exit 1
227   make -j 3 || exit 1
228   $DO_MAKE_INSTALL || exit 1
229   cd ..
230 fi
231
232 #
233 # Start with GNU gettext; GLib requires it, and OS X doesn't have it
234 # or a BSD-licensed replacement.
235 #
236 # At least on Lion with Xcode 4, _FORTIFY_SOURCE gets defined as 2
237 # by default, which causes, for example, stpncpy to be defined as
238 # a hairy macro that collides with the GNU gettext configure script's
239 # attempts to workaround AIX's lack of a declaration for stpncpy,
240 # with the result being a huge train wreck.  Define _FORTIFY_SOURCE
241 # as 0 in an attempt to keep the trains on separate tracks.
242 #
243 echo "Downloading, building, and installing GNU gettext:"
244 curl -O http://ftp.gnu.org/pub/gnu/gettext/gettext-$GETTEXT_VERSION.tar.gz || exit 1
245 tar xf gettext-$GETTEXT_VERSION.tar.gz || exit 1
246 cd gettext-$GETTEXT_VERSION
247 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0" ./configure || exit 1
248 make -j 3 || exit 1
249 $DO_MAKE_INSTALL || exit 1
250 cd ..
251
252 echo "Downloading, building, and installing GLib:"
253 glib_dir=`expr $GLIB_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
254 curl -L -O http://ftp.gnome.org/pub/gnome/sources/glib/$glib_dir/glib-$GLIB_VERSION.tar.xz || exit 1
255 xzcat glib-$GLIB_VERSION.tar.xz | tar xf - || exit 1
256 cd glib-$GLIB_VERSION
257 #
258 # OS X ships with libffi, but doesn't provide its pkg-config file;
259 # explicitly specify LIBFFI_CFLAGS and LIBFFI_LIBS, so the configure
260 # script doesn't try to use pkg-config to get the appropriate
261 # CFLAGS and LIBS.
262 #
263 # And, what's worse, at least with the version of Xcode that comes
264 # with Leopard, /usr/include/ffi/fficonfig.h doesn't define MACOSX,
265 # which causes the build of GLib to fail.  If we don't find
266 # "#define.*MACOSX" in /usr/include/ffi/fficonfig.h, explictly
267 # define it.
268 #
269 if grep -qs '#define.*MACOSX' /usr/include/ffi/fficonfig.h
270 then
271         # It's defined, nothing to do
272         LIBFFI_CFLAGS="$CFLAGS -I/usr/include/ffi" LIBFFI_LIBS="$LDFLAGS -lffi" ./configure || exit 1
273 else
274         CFLAGS="$CFLAGS -DMACOSX" LIBFFI_CFLAGS="$CFLAGS -I/usr/include/ffi" LIBFFI_LIBS="LDFLAGS-lffi" ./configure || exit 1
275 fi
276 make -j 3 || exit 1
277 # Apply patch: we depend on libffi, but pkg-config doesn't get told.
278 patch -p0 <../../macosx-support-lib-patches/glib-pkgconfig.patch || exit 1
279 $DO_MAKE_INSTALL || exit 1
280 cd ..
281
282 echo "Downloading, building, and installing pkg-config:"
283 curl -O http://pkgconfig.freedesktop.org/releases/pkg-config-$PKG_CONFIG_VERSION.tar.gz || exit 1
284 tar xf pkg-config-$PKG_CONFIG_VERSION.tar.gz || exit 1
285 cd pkg-config-$PKG_CONFIG_VERSION
286 # Avoid another pkgconfig call
287 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
288 # ./configure || exit 1
289 make -j 3 || exit 1
290 $DO_MAKE_INSTALL || exit 1
291 cd ..
292
293 #
294 # Now we have reached a point where we can build everything but
295 # the GUI (Wireshark).
296 #
297 # Cairo is part of Mac OS X 10.6 and 10.7.
298 # The *headers* are supplied by 10.5, but the *libraries* aren't, so
299 # we have to build it on 10.5.
300 # GTK+ 3 requires a newer Cairo build than the one that comes with
301 # 10.6, so we build Cairo if we are using GTK+ 3.
302 # In 10.6 and 10.7, it's an X11 library; if we build with "native" GTK+
303 # rather than X11 GTK+, we might have to build and install Cairo.
304 # The major version number of Darwin in 10.5 is 9.
305 #
306 if [[ -n "$GTK3" || $DARWIN_MAJOR_VERSION = "9" ]]; then
307   #
308   # Requirements for Cairo first
309   #
310   # The libpng that comes with the X11 for leopard has a bogus
311   # pkg-config file that lies about where the header files are,
312   # which causes other packages not to be able to find its
313   # headers.
314   #
315   echo "Downloading, building, and installing libpng:"
316   curl -O ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-$PNG_VERSION.tar.xz
317   xzcat libpng-$PNG_VERSION.tar.xz | tar xf - || exit 1
318   cd libpng-$PNG_VERSION
319   ./configure || exit 1
320   make -j 3 || exit 1
321   $DO_MAKE_INSTALL || exit 1
322   cd ..
323
324   #
325   # The libpixman that comes with the X11 for Leopard is too old
326   # to support Cairo's image surface backend feature (which requires
327   # pixman-1 >= 0.22.0).
328   #
329   echo "Downloading, building, and installing pixman:"
330   curl -O http://www.cairographics.org/releases/pixman-$PIXMAN_VERSION.tar.gz
331   gzcat pixman-$PIXMAN_VERSION.tar.gz | tar xf - || exit 1
332   cd pixman-$PIXMAN_VERSION
333   ./configure || exit 1
334   make -j 3 || exit 1
335   $DO_MAKE_INSTALL || exit 1
336   cd ..
337
338   #
339   # And now Cairo itself.
340   #
341   echo "Downloading, building, and installing Cairo:"
342   CAIRO_MAJOR_VERSION="`expr $CAIRO_VERSION : '\([0-9][0-9]*\).*'`"
343   CAIRO_MINOR_VERSION="`expr $CAIRO_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
344   CAIRO_DOTDOT_VERSION="`expr $CAIRO_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
345   if [[ $CAIRO_MAJOR_VERSION -gt 1 ||
346         $CAIRO_MINOR_VERSION -gt 12 ||
347         ($CAIRO_MINOR_VERSION -eq 12 && $CAIRO_DOTDOT_VERSION -ge 2) ]]
348   then
349         #
350         # Starting with Cairo 1.12.2, the tarballs are compressed with
351         # xz rather than gzip.
352         #
353         curl -O http://cairographics.org/releases/cairo-$CAIRO_VERSION.tar.xz || exit 1
354         xzcat cairo-$CAIRO_VERSION.tar.xz | tar xf - || exit 1
355   else
356         curl -O http://cairographics.org/releases/cairo-$CAIRO_VERSION.tar.gz || exit 1
357         tar xf cairo-$CAIRO_VERSION.tar.gz || exit 1
358   fi
359   cd cairo-$CAIRO_VERSION
360   #./configure --enable-quartz=no || exit 1
361   # Maybe follow http://cairographics.org/end_to_end_build_for_mac_os_x/
362   ./configure --enable-quartz=yes || exit 1
363   #
364   # We must avoid the version of libpng that comes with X11; the
365   # only way I've found to force that is to forcibly set INCLUDES
366   # when we do the build, so that this comes before CAIRO_CFLAGS,
367   # which has -I/usr/X11/include added to it before anything
368   # connected to libpng is.
369   #
370   INCLUDES="-I/usr/local/include/libpng15" make -j 3 || exit 1
371   $DO_MAKE_INSTALL || exit 1
372   cd ..
373 fi
374
375 echo "Downloading, building, and installing ATK:"
376 atk_dir=`expr $ATK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
377 curl -O http://ftp.gnome.org/pub/gnome/sources/atk/$atk_dir/atk-$ATK_VERSION.tar.xz || exit 1
378 xzcat atk-$ATK_VERSION.tar.xz | tar xf - || exit 1
379 cd atk-$ATK_VERSION
380 ./configure || exit 1
381 make -j 3 || exit 1
382 $DO_MAKE_INSTALL || exit 1
383 cd ..
384
385 echo "Downloading, building, and installing Pango:"
386 pango_dir=`expr $PANGO_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
387 PANGO_MAJOR_VERSION="`expr $PANGO_VERSION : '\([0-9][0-9]*\).*'`"
388 PANGO_MINOR_VERSION="`expr $PANGO_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
389 if [[ $PANGO_MAJOR_VERSION -gt 1 ||
390       $PANGO_MINOR_VERSION -ge 29 ]]
391 then
392         #
393         # Starting with Pango 1.29, the tarballs are compressed with
394         # xz rather than bzip2.
395         #
396         curl -L -O http://ftp.gnome.org/pub/gnome/sources/pango/$pango_dir/pango-$PANGO_VERSION.tar.xz
397         xzcat pango-$PANGO_VERSION.tar.xz | tar xf - || exit 1
398 else
399         curl -L -O http://ftp.gnome.org/pub/gnome/sources/pango/$pango_dir/pango-$PANGO_VERSION.tar.bz2
400         tar xf pango-$PANGO_VERSION.tar.bz2 || exit 1
401 fi
402 cd pango-$PANGO_VERSION
403 ./configure || exit 1
404 make -j 3 || exit 1
405 $DO_MAKE_INSTALL || exit 1
406 cd ..
407
408 echo "Downloading, building, and installing gdk-pixbuf:"
409 gdk_pixbuf_dir=`expr $GDK_PIXBUF_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
410 curl -L -O http://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/$gdk_pixbuf_dir/gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.xz || exit 1
411 xzcat gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.xz | tar xf - || exit 1
412 cd gdk-pixbuf-$GDK_PIXBUF_VERSION
413 ./configure --without-libtiff --without-libjpeg || exit 1
414 make -j 3 || exit 1
415 $DO_MAKE_INSTALL || exit 1
416 cd ..
417
418 echo "Downloading, building, and installing GTK+:"
419 gtk_dir=`expr $GTK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
420 GTK_MAJOR_VERSION="`expr $GTK_VERSION : '\([0-9][0-9]*\).*'`"
421 GTK_MINOR_VERSION="`expr $GTK_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
422 GTK_DOTDOT_VERSION="`expr $GTK_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
423 if [[ $GTK_MAJOR_VERSION -gt 2 ||
424       $GTK_MINOR_VERSION -gt 24 ||
425       ($GTK_MINOR_VERSION -eq 24 && $GTK_DOTDOT_VERSION -ge 5) ]]
426 then
427         #
428         # Starting with GTK+ 2.24.5, the tarballs are compressed with
429         # xz rather than gzip, in addition to bzip2; use xz, as we've
430         # built and installed it, and as xz compresses better than
431         # bzip2 so the tarballs take less time to download.
432         #
433         curl -L -O http://ftp.gnome.org/pub/gnome/sources/gtk+/$gtk_dir/gtk+-$GTK_VERSION.tar.xz
434         xzcat gtk+-$GTK_VERSION.tar.xz | tar xf - || exit 1
435 else
436         curl -L -O http://ftp.gnome.org/pub/gnome/sources/gtk+/$gtk_dir/gtk+-$GTK_VERSION.tar.bz2
437         tar xf gtk+-$GTK_VERSION.tar.bz2 || exit 1
438 fi
439 cd gtk+-$GTK_VERSION
440 if [ $DARWIN_MAJOR_VERSION -ge "12" ]
441 then
442         #
443         # GTK+ 2.24.10, at least, doesn't build on Mountain Lion with the
444         # CUPS printing backend - either the CUPS API changed incompatibly
445         # or the backend was depending on non-API implementation details.
446         #
447         # Configure it out, on Mountain Lion and later, for now.
448         # (12 is the Darwin major version number in Mountain Lion.)
449         #
450         ./configure --disable-cups || exit 1
451 else
452         ./configure || exit 1
453 fi
454 make -j 3 || exit 1
455 $DO_MAKE_INSTALL || exit 1
456 cd ..
457
458 #
459 # Now we have reached a point where we can build everything including
460 # the GUI (Wireshark), but not with any optional features such as
461 # SNMP OID resolution, some forms of decryption, Lua scripting, playback
462 # of audio, or GeoIP mapping of IP addresses.
463 #
464 # We now conditionally download optional libraries to support them;
465 # the default is to download them all.
466 #
467
468 if [ ! -z $LIBSMI_VERSION ]
469 then
470         echo "Downloading, building, and installing libsmi:"
471         curl -L -O ftp://ftp.ibr.cs.tu-bs.de/pub/local/libsmi/libsmi-$LIBSMI_VERSION.tar.gz || exit 1
472         tar xf libsmi-$LIBSMI_VERSION.tar.gz || exit 1
473         cd libsmi-$LIBSMI_VERSION
474         ./configure || exit 1
475         make -j 3 || exit 1
476         $DO_MAKE_INSTALL || exit 1
477         cd ..
478 fi
479
480 if [ ! -z $LIBGPG_ERROR_VERSION ]
481 then
482         echo "Downloading, building, and installing libgpg-error:"
483         curl -L -O ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 || exit 1
484         bzcat libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 | tar xf - || exit 1
485         cd libgpg-error-$LIBGPG_ERROR_VERSION
486         ./configure || exit 1
487         make -j 3 || exit 1
488         $DO_MAKE_INSTALL || exit 1
489         cd ..
490 fi
491
492 if [ ! -z $LIBGCRYPT_VERSION ]
493 then
494         #
495         # libgpg-error is required for libgcrypt.
496         #
497         if [ -z $LIBGPG_ERROR_VERSION ]
498         then
499                 echo "libgcrypt requires libgpg-error, but you didn't install libgpg-error." 1>&2
500                 exit 1
501         fi
502
503         echo "Downloading, building, and installing libgcrypt:"
504         curl -L -O ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-$LIBGCRYPT_VERSION.tar.gz || exit 1
505         tar xf libgcrypt-$LIBGCRYPT_VERSION.tar.gz || exit 1
506         cd libgcrypt-$LIBGCRYPT_VERSION
507         #
508         # The assembler language code is not compatible with the OS X
509         # x86 assembler (or is it an x86-64 vs. x86-32 issue?).
510         #
511         ./configure --disable-asm || exit 1
512         make -j 3 || exit 1
513         $DO_MAKE_INSTALL || exit 1
514         cd ..
515 fi
516
517 if [ ! -z $GNUTLS_VERSION ]
518 then
519         #
520         # GnuTLS requires libgcrypt (or nettle, in newer versions).
521         #
522         if [ -z $LIBGCRYPT_VERSION ]
523         then
524                 echo "GnuTLS requires libgcrypt, but you didn't install libgcrypt" 1>&2
525                 exit 1
526         fi
527
528         echo "Downloading, building, and installing GnuTLS:"
529         curl -L -O http://ftp.gnu.org/gnu/gnutls/gnutls-$GNUTLS_VERSION.tar.bz2 || exit 1
530         bzcat gnutls-$GNUTLS_VERSION.tar.bz2 | tar xf - || exit 1
531         cd gnutls-$GNUTLS_VERSION
532         #
533         # Use libgcrypt, not nettle.
534         # XXX - is there some reason to prefer nettle?  Or does
535         # Wireshark directly use libgcrypt routines?
536         #
537         ./configure --with-libgcrypt --without-p11-kit || exit 1
538         make -j 3 || exit 1
539         #
540         # The pkgconfig file for GnuTLS says "requires zlib", but OS X,
541         # while it supplies zlib, doesn't supply a pkgconfig file for
542         # it.
543         #
544         # Patch the GnuTLS pkgconfig file not to require zlib.
545         # (If the capabilities of GnuTLS that Wireshark uses don't
546         # depend on building GnuTLS with zlib, an alternative would be
547         # to configure it not to use zlib.)
548         #
549         patch -p0 lib/gnutls.pc.in <../../macosx-support-lib-patches/gnutls-pkgconfig.patch || exit 1
550         $DO_MAKE_INSTALL || exit 1
551         cd ..
552 fi
553
554 if [ ! -z $LUA_VERSION ]
555 then
556         echo "Downloading, building, and installing Lua:"
557         curl -L -O http://www.lua.org/ftp/lua-$LUA_VERSION.tar.gz || exit 1
558         tar xf lua-$LUA_VERSION.tar.gz || exit 1
559         cd lua-$LUA_VERSION
560         make -j 3 macosx || exit 1
561         $DO_MAKE_INSTALL || exit 1
562         cd ..
563 fi
564
565 if [ ! -z $PORTAUDIO_VERSION ]
566 then
567         echo "Downloading, building, and installing PortAudio:"
568         curl -L -O http://www.portaudio.com/archives/$PORTAUDIO_VERSION.tgz || exit 1
569         tar xf $PORTAUDIO_VERSION.tgz || exit 1
570         cd portaudio
571         #
572         # Un-comment an include that's required on Lion.
573         #
574         patch -p0 include/pa_mac_core.h <../../macosx-support-lib-patches/portaudio-pa_mac_core.h.patch
575         #
576         # Disable fat builds - the configure script doesn't work right
577         # with Xcode 4 if you leave them enabled, and we don't build
578         # any other libraries fat (GLib, for example, would be very
579         # hard to build fat), so there's no advantage to having PortAudio
580         # built fat.
581         #
582         # Set the minimum OS X version to 10.4, to suppress some
583         # deprecation warnings.
584         #
585         CFLAGS="$CFLAGS -mmacosx-version-min=10.4" ./configure --disable-mac-universal || exit 1
586         make -j 3 || exit 1
587         $DO_MAKE_INSTALL || exit 1
588         cd ..
589 fi
590
591 if [ ! -z $GEOIP_VERSION ]
592 then
593         echo "Downloading, building, and installing GeoIP API:"
594         curl -L -O http://geolite.maxmind.com/download/geoip/api/c/GeoIP-$GEOIP_VERSION.tar.gz || exit 1
595         tar xf GeoIP-$GEOIP_VERSION.tar.gz || exit 1
596         cd GeoIP-$GEOIP_VERSION
597         ./configure || exit 1
598         #
599         # Grr.  Their man pages "helpfully" have an ISO 8859-1
600         # copyright symbol in the copyright notice, but OS X's
601         # default character encoding is UTF-8.  sed on Mountain
602         # Lion barfs at the "illegal character sequence" represented
603         # by an ISO 8859-1 copyright symbol, as it's not a valid
604         # UTF-8 sequence.
605         #
606         # iconv the relevant man pages into UTF-8.
607         #
608         for i in geoipupdate.1.in geoiplookup6.1.in geoiplookup.1.in
609         do
610                 iconv -f iso8859-1 -t utf-8 man/"$i" >man/"$i".tmp &&
611                     mv man/"$i".tmp man/"$i"
612         done
613         make -j 3 || exit 1
614         $DO_MAKE_INSTALL || exit 1
615         cd ..
616 fi
617
618 echo ""
619
620 echo "You are now prepared to build Wireshark. To do so do:"
621 echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig"
622 echo ""
623 if [ -n "$CMAKE" ]; then
624   echo "mkdir build; cd build"
625   echo "cmake .."
626   echo
627   echo "or"
628   echo
629 fi
630 echo "./autogen.sh"
631 echo "mkdir build; cd build"
632 echo "../configure"
633 echo ""
634 echo "make -j 3"
635 echo "make install"
636
637 echo ""
638
639 echo "Make sure you are allowed capture access to the network devices"
640 echo "See: http://wiki.wireshark.org/CaptureSetup/CapturePrivileges"
641
642 echo ""
643
644 exit 0