2 # Setup development environment on Mac OS X (tested with 10.6.8 and Xcode 3.2.6)
4 # Copyright 2011 Michael Tuexen, Joerg Mayer, Guy Harris (see AUTHORS file)
6 # Wireshark - Network traffic analyzer
7 # By Gerald Combs <gerald@wireshark.org>
8 # Copyright 1998 Gerald Combs
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License
12 # as published by the Free Software Foundation; either version 2
13 # of the License, or (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 # To build all libraries as 32-bit libraries uncomment the following three lines.
31 # export CFLAGS="$CFLAGS -arch i386"
32 # export CXXFLAGS="$CXXFLAGS -arch i386"
33 # export LDFLAGS="$LDFLAGS -arch i386"
35 # and change "macx-clang" to "macx-clang-32" in the line below.
37 # Note: when building against the 10.6 SDK, clang fails, because there's
38 # a missing libstdc++.dylib in the SDK; this does not bother g++, however.
40 #TARGET_PLATFORM=macx-g++
41 TARGET_PLATFORM=macx-clang
44 # Versions of packages to download and install.
48 # Some packages need xz to unpack their current source.
49 # xz is not yet provided with OS X.
54 # In case we want to build with cmake.
56 CMAKE_VERSION=2.8.12.2
59 # The following libraries and tools are required even to build only TShark.
61 GETTEXT_VERSION=0.18.2
63 PKG_CONFIG_VERSION=0.28
66 # One or more of the following libraries are required to build Wireshark.
68 # If you don't want to build with Qt, comment out the QT_VERSION= line.
70 # If you want to build with GTK+ 2, comment out the GTK_VERSION=3.* line
71 # and un-comment the GTK_VERSION=2.* line.
73 # If you don't want to build with GTK+ at all, comment out both lines.
78 if [ "$GTK_VERSION" ]; then
80 # We'll be building GTK+, so we need some additional libraries.
82 GTK_MAJOR_VERSION="`expr $GTK_VERSION : '\([0-9][0-9]*\).*'`"
83 GTK_MINOR_VERSION="`expr $GTK_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
84 GTK_DOTDOT_VERSION="`expr $GTK_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
91 GDK_PIXBUF_VERSION=2.28.0
94 # In case we want to build GTK *and* we don't have Apple's X11 SDK installed
95 # we may want to install XQuartz. The version will only be used in the printing
96 # of a URL, the package will not be installed.
100 # The following libraries are optional.
101 # Comment them out if you don't want them, but note that some of
102 # the optional libraries are required by other optional libraries.
106 # libgpg-error is required for libgcrypt.
108 LIBGPG_ERROR_VERSION=1.10
110 # libgcrypt is required for GnuTLS.
111 # XXX - the link for "Libgcrypt source code" at
112 # http://www.gnupg.org/download/#libgcrypt is for 1.5.0, and is a bzip2
113 # file, but http://directory.fsf.org/project/libgcrypt/ lists only
116 LIBGCRYPT_VERSION=1.5.0
117 GNUTLS_VERSION=2.12.19
118 # Default to 5.2 now, unless user overrides it later
120 PORTAUDIO_VERSION=pa_stable_v19_20111121
122 # XXX - they appear to have an unversioned gzipped tarball for the
123 # current version; should we just download that, with some other
124 # way of specifying whether to download the GeoIP API?
130 DARWIN_MAJOR_VERSION=`uname -r | sed 's/\([0-9]*\).*/\1/'`
133 # GNU autotools; they're provided with releases up to Snow Leopard, but
134 # not in later releases.
136 if [[ $DARWIN_MAJOR_VERSION -gt 10 ]]; then
137 AUTOCONF_VERSION=2.69
138 AUTOMAKE_VERSION=1.13.3
139 LIBTOOL_VERSION=2.4.2
143 echo "Downloading, building, and installing xz:"
144 [ -f xz-$XZ_VERSION.tar.bz2 ] || curl -O http://tukaani.org/xz/xz-$XZ_VERSION.tar.bz2 || exit 1
145 bzcat xz-$XZ_VERSION.tar.bz2 | tar xf - || exit 1
147 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0" ./configure || exit 1
148 make $MAKE_BUILD_OPTS || exit 1
149 $DO_MAKE_INSTALL || exit 1
151 touch xz-$XZ_VERSION-done
155 echo "Uninstalling xz:"
156 cd xz-$installed_xz_version
157 $DO_MAKE_UNINSTALL || exit 1
158 make distclean || exit 1
160 rm xz-$installed_xz_version-done
164 echo "Downloading, building and installing GNU autoconf..."
165 [ -f autoconf-$AUTOCONF_VERSION.tar.xz ] || curl -O ftp://ftp.gnu.org/gnu/autoconf/autoconf-$AUTOCONF_VERSION.tar.xz || exit 1
166 xzcat autoconf-$AUTOCONF_VERSION.tar.xz | tar xf - || exit 1
167 cd autoconf-$AUTOCONF_VERSION
168 ./configure || exit 1
169 make $MAKE_BUILD_OPTS || exit 1
170 $DO_MAKE_INSTALL || exit 1
172 touch autoconf-$AUTOCONF_VERSION-done
175 uninstall_autoconf() {
176 echo "Uninstalling GNU autoconf:"
177 cd autoconf-$installed_autoconf_version
178 $DO_MAKE_UNINSTALL || exit 1
179 make distclean || exit 1
181 rm autoconf-$installed_autoconf_version-done
185 echo "Downloading, building and installing GNU automake..."
186 [ -f automake-$AUTOMAKE_VERSION.tar.xz ] || curl -O ftp://ftp.gnu.org/gnu/automake/automake-$AUTOMAKE_VERSION.tar.xz || exit 1
187 xzcat automake-$AUTOMAKE_VERSION.tar.xz | tar xf - || exit 1
188 cd automake-$AUTOMAKE_VERSION
189 ./configure || exit 1
190 make $MAKE_BUILD_OPTS || exit 1
191 $DO_MAKE_INSTALL || exit 1
193 touch automake-$AUTOMAKE_VERSION-done
196 uninstall_automake() {
197 echo "Uninstalling GNU automake:"
198 cd automake-$installed_automake_version
199 $DO_MAKE_UNINSTALL || exit 1
200 make distclean || exit 1
202 rm automake-$installed_automake_version-done
206 echo "Downloading, building and installing GNU libtool..."
207 [ -f libtool-$LIBTOOL_VERSION.tar.xz ] || curl -O ftp://ftp.gnu.org/gnu/libtool/libtool-$LIBTOOL_VERSION.tar.xz || exit 1
208 xzcat libtool-$LIBTOOL_VERSION.tar.xz | tar xf - || exit 1
209 cd libtool-$LIBTOOL_VERSION
210 ./configure || exit 1
211 make $MAKE_BUILD_OPTS || exit 1
212 $DO_MAKE_INSTALL || exit 1
213 $DO_MV /usr/local/bin/libtool /usr/local/bin/glibtool
214 $DO_MV /usr/local/bin/libtoolize /usr/local/bin/glibtoolize
216 touch libtool-$LIBTOOL_VERSION-done
219 uninstall_libtool() {
220 echo "Uninstalling GNU libtool:"
221 cd libtool-$installed_libtool_version
222 $DO_MV /usr/local/bin/glibtool /usr/local/bin/libtool
223 $DO_MV /usr/local/bin/glibtoolize /usr/local/bin/libtoolize
224 $DO_MAKE_UNINSTALL || exit 1
225 make distclean || exit 1
227 rm libtool-$installed_libtool_version-done
231 echo "Downloading and installing CMake:"
232 cmake_dir=`expr $CMAKE_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
234 # NOTE: the "64" in "Darwin64" doesn't mean "64-bit-only"; the
235 # package in question supports both 32-bit and 64-bit x86.
237 [ -f cmake-$CMAKE_VERSION-Darwin64-universal.dmg ] || curl -O http://www.cmake.org/files/v$cmake_dir/cmake-$CMAKE_VERSION-Darwin64-universal.dmg || exit 1
238 sudo hdiutil attach http://www.cmake.org/files/v2.8/cmake-$CMAKE_VERSION-Darwin64-universal.dmg || exit 1
239 sudo installer -target / -pkg /Volumes/cmake-$CMAKE_VERSION-Darwin64-universal/cmake-$CMAKE_VERSION-Darwin64-universal.pkg || exit 1
240 sudo hdiutil detach /Volumes/cmake-$CMAKE_VERSION-Darwin64-universal
241 touch cmake-$CMAKE_VERSION-done
245 echo "Uninstalling CMake:"
246 sudo rm -rf "/Applications/CMake "`echo "$installed_cmake_version" | sed 's/\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\1.\2-\3/'`.app
247 sudo rm /usr/bin/ccmake
248 sudo rm /usr/bin/cmake
249 sudo rm /usr/bin/cmake-gui
250 sudo rm /usr/bin/cmakexbuild
251 sudo rm /usr/bin/cpack
252 sudo rm /usr/bin/ctest
253 sudo pkgutil --forget com.Kitware.CMake
254 rm cmake-$installed_cmake_version-done
258 echo "Downloading, building, and installing GNU gettext:"
259 [ -f gettext-$GETTEXT_VERSION.tar.gz ] || curl -O http://ftp.gnu.org/pub/gnu/gettext/gettext-$GETTEXT_VERSION.tar.gz || exit 1
260 gzcat gettext-$GETTEXT_VERSION.tar.gz | tar xf - || exit 1
261 cd gettext-$GETTEXT_VERSION
262 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
263 make $MAKE_BUILD_OPTS || exit 1
264 $DO_MAKE_INSTALL || exit 1
266 touch gettext-$GETTEXT_VERSION-done
269 uninstall_gettext() {
270 echo "Uninstalling GNU gettext:"
271 cd gettext-$installed_gettext_version
272 $DO_MAKE_UNINSTALL || exit 1
273 make distclean || exit 1
275 rm gettext-$installed_gettext_version-done
278 install_pkg_config() {
279 echo "Downloading, building, and installing pkg-config:"
280 [ -f pkg-config-$PKG_CONFIG_VERSION.tar.gz ] || curl -O http://pkgconfig.freedesktop.org/releases/pkg-config-$PKG_CONFIG_VERSION.tar.gz || exit 1
281 gzcat pkg-config-$PKG_CONFIG_VERSION.tar.gz | tar xf - || exit 1
282 cd pkg-config-$PKG_CONFIG_VERSION
283 ./configure --with-internal-glib || exit 1
284 make $MAKE_BUILD_OPTS || exit 1
285 $DO_MAKE_INSTALL || exit 1
287 touch pkg-config-$PKG_CONFIG_VERSION-done
290 uninstall_pkg_config() {
291 echo "Uninstalling pkg-config:"
292 cd pkg-config-$installed_pkg_config_version
293 $DO_MAKE_UNINSTALL || exit 1
294 make distclean || exit 1
296 rm pkg-config-$installed_pkg_config_version-done
300 echo "Downloading, building, and installing GLib:"
301 glib_dir=`expr $GLIB_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
302 GLIB_MAJOR_VERSION="`expr $GLIB_VERSION : '\([0-9][0-9]*\).*'`"
303 GLIB_MINOR_VERSION="`expr $GLIB_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
304 GLIB_DOTDOT_VERSION="`expr $GLIB_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
305 if [[ $GLIB_MAJOR_VERSION -gt 2 ||
306 $GLIB_MINOR_VERSION -gt 28 ||
307 ($GLIB_MINOR_VERSION -eq 28 && $GLIB_DOTDOT_VERSION -ge 8) ]]
310 # Starting with GLib 2.28.8, xz-compressed tarballs are available.
312 [ -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
313 xzcat glib-$GLIB_VERSION.tar.xz | tar xf - || exit 1
315 [ -f glib-$GLIB_VERSION.tar.bz2 ] || curl -L -O http://ftp.gnome.org/pub/gnome/sources/glib/$glib_dir/glib-$GLIB_VERSION.tar.bz2 || exit 1
316 bzcat glib-$GLIB_VERSION.tar.bz2 | tar xf - || exit 1
318 cd glib-$GLIB_VERSION
320 # OS X ships with libffi, but doesn't provide its pkg-config file;
321 # explicitly specify LIBFFI_CFLAGS and LIBFFI_LIBS, so the configure
322 # script doesn't try to use pkg-config to get the appropriate
323 # C flags and loader flags.
325 # And, what's worse, at least with the version of Xcode that comes
326 # with Leopard, /usr/include/ffi/fficonfig.h doesn't define MACOSX,
327 # which causes the build of GLib to fail. If we don't find
328 # "#define.*MACOSX" in /usr/include/ffi/fficonfig.h, explicitly
331 # While we're at it, suppress -Wformat-nonliteral to avoid a case
332 # where clang's stricter rules on when not to complain about
333 # non-literal format arguments cause it to complain about code
334 # that's safe but it wasn't told that. See my comment #25 in
337 # https://bugzilla.gnome.org/show_bug.cgi?id=691608#c25
339 # First, determine where the system include files are. (It's not
340 # necessarily /usr/include.) There's a bit of a greasy hack here;
341 # pre-5.x versions of the developer tools don't support the
342 # --show-sdk-path option, and will produce no output, so includedir
343 # will be set to /usr/include (in those older versions of the
344 # developer tools, there is a /usr/include directory).
346 includedir=`xcrun --show-sdk-path 2>/dev/null`/usr/include
347 if grep -qs '#define.*MACOSX' $includedir/ffi/fficonfig.h
349 # It's defined, nothing to do
350 LIBFFI_CFLAGS="-I $includedir/ffi" LIBFFI_LIBS="-lffi" CFLAGS="$CFLAGS -Wno-format-nonliteral $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS -Wno-format-nonliteral $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
352 LIBFFI_CFLAGS="-I $includedir/ffi" LIBFFI_LIBS="-lffi" CFLAGS="$CFLAGS -DMACOSX -Wno-format-nonliteral $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS -DMACOSX -Wno-format-nonliteral $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
356 # Apply the fix to GNOME bug 529806:
358 # https://bugzilla.gnome.org/show_bug.cgi?id=529806
360 # if we have a version of GLib prior to 2.30.
362 if [[ $GLIB_MAJOR_VERSION -eq 2 && $GLIB_MINOR_VERSION -le 30 ]]
364 patch -p0 <../../macosx-support-lib-patches/glib-gconvert.c.patch || exit 1
366 make $MAKE_BUILD_OPTS || exit 1
367 $DO_MAKE_INSTALL || exit 1
369 touch glib-$GLIB_VERSION-done
373 echo "Uninstalling GLib:"
374 cd glib-$installed_glib_version
375 $DO_MAKE_UNINSTALL || exit 1
376 make distclean || exit 1
378 rm glib-$installed_glib_version-done
382 echo "Downloading, building, and installing Qt:"
383 QT_MAJOR_VERSION="`expr $QT_VERSION : '\([0-9][0-9]*\).*'`"
384 QT_MINOR_VERSION="`expr $QT_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
385 QT_DOTDOT_VERSION="`expr $QT_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
386 QT_MAJOR_MINOR_VERSION=$QT_MAJOR_VERSION.$QT_MINOR_VERSION
388 # What you get for this URL might just be a 302 Found reply, so use
389 # -L so we get redirected.
391 curl -L -O http://download.qt-project.org/official_releases/qt/$QT_MAJOR_MINOR_VERSION/$QT_VERSION/single/qt-everywhere-opensource-src-$QT_VERSION.tar.gz
393 # Qt 5.1.x sets QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
394 # in qtbase/mkspecs/$TARGET_PLATFORM/qmake.conf
395 # We may need to adjust this manually in the future.
397 # The -no-c++11 flag is needed to work around
398 # https://bugreports.qt-project.org/browse/QTBUG-30487
400 tar xf qt-everywhere-opensource-src-$QT_VERSION.tar.gz
401 cd qt-everywhere-opensource-src-$QT_VERSION
403 # We don't build Qt in its Full Shining Glory, as we don't need all
404 # of its components, and it takes *forever* to build in that form.
406 # Qt 5.2.0 beta1 fails to build on OS X without -no-xcb due to bug
409 # Qt 5.x fails to build on OS X with -no-opengl due to bug
412 ./configure -v $qt_sdk_arg -platform $TARGET_PLATFORM \
413 -opensource -confirm-license -no-c++11 -no-dbus \
414 -no-sql-sqlite -no-xcb -nomake examples \
415 -skip qtdoc -skip qtquickcontrols -skip qtwebkit \
416 -skip qtwebkit-examples -skip qtxmlpatterns
418 $DO_MAKE_INSTALL || exit 1
420 touch qt-$QT_VERSION-done
424 echo "Uninstalling Qt:"
425 cd qt-everywhere-opensource-src-$installed_qt_version
426 $DO_MAKE_UNINSTALL || exit 1
428 # XXX - "make distclean" doesn't work. qmake sure does a
429 # good job of constructing Makefiles that work correctly....
431 #make distclean || exit 1
433 rm qt-$installed_qt_version-done
437 echo "Downloading, building, and installing libpng:"
439 # The FTP site puts libpng x.y.* into a libpngxy directory.
441 subdir=`echo $PNG_VERSION | sed 's/\([1-9][0-9]*\)\.\([1-9][0-9]*\).*/libpng\1\2'/`
442 [ -f libpng-$PNG_VERSION.tar.xz ] || curl -O ftp://ftp.simplesystems.org/pub/libpng/png/src/$subdir/libpng-$PNG_VERSION.tar.xz
443 xzcat libpng-$PNG_VERSION.tar.xz | tar xf - || exit 1
444 cd libpng-$PNG_VERSION
445 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
446 make $MAKE_BUILD_OPTS || exit 1
447 $DO_MAKE_INSTALL || exit 1
449 touch libpng-$PNG_VERSION-done
453 echo "Uninstalling libpng:"
454 cd libpng-$installed_libpng_version
455 $DO_MAKE_UNINSTALL || exit 1
456 make distclean || exit 1
458 rm libpng-$installed_libpng_version-done
461 install_libpixman() {
462 echo "Downloading, building, and installing pixman:"
463 [ -f pixman-$PIXMAN_VERSION.tar.gz ] || curl -O http://www.cairographics.org/releases/pixman-$PIXMAN_VERSION.tar.gz
464 gzcat pixman-$PIXMAN_VERSION.tar.gz | tar xf - || exit 1
465 cd pixman-$PIXMAN_VERSION
466 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
467 make $MAKE_BUILD_OPTS || exit 1
468 $DO_MAKE_INSTALL || exit 1
470 touch pixman-$PIXMAN_VERSION-done
474 echo "Uninstalling pixman:"
475 cd pixman-$installed_pixman_version
476 $DO_MAKE_UNINSTALL || exit 1
477 make distclean || exit 1
479 rm pixman-$installed_pixman_version-done
483 echo "Downloading, building, and installing Cairo:"
484 CAIRO_MAJOR_VERSION="`expr $CAIRO_VERSION : '\([0-9][0-9]*\).*'`"
485 CAIRO_MINOR_VERSION="`expr $CAIRO_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
486 CAIRO_DOTDOT_VERSION="`expr $CAIRO_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
487 if [[ $CAIRO_MAJOR_VERSION -gt 1 ||
488 $CAIRO_MINOR_VERSION -gt 12 ||
489 ($CAIRO_MINOR_VERSION -eq 12 && $CAIRO_DOTDOT_VERSION -ge 2) ]]
492 # Starting with Cairo 1.12.2, the tarballs are compressed with
493 # xz rather than gzip.
495 [ -f cairo-$CAIRO_VERSION.tar.xz ] || curl -O http://cairographics.org/releases/cairo-$CAIRO_VERSION.tar.xz || exit 1
496 xzcat cairo-$CAIRO_VERSION.tar.xz | tar xf - || exit 1
498 [ -f cairo-$CAIRO_VERSION.tar.gz ] || curl -O http://cairographics.org/releases/cairo-$CAIRO_VERSION.tar.gz || exit 1
499 gzcat cairo-$CAIRO_VERSION.tar.gz | tar xf - || exit 1
501 cd cairo-$CAIRO_VERSION
502 # CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --enable-quartz=no || exit 1
503 # Maybe follow http://cairographics.org/end_to_end_build_for_mac_os_x/
504 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --enable-quartz=yes || exit 1
506 # We must avoid the version of libpng that comes with X11; the
507 # only way I've found to force that is to forcibly set INCLUDES
508 # when we do the build, so that this comes before CAIRO_CFLAGS,
509 # which has -I/usr/X11/include added to it before anything
510 # connected to libpng is.
512 INCLUDES="-I/usr/local/include/libpng15" make $MAKE_BUILD_OPTS || exit 1
513 $DO_MAKE_INSTALL || exit 1
515 touch cairo-$CAIRO_VERSION-done
519 echo "Uninstalling Cairo:"
520 cd cairo-$installed_cairo_version
521 $DO_MAKE_UNINSTALL || exit 1
522 make distclean || exit 1
524 rm cairo-$installed_cairo_version-done
528 echo "Downloading, building, and installing ATK:"
529 atk_dir=`expr $ATK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
530 ATK_MAJOR_VERSION="`expr $ATK_VERSION : '\([0-9][0-9]*\).*'`"
531 ATK_MINOR_VERSION="`expr $ATK_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
532 ATK_DOTDOT_VERSION="`expr $ATK_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
533 if [[ $ATK_MAJOR_VERSION -gt 2 ||
534 ($ATK_MAJOR_VERSION -eq 2 && $ATK_MINOR_VERSION -gt 0) ||
535 ($ATK_MANOR_VERSION -eq 2 && $ATK_MINOR_VERSION -eq 0 && $ATK_DOTDOT_VERSION -ge 1) ]]
538 # Starting with ATK 2.0.1, xz-compressed tarballs are available.
540 [ -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
541 xzcat atk-$ATK_VERSION.tar.xz | tar xf - || exit 1
543 [ -f atk-$ATK_VERSION.tar.bz2 ] || curl -O http://ftp.gnome.org/pub/gnome/sources/atk/$atk_dir/atk-$ATK_VERSION.tar.bz2 || exit 1
544 bzcat atk-$ATK_VERSION.tar.bz2 | tar xf - || exit 1
547 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
548 make $MAKE_BUILD_OPTS || exit 1
549 $DO_MAKE_INSTALL || exit 1
551 touch atk-$ATK_VERSION-done
555 echo "Uninstalling ATK:"
556 cd atk-$installed_atk_version
557 $DO_MAKE_UNINSTALL || exit 1
558 make distclean || exit 1
560 rm atk-$installed_atk_version-done
564 echo "Downloading, building, and installing Pango:"
565 pango_dir=`expr $PANGO_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
566 PANGO_MAJOR_VERSION="`expr $PANGO_VERSION : '\([0-9][0-9]*\).*'`"
567 PANGO_MINOR_VERSION="`expr $PANGO_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
568 if [[ $PANGO_MAJOR_VERSION -gt 1 ||
569 $PANGO_MINOR_VERSION -ge 29 ]]
572 # Starting with Pango 1.29, the tarballs are compressed with
573 # xz rather than bzip2.
575 [ -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
576 xzcat pango-$PANGO_VERSION.tar.xz | tar xf - || exit 1
578 [ -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
579 bzcat pango-$PANGO_VERSION.tar.bz2 | tar xf - || exit 1
581 cd pango-$PANGO_VERSION
582 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
583 make $MAKE_BUILD_OPTS || exit 1
584 $DO_MAKE_INSTALL || exit 1
586 touch pango-$PANGO_VERSION-done
590 echo "Uninstalling Pango:"
591 cd pango-$installed_pango_version
592 $DO_MAKE_UNINSTALL || exit 1
593 make distclean || exit 1
595 rm pango-$installed_pango_version-done
598 install_gdk_pixbuf() {
599 echo "Downloading, building, and installing gdk-pixbuf:"
600 gdk_pixbuf_dir=`expr $GDK_PIXBUF_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
601 [ -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
602 xzcat gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.xz | tar xf - || exit 1
603 cd gdk-pixbuf-$GDK_PIXBUF_VERSION
605 # If we're building using the 10.6 SDK, force the use of libpng12.
607 # The OS's X11, and corresponding SDK, didn't introduce libpng15,
608 # or pkg-config files, until 10.7, so, for 10.6 have to explicitly
609 # set LIBPNG to override the configure script, and also force the
610 # CFLAGS to look for the header files for libpng12 (note that
611 # -isysroot doesn't affect the arguments to -I, so we need to
612 # include the SDK path explicitly).
614 if [[ "$sdk_target" = 10.6 ]]
616 LIBPNG="-L/usr/X11/lib -lpng12" CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS -I$SDKPATH/usr/X11/include/libpng12" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS -I$SDKPATH/usr/X11/include/libpng12" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --without-libtiff --without-libjpeg || exit 1
618 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --without-libtiff --without-libjpeg || exit 1
620 make $MAKE_BUILD_OPTS || exit 1
621 $DO_MAKE_INSTALL || exit 1
623 touch gdk-pixbuf-$GDK_PIXBUF_VERSION-done
626 uninstall_gdk_pixbuf() {
627 echo "Uninstalling gdk-pixbuf:"
628 cd gdk-pixbuf-$installed_gdk_pixbuf_version
629 $DO_MAKE_UNINSTALL || exit 1
630 make distclean || exit 1
632 rm gdk-pixbuf-$installed_gdk_pixbuf_version-done
636 echo "Downloading, building, and installing GTK+:"
637 gtk_dir=`expr $GTK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
638 if [[ $GTK_MAJOR_VERSION -gt 2 ||
639 $GTK_MINOR_VERSION -gt 24 ||
640 ($GTK_MINOR_VERSION -eq 24 && $GTK_DOTDOT_VERSION -ge 5) ]]
643 # Starting with GTK+ 2.24.5, the tarballs are compressed with
644 # xz rather than gzip, in addition to bzip2; use xz, as we've
645 # built and installed it, and as xz compresses better than
646 # bzip2 so the tarballs take less time to download.
648 [ -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
649 xzcat gtk+-$GTK_VERSION.tar.xz | tar xf - || exit 1
651 [ -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
652 bzcat gtk+-$GTK_VERSION.tar.bz2 | tar xf - || exit 1
655 if [ $DARWIN_MAJOR_VERSION -ge "12" ]
658 # GTK+ 2.24.10, at least, doesn't build on Mountain Lion with the
659 # CUPS printing backend - either the CUPS API changed incompatibly
660 # or the backend was depending on non-API implementation details.
662 # Configure it out, on Mountain Lion and later, for now.
663 # (12 is the Darwin major version number in Mountain Lion.)
665 # Also, configure out libtiff and libjpeg; configure scripts
666 # just ignore unknown --enable/--disable and --with/--without
667 # options (at least they've always do so up to now).
669 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --disable-cups --without-libtiff --without-libjpeg || exit 1
671 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --without-libtiff --without-libjpeg || exit 1
673 make $MAKE_BUILD_OPTS || exit 1
674 $DO_MAKE_INSTALL || exit 1
676 touch gtk+-$GTK_VERSION-done
680 echo "Uninstalling GTK+:"
681 cd gtk+-$installed_gtk_version
682 $DO_MAKE_UNINSTALL || exit 1
683 make distclean || exit 1
685 rm gtk+-$installed_gtk_version-done
689 echo "Downloading, building, and installing libsmi:"
690 [ -f libsmi-$LIBSMI_VERSION.tar.gz ] || curl -L -O https://www.ibr.cs.tu-bs.de/projects/libsmi/download/libsmi-$LIBSMI_VERSION.tar.gz || exit 1
691 gzcat libsmi-$LIBSMI_VERSION.tar.gz | tar xf - || exit 1
692 cd libsmi-$LIBSMI_VERSION
693 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
694 make $MAKE_BUILD_OPTS || exit 1
695 $DO_MAKE_INSTALL || exit 1
697 touch libsmi-$LIBSMI_VERSION-done
701 echo "Uninstalling libsmi:"
702 cd libsmi-$installed_libsmi_version
703 $DO_MAKE_UNINSTALL || exit 1
704 make distclean || exit 1
706 rm libsmi-$installed_libsmi_version-done
709 install_libgpg_error() {
710 echo "Downloading, building, and installing libgpg-error:"
711 [ -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
712 bzcat libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 | tar xf - || exit 1
713 cd libgpg-error-$LIBGPG_ERROR_VERSION
714 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
715 make $MAKE_BUILD_OPTS || exit 1
716 $DO_MAKE_INSTALL || exit 1
718 touch libgpg-error-$LIBGPG_ERROR_VERSION-done
721 uninstall_libgpg_error() {
722 echo "Uninstalling libgpg-error:"
723 cd libgpg-error-$installed_libgpg_error_version
724 $DO_MAKE_UNINSTALL || exit 1
725 make distclean || exit 1
727 rm libgpg-error-$installed_libgpg_error_version-done
730 install_libgcrypt() {
732 # libgpg-error is required for libgcrypt.
734 if [ -z $LIBGPG_ERROR_VERSION ]
736 echo "libgcrypt requires libgpg-error, but you didn't install libgpg-error." 1>&2
740 echo "Downloading, building, and installing libgcrypt:"
741 [ -f libgcrypt-$LIBGCRYPT_VERSION.tar.gz ] || curl -L -O ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-$LIBGCRYPT_VERSION.tar.gz || exit 1
742 gzcat libgcrypt-$LIBGCRYPT_VERSION.tar.gz | tar xf - || exit 1
743 cd libgcrypt-$LIBGCRYPT_VERSION
745 # The assembler language code is not compatible with the OS X
746 # x86 assembler (or is it an x86-64 vs. x86-32 issue?).
748 # libgcrypt expects gnu89, not c99/gnu99, semantics for
749 # "inline". See, for example:
751 # http://lists.freebsd.org/pipermail/freebsd-ports-bugs/2010-October/198809.html
753 CFLAGS="$CFLAGS -std=gnu89 $VERSION_MIN_FLAGS $SDKFLAGS" CFLAGS="$CFLAGS -std=gnu89 $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --disable-asm || exit 1
754 make $MAKE_BUILD_OPTS || exit 1
755 $DO_MAKE_INSTALL || exit 1
757 touch libgcrypt-$LIBGCRYPT_VERSION-done
760 uninstall_libgcrypt() {
761 echo "Uninstalling libgcrypt:"
762 cd libgcrypt-$installed_libgcrypt_version
763 $DO_MAKE_UNINSTALL || exit 1
764 make distclean || exit 1
766 rm libgcrypt-$installed_libgcrypt_version-done
771 # GnuTLS requires libgcrypt (or nettle, in newer versions).
773 if [ -z $LIBGCRYPT_VERSION ]
775 echo "GnuTLS requires libgcrypt, but you didn't install libgcrypt" 1>&2
779 echo "Downloading, building, and installing GnuTLS:"
780 [ -f gnutls-$GNUTLS_VERSION.tar.bz2 ] || curl -L -O http://ftp.gnu.org/gnu/gnutls/gnutls-$GNUTLS_VERSION.tar.bz2 || exit 1
781 bzcat gnutls-$GNUTLS_VERSION.tar.bz2 | tar xf - || exit 1
782 cd gnutls-$GNUTLS_VERSION
784 # Use libgcrypt, not nettle.
785 # XXX - is there some reason to prefer nettle? Or does
786 # Wireshark directly use libgcrypt routines?
788 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --with-libgcrypt --without-p11-kit || exit 1
789 make $MAKE_BUILD_OPTS || exit 1
791 # The pkgconfig file for GnuTLS says "requires zlib", but OS X,
792 # while it supplies zlib, doesn't supply a pkgconfig file for
795 # Patch the GnuTLS pkgconfig file not to require zlib.
796 # (If the capabilities of GnuTLS that Wireshark uses don't
797 # depend on building GnuTLS with zlib, an alternative would be
798 # to configure it not to use zlib.)
800 patch -p0 lib/gnutls.pc.in <../../macosx-support-lib-patches/gnutls-pkgconfig.patch || exit 1
801 $DO_MAKE_INSTALL || exit 1
803 touch gnutls-$GNUTLS_VERSION-done
807 echo "Uninstalling GnuTLS:"
808 cd gnutls-$installed_gnutls_version
809 $DO_MAKE_UNINSTALL || exit 1
810 make distclean || exit 1
812 rm gnutls-$installed_gnutls_version-done
816 echo "Downloading, building, and installing Lua:"
817 [ -f lua-$LUA_VERSION.tar.gz ] || curl -L -O http://www.lua.org/ftp/lua-$LUA_VERSION.tar.gz || exit 1
818 gzcat lua-$LUA_VERSION.tar.gz | tar xf - || exit 1
820 make $MAKE_BUILD_OPTS macosx || exit 1
821 $DO_MAKE_INSTALL || exit 1
823 touch lua-$LUA_VERSION-done
827 echo "Uninstalling Lua:"
829 # Lua has no "make uninstall", so just remove stuff manually.
830 # There's no configure script, so there's no need for
831 # "make distclean", either; just do "make clean".
833 (cd /usr/local/bin; $DO_RM -f lua luac)
834 (cd /usr/local/include; $DO_RM -f lua.h luaconf.h lualib.h lauxlib.h lua.hpp)
835 (cd /usr/local/lib; $DO_RM -f liblua.a)
836 (cd /usr/local/man/man1; $DO_RM -f lua.1 luac.1)
837 cd lua-$installed_lua_version
840 rm lua-$installed_lua_version-done
843 install_portaudio() {
844 echo "Downloading, building, and installing PortAudio:"
845 [ -f $PORTAUDIO_VERSION.tgz ] || curl -L -O http://www.portaudio.com/archives/$PORTAUDIO_VERSION.tgz || exit 1
846 gzcat $PORTAUDIO_VERSION.tgz | tar xf - || exit 1
849 # Un-comment an include that's required on Lion.
851 patch -p0 include/pa_mac_core.h <../../macosx-support-lib-patches/portaudio-pa_mac_core.h.patch
853 # Fix a bug that showed up with clang (but is a bug with any
856 patch -p0 src/hostapi/coreaudio/pa_mac_core.c <../../macosx-support-lib-patches/portaudio-pa_mac_core.c.patch
858 # Disable fat builds - the configure script doesn't work right
859 # with Xcode 4 if you leave them enabled, and we don't build
860 # any other libraries fat (GLib, for example, would be very
861 # hard to build fat), so there's no advantage to having PortAudio
864 # Set the minimum OS X version to 10.4, to suppress some
865 # deprecation warnings. (Good luck trying to make any of
866 # this build on an OS+Xcode with a pre-10.4 SDK; we don't
867 # worry about the user requesting that.)
869 CFLAGS="$CFLAGS -mmacosx-version-min=10.4 $SDKFLAGS" CXXFLAGS="$CXXFLAGS -mmacosx-version-min=10.4 $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --disable-mac-universal || exit 1
870 make $MAKE_BUILD_OPTS || exit 1
871 $DO_MAKE_INSTALL || exit 1
876 uninstall_portaudio() {
877 echo "Uninstalling PortAudio:"
879 $DO_MAKE_UNINSTALL || exit 1
880 make distclean || exit 1
886 echo "Downloading, building, and installing GeoIP API:"
887 [ -f GeoIP-$GEOIP_VERSION.tar.gz ] || curl -L -O http://geolite.maxmind.com/download/geoip/api/c/GeoIP-$GEOIP_VERSION.tar.gz || exit 1
888 gzcat GeoIP-$GEOIP_VERSION.tar.gz | tar xf - || exit 1
889 cd GeoIP-$GEOIP_VERSION
890 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
892 # Grr. Their man pages "helpfully" have an ISO 8859-1
893 # copyright symbol in the copyright notice, but OS X's
894 # default character encoding is UTF-8. sed on Mountain
895 # Lion barfs at the "illegal character sequence" represented
896 # by an ISO 8859-1 copyright symbol, as it's not a valid
899 # iconv the relevant man pages into UTF-8.
901 for i in geoipupdate.1.in geoiplookup6.1.in geoiplookup.1.in
903 iconv -f iso8859-1 -t utf-8 man/"$i" >man/"$i".tmp &&
904 mv man/"$i".tmp man/"$i"
906 make $MAKE_BUILD_OPTS || exit 1
907 $DO_MAKE_INSTALL || exit 1
909 touch geoip-$GEOIP_VERSION-done
913 echo "Uninstalling GeoIP API:"
914 cd GeoIP-$installed_geoip_version
915 $DO_MAKE_UNINSTALL || exit 1
916 make distclean || exit 1
918 rm geoip-$installed_geoip_version-done
922 echo "Downloading, building, and installing C-Ares API:"
923 [ -f c-ares-$CARES_VERSION.tar.gz ] || curl -L -O http://c-ares.haxx.se/download/c-ares-$CARES_VERSION.tar.gz || exit 1
924 gzcat c-ares-$CARES_VERSION.tar.gz | tar xf - || exit 1
925 cd c-ares-$CARES_VERSION
926 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
927 make $MAKE_BUILD_OPTS || exit 1
928 $DO_MAKE_INSTALL || exit 1
930 touch c-ares-$CARES_VERSION-done
934 echo "Uninstalling C-Ares API:"
935 cd c-ares-$installed_cares_version
936 $DO_MAKE_UNINSTALL || exit 1
937 make distclean || exit 1
939 rm c-ares-$installed_cares_version-done
943 if [ -d macosx-support-libs ]
945 cd macosx-support-libs
948 # Uninstall items in the reverse order from the order in which they're
949 # installed. Only uninstall if the download/build/install process
950 # completed; uninstall the version that appears in the name of
953 # We also do a "make distclean", so that we don't have leftovers from
954 # old configurations.
957 installed_cares_version=`ls c-ares-*-done 2>/dev/null | sed 's/c-ares-\(.*\)-done/\1/'`
958 if [ ! -z "$installed_cares_version" ] ; then
962 installed_geoip_version=`ls geoip-*-done 2>/dev/null | sed 's/geoip-\(.*\)-done/\1/'`
963 if [ ! -z "$installed_geoip_version" ] ; then
967 if [ "$PORTAUDIO_VERSION" -a -f portaudio-done ] ; then
971 installed_lua_version=`ls lua-*-done 2>/dev/null | sed 's/lua-\(.*\)-done/\1/'`
972 if [ ! -z "$installed_lua_version" ] ; then
976 installed_gnutls_version=`ls gnutls-*-done 2>/dev/null | sed 's/gnutls-\(.*\)-done/\1/'`
977 if [ ! -z "$installed_gnutls_version" ] ; then
981 installed_libgcrypt_version=`ls libgcrypt-*-done 2>/dev/null | sed 's/libgcrypt-\(.*\)-done/\1/'`
982 if [ ! -z "$installed_libgcrypt_version" ] ; then
986 installed_libgpg_error_version=`ls libgpg-error-*-done 2>/dev/null | sed 's/libgpg-error-\(.*\)-done/\1/'`
987 if [ ! -z "$installed_libgpg_error_version" ] ; then
988 uninstall_libgpg_error
991 installed_libsmi_version=`ls libsmi-*-done 2>/dev/null | sed 's/libsmi-\(.*\)-done/\1/'`
992 if [ ! -z "$installed_libsmi_version" ] ; then
996 installed_gtk_version=`ls gtk+-*-done 2>/dev/null | sed 's/gtk+-\(.*\)-done/\1/'`
997 if [ ! -z "$installed_gtk_version" ] ; then
1001 installed_gdk_pixbuf_version=`ls gdk-pixbuf-*-done 2>/dev/null | sed 's/gdk-pixbuf-\(.*\)-done/\1/'`
1002 if [ ! -z "$installed_gdk_pixbuf_version" ] ; then
1003 uninstall_gdk_pixbuf
1006 installed_pango_version=`ls pango-*-done 2>/dev/null | sed 's/pango-\(.*\)-done/\1/'`
1007 if [ ! -z "$installed_pango_version" ] ; then
1011 installed_atk_version=`ls atk-*-done 2>/dev/null | sed 's/atk-\(.*\)-done/\1/'`
1012 if [ ! -z "$installed_atk_version" ] ; then
1016 installed_cairo_version=`ls cairo-*-done 2>/dev/null | sed 's/cairo-\(.*\)-done/\1/'`
1017 if [ ! -z "$installed_cairo_version" ] ; then
1021 installed_pixman_version=`ls pixman-*-done 2>/dev/null | sed 's/pixman-\(.*\)-done/\1/'`
1022 if [ ! -z "$installed_pixman_version" ] ; then
1026 installed_libpng_version=`ls libpng-*-done 2>/dev/null | sed 's/libpng-\(.*\)-done/\1/'`
1027 if [ ! -z "$installed_libpng_version" ] ; then
1031 installed_qt_version=`ls qt-*-done 2>/dev/null | sed 's/qt-\(.*\)-done/\1/'`
1032 if [ ! -z "$installed_qt_version" ] ; then
1036 installed_glib_version=`ls glib-*-done 2>/dev/null | sed 's/glib-\(.*\)-done/\1/'`
1037 if [ ! -z "$installed_glib_version" ] ; then
1041 installed_pkg_config_version=`ls pkg-config-*-done 2>/dev/null | sed 's/pkg-config-\(.*\)-done/\1/'`
1042 if [ ! -z "$installed_pkg_config_version" ] ; then
1043 uninstall_pkg_config
1046 installed_gettext_version=`ls gettext-*-done 2>/dev/null | sed 's/gettext-\(.*\)-done/\1/'`
1047 if [ ! -z "$installed_gettext_version" ] ; then
1052 # XXX - really remove this?
1053 # Or should we remember it as installed only if this script
1056 installed_cmake_version=`ls cmake-*-done 2>/dev/null | sed 's/cmake-\(.*\)-done/\1/'`
1057 if [ ! -z "$installed_cmake_version" ]; then
1061 installed_libtool_version=`ls libtool-*-done 2>/dev/null | sed 's/libtool-\(.*\)-done/\1/'`
1062 if [ ! -z "$installed_libtool_version" ] ; then
1066 installed_automake_version=`ls automake-*-done 2>/dev/null | sed 's/automake-\(.*\)-done/\1/'`
1067 if [ ! -z "$installed_automake_version" ] ; then
1071 installed_autoconf_version=`ls autoconf-*-done 2>/dev/null | sed 's/autoconf-\(.*\)-done/\1/'`
1072 if [ ! -z "$installed_autoconf_version" ] ; then
1076 installed_xz_version=`ls xz-*-done 2>/dev/null | sed 's/xz-\(.*\)-done/\1/'`
1077 if [ ! -z "$installed_xz_version" ] ; then
1084 # Do we have permission to write in /usr/local?
1086 # If so, assume we have permission to write in its subdirectories.
1087 # (If that's not the case, this test needs to check the subdirectories
1090 # If not, do "make install", "make uninstall", the removes for Lua,
1091 # and the renames of [g]libtool* with sudo.
1093 if [ -w /usr/local ]
1095 DO_MAKE_INSTALL="make install"
1096 DO_MAKE_UNINSTALL="make uninstall"
1100 DO_MAKE_INSTALL="sudo make install"
1101 DO_MAKE_UNINSTALL="sudo make uninstall"
1107 # If we have SDKs available, the default target OS is the major version
1108 # of the one we're running; get that and strip off the third component
1111 for i in /Developer/SDKs \
1112 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \
1113 /Library/Developer/CommandLineTools/SDKs
1117 min_osx_target=`sw_vers -productVersion | sed 's/\([0-9]*\)\.\([0-9]*\)\.[0-9]*/\1.\2/'`
1120 # That's also the OS whose SDK we'd be using.
1122 sdk_target=$min_osx_target
1128 # Parse command-line flags:
1131 # -t <target> - build libraries so that they'll work on the specified
1132 # version of OS X and later versions.
1133 # -u - do an uninstall.
1135 while getopts ht:u name
1142 min_osx_target="$OPTARG"
1145 echo "Usage: macosx-setup.sh [ -t <target> ] [ -u ]" 1>&1
1151 if [ "$do_uninstall" = "yes" ]
1158 # Configure scripts tend to set CFLAGS and CXXFLAGS to "-g -O2" if
1159 # invoked without CFLAGS or CXXFLAGS being set in the environment.
1161 # However, we *are* setting them in the environment, for our own
1162 # nefarious purposes, so start them out as "-g -O2".
1168 # To make this work on Leopard (rather than working *on* Snow Leopard
1169 # when building *for* Leopard) will take more work.
1171 # For one thing, Leopard's /usr/X11/lib/libXdamage.la claims, at least
1172 # with all software updates applied, that the Xdamage shared library
1173 # is libXdamage.1.0.0.dylib, but it is, in fact, libXdamage.1.1.0.dylib.
1174 # This causes problems when building GTK+, so the script would have to
1177 if [[ $DARWIN_MAJOR_VERSION -le 9 ]]; then
1178 echo "This script does not support any versions of OS X before Snow Leopard" 1>&2
1182 # if no make options are present, set default options
1183 if [ -z "$MAKE_BUILD_OPTS" ] ; then
1184 # by default use 1.5x number of cores for parallel build
1185 MAKE_BUILD_OPTS="-j $(( $(sysctl -n hw.logicalcpu) * 3 / 2))"
1189 # If we have a target release, look for the oldest SDK that's for an
1190 # OS equal to or later than that one, and build libraries against it
1191 # rather than against the headers and, more importantly, libraries
1192 # that come with the OS, so that we don't end up with support libraries
1193 # that only work on the OS version on which we built them, not earlier
1194 # versions of the same release, or earlier releases if the minimum is
1197 if [ ! -z "$min_osx_target" ]
1200 # Get the real version - strip off the "10.".
1201 # We'll worry about that if, as, and when there's ever
1204 deploy_real_version=`echo "$min_osx_target" | sed -n 's/10\.\(.*\)/\1/p'`
1207 # Search each directory that might contain SDKs.
1210 for sdksdir in /Developer/SDKs \
1211 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \
1212 /Library/Developer/CommandLineTools/SDKs
1215 # Get a list of all the SDKs.
1217 if ! test -d "$sdksdir"
1220 # There is no directory with that name.
1221 # Move on to the next one in the list, if any.
1227 # Get a list of all the SDKs in that directory, if any.
1229 sdklist=`(cd "$sdksdir"; ls -d MacOSX10.[0-9]*.sdk 2>/dev/null)`
1234 # Get the real version for this SDK.
1236 sdk_real_version=`echo "$sdk" | sed -n 's/MacOSX10\.\(.*\)\.sdk/\1/p'`
1239 # Is it for the deployment target or some later release?
1241 if test "$sdk_real_version" -ge "$deploy_real_version"
1246 sdkpath="$sdksdir/$sdk"
1247 qt_sdk_arg="-sdk $sdk"
1253 if [ -z "$sdkpath" ]
1255 echo "macosx-setup.sh: Couldn't find an SDK for OS X $min_osx_target or later" 1>&2
1260 sdk_target=10.$sdk_real_version
1261 echo "Using the 10.$sdk_real_version SDK"
1264 # Make sure there are links to /usr/local/include and /usr/local/lib
1265 # in the SDK's usr/local.
1267 if [ ! -e $SDKPATH/usr/local/include ]
1269 if [ ! -d $SDKPATH/usr/local ]
1271 sudo mkdir $SDKPATH/usr/local
1273 sudo ln -s /usr/local/include $SDKPATH/usr/local/include
1275 if [ ! -e $SDKPATH/usr/local/lib ]
1277 if [ ! -d $SDKPATH/usr/local ]
1279 sudo mkdir $SDKPATH/usr/local
1281 sudo ln -s /usr/local/lib $SDKPATH/usr/local/lib
1285 # Set the minimum OS version for which to build to the specified
1286 # minimum target OS version, so we don't, for example, end up using
1287 # linker features supported by the OS verson on which we're building
1288 # but not by the target version.
1290 VERSION_MIN_FLAGS="-mmacosx-version-min=$min_osx_target"
1293 # Compile and link against the SDK.
1295 SDKFLAGS="-isysroot $SDKPATH"
1297 if [[ "$min_osx_target" == "10.5" ]]
1300 # Cairo is part of Mac OS X 10.6 and later.
1301 # The *headers* are supplied by 10.5, but the *libraries*
1302 # aren't, so we have to build it if we're building for 10.5.
1304 cairo_not_in_the_os=yes
1307 # Build with older versions of the support libraries, as
1308 # were used on the Wireshark Leopard buildbot at one
1309 # point. (Most of these versions come from the About page
1310 # from Wireshark 1.8.6, the last build done on that buildbot;
1311 # the ATK version isn't reported, so this is a guess.)
1313 # If you want to try building with newer versions of
1314 # the libraries, note that:
1316 # The version of fontconfig that comes with Leopard doesn't
1317 # support FC_WEIGHT_EXTRABLACK, so we can't use any version
1318 # of Pango newer than 1.22.4.
1320 # However, Pango 1.22.4 doesn't work with versions of GLib
1321 # after 2.29.6, because Pango 1.22.4 uses G_CONST_RETURN and
1322 # GLib 2.29.8 and later deprecate it (there doesn't appear to
1323 # be a GLib 2.29.7). That means we'd either have to patch
1324 # Pango not to use it (just use "const"; G_CONST_RETURN was
1325 # there to allow code to choose whether to use "const" or not),
1326 # or use GLib 2.29.6 or earlier.
1328 # GLib 2.29.6 includes an implementation of g_bit_lock() that,
1329 # on x86 (32-bit and 64-bit), uses asms in a fashion
1330 # ("asm volatile goto") that requires GCC 4.5 or later, which
1331 # is later than the compilers that come with Leopard and Snow
1332 # Leopard. Recent versions of GLib check for that, but 2.29.6
1333 # doesn't, so, if you want to build GLib 2.29.6 on Leopard or
1334 # Snow Leopard, you would have to patch glib/gbitlock.c to do
1335 # what the newer versions of GLib do:
1337 # define a USE_ASM_GOTO macro that indicates whether "asm goto"
1339 # #if (defined (i386) || defined (__amd64__))
1340 # #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
1341 # #define USE_ASM_GOTO 1
1345 # replace all occurrences of
1347 # #if defined (__GNUC__) && (defined (i386) || defined (__amd64__))
1351 # #ifdef USE_ASM_GOTO
1353 # Using GLib 2.29.6 or earlier, however, means that we can't
1354 # use a version of ATK later than 2.3.93, as those versions
1355 # don't work with GLib 2.29.6. The same applies to gdk-pixbuf;
1356 # versions of gdk-pixbuf after 2.24.1 won't work with GLib
1359 # Then you have to make sure that what you've build doesn't
1360 # cause the X server that comes with Leopard to crash; at
1361 # least one attempt at building for Leopard did.
1363 # At least if building on Leopard, you might also find
1364 # that, with various older versions of Cairo, including
1365 # 1.6.4 and at least some 1.8.x versions, when you try to
1366 # build it, the build fails because it can't find
1367 # png_set_longjmp_fn(). I vaguely remember dealing with that,
1368 # ages ago, but don't remember what I did.
1373 PANGO_VERSION=1.20.2
1377 # That version of GTK+ includes gdk-pixbuf.
1378 # XXX - base this on the version of GTK+ requested.
1383 # Libgcrypt 1.5.0 fails to compile due to some problem with an
1384 # asm in rijndael.c, at least with i686-apple-darwin10-gcc-4.2.1
1385 # (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3) when building
1388 # We try libgcrypt 1.4.3 instead, as that's what shows up in
1389 # the version from the Leopard buildbot.
1390 LIBGCRYPT_VERSION=1.4.3
1393 # Build 32-bit while we're at it; Leopard has a bug that
1394 # causes some BPF functions not to work with 64-bit userland
1395 # code, so capturing won't work.
1397 CFLAGS="$CFLAGS -arch i386"
1398 CXXFLAGS="$CXXFLAGS -arch i386"
1399 export LDFLAGS="$LDFLAGS -arch i386"
1407 # You need Xcode or the command-line tools installed to get the compilers.
1409 if [ ! -x /usr/bin/xcodebuild ]; then
1410 echo "Please install Xcode first (should be available on DVD or from http://developer.apple.com/xcode/index.php)."
1414 if [ "$QT_VERSION" ]; then
1416 # We need Xcode, not just the command-line tools, installed to build
1419 if ! /usr/bin/xcrun -find xcrun >/dev/null 2>&1; then
1420 echo "Please install Xcode first (should be available on DVD or from http://developer.apple.com/xcode/index.php)."
1421 echo "The command-line build tools are not sufficient to build Qt."
1425 if [ "$GTK_VERSION" ]; then
1427 # If we're building with GTK+, you also need the X11 SDK; with at least
1428 # some versions of OS X and Xcode, that is, I think, an optional install.
1429 # (Or it might be installed with X11, but I think *that* is an optional
1430 # install on at least some versions of OS X.)
1432 if [ ! -d /usr/X11/include ]; then
1433 echo "Please install X11 and the X11 SDK first."
1434 echo " You can either use http://xquartz.macosforge.org/, e.g."
1435 echo " http://xquartz-dl.macosforge.org/SL/XQuartz-$XQUARTZ_VERSION.dmg"
1436 echo " or the native Apple packages if you are on Lion or below."
1441 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig
1444 # Do all the downloads and untarring in a subdirectory, so all that
1445 # stuff can be removed once we've installed the support libraries.
1447 if [ ! -d macosx-support-libs ]
1449 mkdir macosx-support-libs || exit 1
1451 cd macosx-support-libs
1453 # Start with xz: It is the sole download format of glib later than 2.31.2
1455 if [ "$XZ_VERSION" -a ! -f xz-$XZ_VERSION-done ] ; then
1459 if [ "$AUTOCONF_VERSION" -a ! -f autoconf-$AUTOCONF_VERSION-done ] ; then
1463 if [ "$AUTOMAKE_VERSION" -a ! -f automake-$AUTOMAKE_VERSION-done ] ; then
1467 if [ "$LIBTOOL_VERSION" -a ! -f libtool-$LIBTOOL_VERSION-done ] ; then
1471 if [ -n "$CMAKE" -a ! -f cmake-$CMAKE_VERSION-done ]; then
1476 # Start with GNU gettext; GLib requires it, and OS X doesn't have it
1477 # or a BSD-licensed replacement.
1479 # At least on Lion with Xcode 4, _FORTIFY_SOURCE gets defined as 2
1480 # by default, which causes, for example, stpncpy to be defined as
1481 # a hairy macro that collides with the GNU gettext configure script's
1482 # attempts to workaround AIX's lack of a declaration for stpncpy,
1483 # with the result being a huge train wreck. Define _FORTIFY_SOURCE
1484 # as 0 in an attempt to keep the trains on separate tracks.
1486 if [ ! -f gettext-$GETTEXT_VERSION-done ] ; then
1491 # GLib depends on pkg-config.
1492 # By default, pkg-config depends on GLib; we break the dependency cycle
1493 # by configuring pkg-config to use its own internal version of GLib.
1495 if [ ! -f pkg-config-$PKG_CONFIG_VERSION-done ] ; then
1499 if [ ! -f glib-$GLIB_VERSION-done ] ; then
1504 # Now we have reached a point where we can build everything but
1505 # the GUI (Wireshark).
1507 if [ "$QT_VERSION" -a ! -f qt-$QT_VERSION-done ]; then
1511 if [ "$GTK_VERSION" ]; then
1514 # GTK+ 3 requires a newer Cairo build than the one that comes with
1515 # 10.6, so we build Cairo if we are using GTK+ 3.
1517 # In 10.6 and 10.7, it's an X11 library; if we build with "native" GTK+
1518 # rather than X11 GTK+, we might have to build and install Cairo.
1519 # In 10.8 and later, there is no X11, but it's included in Xquartz;
1520 # again, if we build with "native" GTK+, we'd have to build and install
1523 if [[ "$GTK_MAJOR_VERSION" -eq 3 || "$cairo_not_in_the_os" = yes ]]; then
1525 # Requirements for Cairo first
1527 # The libpng that comes with the X11 for Leopard has a bogus
1528 # pkg-config file that lies about where the header files are,
1529 # which causes other packages not to be able to find its
1532 # The libpng in later versions is not what the version of
1533 # libpixman we build below wants - it wants libpng15.
1535 if [ ! -f libpng-$PNG_VERSION-done ] ; then
1540 # The libpixman versions that come with the X11s for Leopard,
1541 # Snow Leopard, and Lion is too old to support Cairo's image
1542 # surface backend feature (which requires pixman-1 >= 0.22.0).
1544 # XXX - what about the one that comes with the latest version
1547 if [ ! -f pixman-$PIXMAN_VERSION-done ] ; then
1552 # And now Cairo itself.
1553 # XXX - with the libxcb that comes with 10.6,
1555 # xcb_discard_reply() is missing, and the build fails.
1557 if [ ! -f cairo-$CAIRO_VERSION-done ] ; then
1562 if [ ! -f atk-$ATK_VERSION-done ] ; then
1566 if [ ! -f pango-$PANGO_VERSION-done ] ; then
1570 if [ "$GDK_PIXBUF_VERSION" -a ! -f gdk-pixbuf-$GDK_PIXBUF_VERSION-done ] ; then
1574 if [ ! -f gtk+-$GTK_VERSION-done ] ; then
1580 # Now we have reached a point where we can build everything including
1581 # the GUI (Wireshark), but not with any optional features such as
1582 # SNMP OID resolution, some forms of decryption, Lua scripting, playback
1583 # of audio, or GeoIP mapping of IP addresses.
1585 # We now conditionally download optional libraries to support them;
1586 # the default is to download them all.
1589 if [ "$LIBSMI_VERSION" -a ! -f libsmi-$LIBSMI_VERSION-done ] ; then
1593 if [ "$LIBGPG_ERROR_VERSION" -a ! -f libgpg-error-$LIBGPG_ERROR_VERSION-done ] ; then
1594 install_libgpg_error
1597 if [ "$LIBGCRYPT_VERSION" -a ! -f libgcrypt-$LIBGCRYPT_VERSION-done ] ; then
1601 if [ "$GNUTLS_VERSION" -a ! -f gnutls-$GNUTLS_VERSION-done ] ; then
1605 if [ "$LUA_VERSION" -a ! -f lua-$LUA_VERSION-done ] ; then
1609 if [ "$PORTAUDIO_VERSION" -a ! -f portaudio-done ] ; then
1613 if [ "$GEOIP_VERSION" -a ! -f geoip-$GEOIP_VERSION-done ]
1618 if [ "$CARES_VERSION" -a ! -f c-ares-$CARES_VERSION-done ]
1625 echo "You are now prepared to build Wireshark. To do so do:"
1626 echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig"
1628 if [ -n "$CMAKE" ]; then
1629 echo "mkdir build; cd build"
1636 echo "mkdir build; cd build"
1639 echo "make $MAKE_BUILD_OPTS"
1644 echo "Make sure you are allowed capture access to the network devices"
1645 echo "See: http://wiki.wireshark.org/CaptureSetup/CapturePrivileges"