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
11 # To set up a GTK3 environment
16 # Versions to download and install.
18 # The following libraries are required.
20 GETTEXT_VERSION=0.18.1.1
23 # pkg-config 0.26 appears to have broken the "we have our own GLib"
24 # stuff, even if you explicitly set GLIB_CFLAGS and GLIB_LIBS.
25 # Life's too short to work around the circular dependency in a script,
26 # so we use 0.25 instead.
28 PKG_CONFIG_VERSION=0.26
34 GDK_PIXBUF_VERSION=2.25.0
35 if [ -z "$GTK3" ]; then
42 # Some package need xz to unpack their current source.
43 # xz is not available on OSX (Snow Leopard).
47 # In case we want to build with cmake
51 # The following libraries are optional.
52 # Comment them out if you don't want them, but note that some of
53 # the optional libraries are required by other optional libraries.
57 # libgpg-error is required for libgcrypt.
59 LIBGPG_ERROR_VERSION=1.10
61 # libgcrypt is required for GnuTLS.
62 # XXX - the link for "Libgcrypt source code" at
63 # http://www.gnupg.org/download/#libgcrypt is for 1.5.0, and is a bzip2
64 # file, but http://directory.fsf.org/project/libgcrypt/ lists only
67 LIBGCRYPT_VERSION=1.4.6
70 PORTAUDIO_VERSION=pa_stable_v19_20111121
72 # XXX - they appear to have an unversioned gzipped tarball for the
73 # current version; should we just download that, with some other
74 # way of specifying whether to download the GeoIP API?
79 # You need Xcode installed to get the compilers.
81 if [ ! -x /usr/bin/xcodebuild ]; then
82 echo "Please install Xcode first (should be available on DVD or from http://developer.apple.com/xcode/index.php)."
87 # You also need the X11 SDK; with at least some versions of OS X and
88 # Xcode, that is, I think, an optional install. (Or it might be
89 # installed with X11, but I think *that* is an optional install on
90 # at least some versions of OS X.)
92 if [ ! -d /usr/X11/include ]; then
93 echo "Please install X11 and the X11 SDK first."
98 # Do we have permission to write in /usr/local?
100 # If so, assume we have permission to write in its subdirectories.
101 # (If that's not the case, this test needs to check the subdirectories
104 # If not, do "make install" with sudo.
108 DO_MAKE_INSTALL="make install"
110 DO_MAKE_INSTALL="sudo make install"
113 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig
116 # Do all the downloads and untarring in a subdirectory, so all that
117 # stuff can be removed once we've installed the support libraries.
119 if [ ! -d macosx-support-libs ]
121 mkdir macosx-support-libs || exit 1
123 cd macosx-support-libs
125 # Start with xz: It is the sole download format of glib later than 2.31.2
127 echo "Downloading, building, and installing xz:"
128 curl -O http://tukaani.org/xz/xz-$XZ_VERSION.tar.bz2 || exit 1
129 tar xf xz-$XZ_VERSION.tar.bz2 || exit 1
131 CFLAGS="-D_FORTIFY_SOURCE=0" ./configure || exit 1
133 $DO_MAKE_INSTALL || exit 1
136 if [ -n "$CMAKE" ]; then
137 echo "Downloading, building, and installing CMAKE:"
138 cmake_dir=`expr $CMAKE_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
139 curl -O http://www.cmake.org/files/v$cmake_dir/cmake-$CMAKE_VERSION.tar.gz || exit 1
140 gzcat cmake-$CMAKE_VERSION.tar.gz | tar xf - || exit 1
141 cd cmake-$CMAKE_VERSION
142 ./bootstrap || exit 1
144 $DO_MAKE_INSTALL || exit 1
149 # Start with GNU gettext; GLib requires it, and OS X doesn't have it
150 # or a BSD-licensed replacement.
152 # At least on Lion with Xcode 4, _FORTIFY_SOURCE gets defined as 2
153 # by default, which causes, for example, stpncpy to be defined as
154 # a hairy macro that collides with the GNU gettext configure script's
155 # attempts to workaround AIX's lack of a declaration for stpncpy,
156 # with the result being a huge train wreck. Define _FORTIFY_SOURCE
157 # as 0 in an attempt to keep the trains on separate tracks.
159 echo "Downloading, building, and installing GNU gettext:"
160 curl -O http://ftp.gnu.org/pub/gnu/gettext/gettext-$GETTEXT_VERSION.tar.gz || exit 1
161 tar xf gettext-$GETTEXT_VERSION.tar.gz || exit 1
162 cd gettext-$GETTEXT_VERSION
163 CFLAGS="-D_FORTIFY_SOURCE=0" ./configure || exit 1
165 $DO_MAKE_INSTALL || exit 1
168 echo "Downloading, building, and installing GLib:"
169 glib_dir=`expr $GLIB_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
170 curl -L -O http://ftp.gnome.org/pub/gnome/sources/glib/$glib_dir/glib-$GLIB_VERSION.tar.xz || exit 1
171 xzcat glib-$GLIB_VERSION.tar.xz | tar xf - || exit 1
172 cd glib-$GLIB_VERSION
174 # OS X ships with libffi, but doesn't provide its pkg-config file;
175 # explicitly specify LIBFFI_CFLAGS and LIBFFI_LIBS, so the configure
176 # script doesn't try to use pkg-config to get the appropriate
179 LIBFFI_CFLAGS="-I/usr/include/ffi" LIBFFI_LIBS="-L/usr/lib" ./configure || exit 1
181 # Mac OS X on 64-bit platforms provides libiconv, but in a form that
184 patch -p1 < ../../macosx-support-lib-patches/glib-gconvert.patch || exit 1
186 # Apply patch: we depend on libffi, but pkg-config doesn't get told.
187 patch -p0 <../../macosx-support-lib-patches/glib-pkgconfig.patch || exit 1
188 $DO_MAKE_INSTALL || exit 1
191 echo "Downloading, building, and installing pkg-config:"
192 curl -O http://pkgconfig.freedesktop.org/releases/pkg-config-$PKG_CONFIG_VERSION.tar.gz || exit 1
193 tar xf pkg-config-$PKG_CONFIG_VERSION.tar.gz || exit 1
194 cd pkg-config-$PKG_CONFIG_VERSION
195 # Avoid another pkgconfig call
196 GLIB_CFLAGS="-I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include" GLIB_LIBS="-L/usr/local/lib -lglib-2.0 -lintl" ./configure || exit 1
197 # ./configure || exit 1
199 $DO_MAKE_INSTALL || exit 1
203 # Now we have reached a point where we can build everything but
204 # the GUI (Wireshark).
207 if [ -n "$GTK3" ]; then
209 # Cairo is part of Mac OS X 10.6 (and, I think, 10.5).
210 # However, it's an X11 library; if we build with "native" GTK+ rather
211 # than X11 GTK+, we might have to build and install Cairo.
212 # GTK+-3 requires a newer cairo build as well.
214 # Requirements for cairo first
216 echo "Downloading, building, and installing libpng:"
217 curl -O ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-$PNG_VERSION.tar.xz
218 xzcat libpng-$PNG_VERSION.tar.xz | tar xf - || exit 1
219 cd libpng-$PNG_VERSION
220 ./configure || exit 1
222 $DO_MAKE_INSTALL || exit 1
225 echo "Downloading, building, and installing pixman:"
226 curl -O http://www.cairographics.org/releases/pixman-$PIXMAN_VERSION.tar.gz
227 gzcat pixman-$PIXMAN_VERSION.tar.gz | tar xf - || exit 1
228 cd pixman-$PIXMAN_VERSION
229 ./configure || exit 1
231 $DO_MAKE_INSTALL || exit 1
235 # And now cairo itself.
237 echo "Downloading, building, and installing Cairo:"
238 curl -O http://cairographics.org/releases/cairo-$CAIRO_VERSION.tar.gz || exit 1
239 tar xvfz cairo-$CAIRO_VERSION.tar.gz || exit 1
240 cd cairo-$CAIRO_VERSION
241 #./configure --enable-quartz=no || exit 1
242 # Maybe follow http://cairographics.org/end_to_end_build_for_mac_os_x/
243 ./configure --enable-quartz=yes || exit 1
245 $DO_MAKE_INSTALL || exit 1
249 echo "Downloading, building, and installing ATK:"
250 atk_dir=`expr $ATK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
251 curl -O http://ftp.gnome.org/pub/gnome/sources/atk/$atk_dir/atk-$ATK_VERSION.tar.bz2 || exit 1
252 bzcat atk-$ATK_VERSION.tar.bz2 | tar xf - || exit 1
254 ./configure || exit 1
256 $DO_MAKE_INSTALL || exit 1
259 echo "Downloading, building, and installing Pango:"
260 pango_dir=`expr $PANGO_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
261 curl -L -O http://ftp.gnome.org/pub/gnome/sources/pango/$pango_dir/pango-$PANGO_VERSION.tar.bz2
262 bzcat pango-$PANGO_VERSION.tar.bz2 | tar xf - || exit 1
263 cd pango-$PANGO_VERSION
264 ./configure || exit 1
266 $DO_MAKE_INSTALL || exit 1
269 echo "Downloading, building, and installing gdk-pixbuf:"
270 gdk_pixbuf_dir=`expr $GDK_PIXBUF_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
271 curl -L -O http://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/$gdk_pixbuf_dir/gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.xz || exit 1
272 xzcat gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.xz | tar xf - || exit 1
273 cd gdk-pixbuf-$GDK_PIXBUF_VERSION
274 ./configure --without-libtiff --without-libjpeg || exit 1
276 $DO_MAKE_INSTALL || exit 1
279 echo "Downloading, building, and installing GTK+:"
280 gtk_dir=`expr $GTK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
281 curl -L -O http://ftp.gnome.org/pub/gnome/sources/gtk+/$gtk_dir/gtk+-$GTK_VERSION.tar.xz
282 xzcat gtk+-$GTK_VERSION.tar.xz | tar xf - || exit 1
284 ./configure || exit 1
286 $DO_MAKE_INSTALL || exit 1
290 # Now we have reached a point where we can build everything including
291 # the GUI (Wireshark), but not with any optional features such as
292 # SNMP OID resolution, some forms of decryption, Lua scripting, playback
293 # of audio, or GeoIP mapping of IP addresses.
295 # We now conditionally download optional libraries to support them;
296 # the default is to download them all.
299 if [ ! -z $LIBSMI_VERSION ]
301 echo "Downloading, building, and installing libsmi:"
302 curl -L -O ftp://ftp.ibr.cs.tu-bs.de/pub/local/libsmi/libsmi-$LIBSMI_VERSION.tar.gz || exit 1
303 tar xf libsmi-$LIBSMI_VERSION.tar.gz || exit 1
304 cd libsmi-$LIBSMI_VERSION
305 ./configure || exit 1
307 $DO_MAKE_INSTALL || exit 1
311 if [ ! -z $LIBGPG_ERROR_VERSION ]
313 echo "Downloading, building, and installing libgpg-error:"
314 curl -L -O ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 || exit 1
315 bzcat libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 | tar xf - || exit 1
316 cd libgpg-error-$LIBGPG_ERROR_VERSION
317 ./configure || exit 1
319 $DO_MAKE_INSTALL || exit 1
323 if [ ! -z $LIBGCRYPT_VERSION ]
326 # libgpg-error is required for libgcrypt.
328 if [ -z $LIBGPG_ERROR_VERSION ]
330 echo "libgcrypt requires libgpg-error, but you didn't install libgpg-error." 1>&2
334 echo "Downloading, building, and installing libgcrypt:"
335 curl -L -O ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-$LIBGCRYPT_VERSION.tar.gz || exit 1
336 tar xf libgcrypt-$LIBGCRYPT_VERSION.tar.gz || exit 1
337 cd libgcrypt-$LIBGCRYPT_VERSION
339 # The assembler language code is not compatible with the OS X
340 # x86 assembler (or is it an x86-64 vs. x86-32 issue?).
342 ./configure --disable-asm || exit 1
344 $DO_MAKE_INSTALL || exit 1
348 if [ ! -z $GNUTLS_VERSION ]
351 # GnuTLS requires libgcrypt (or nettle, in newer versions).
353 if [ -z $LIBGCRYPT_VERSION ]
355 echo "GnuTLS requires libgcrypt, but you didn't install libgcrypt" 1>&2
359 echo "Downloading, building, and installing GnuTLS:"
360 curl -L -O http://ftp.gnu.org/gnu/gnutls/gnutls-$GNUTLS_VERSION.tar.bz2 || exit 1
361 bzcat gnutls-$GNUTLS_VERSION.tar.bz2 | tar xf - || exit 1
362 cd gnutls-$GNUTLS_VERSION
364 # Use libgcrypt, not nettle.
365 # XXX - is there some reason to prefer nettle? Or does
366 # Wireshark directly use libgcrypt routines?
368 ./configure --with-libgcrypt || exit 1
371 # The pkgconfig file for GnuTLS says "requires zlib", but OS X,
372 # while it supplies zlib, doesn't supply a pkgconfig file for
375 # Patch the GnuTLS pkgconfig file not to require zlib.
376 # (If the capabilities of GnuTLS that Wireshark uses don't
377 # depend on building GnuTLS with zlib, an alternative would be
378 # to configure it not to use zlib.)
380 patch -p0 lib/gnutls.pc <../../macosx-support-lib-patches/gnutls-pkgconfig.patch || exit 1
381 $DO_MAKE_INSTALL || exit 1
385 if [ ! -z $LUA_VERSION ]
387 echo "Downloading, building, and installing Lua:"
388 curl -L -O http://www.lua.org/ftp/lua-$LUA_VERSION.tar.gz || exit 1
389 tar xf lua-$LUA_VERSION.tar.gz || exit 1
391 make -j 3 macosx || exit 1
392 $DO_MAKE_INSTALL || exit 1
396 if [ ! -z $PORTAUDIO_VERSION ]
398 echo "Downloading, building, and installing PortAudio:"
399 curl -L -O http://www.portaudio.com/archives/$PORTAUDIO_VERSION.tgz || exit 1
400 tar xf $PORTAUDIO_VERSION.tgz || exit 1
402 ./configure || exit 1
404 $DO_MAKE_INSTALL || exit 1
408 if [ ! -z $GEOIP_VERSION ]
410 echo "Downloading, building, and installing GeoIP API:"
411 curl -L -O http://geolite.maxmind.com/download/geoip/api/c/GeoIP-$GEOIP_VERSION.tar.gz || exit 1
412 tar xf GeoIP-$GEOIP_VERSION.tar.gz || exit 1
413 cd GeoIP-$GEOIP_VERSION
414 ./configure || exit 1
416 $DO_MAKE_INSTALL || exit 1
422 echo "You are now prepared to build Wireshark. To do so do:"
423 echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig"
425 if [ -n "$CMAKE" ]; then
426 echo "mkdir build; cd build"
433 echo "mkdir build; cd build"
441 echo "Make sure you are allowed capture access to the network devices"
442 echo "See: http://wiki.wireshark.org/CaptureSetup/CapturePrivileges"