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 if [ "$XZ_VERSION" -a ! -f xz-$XZ_VERSION-done ] ; then
144 echo "Downloading, building, and installing xz:"
145 [ -f xz-$XZ_VERSION.tar.bz2 ] || curl -O http://tukaani.org/xz/xz-$XZ_VERSION.tar.bz2 || exit 1
146 bzcat xz-$XZ_VERSION.tar.bz2 | tar xf - || exit 1
148 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0" ./configure || exit 1
149 make $MAKE_BUILD_OPTS || exit 1
150 $DO_MAKE_INSTALL || exit 1
152 touch xz-$XZ_VERSION-done
157 if [ ! -z "$installed_xz_version" ] ; then
158 echo "Uninstalling xz:"
159 cd xz-$installed_xz_version
160 $DO_MAKE_UNINSTALL || exit 1
161 make distclean || exit 1
163 rm xz-$installed_xz_version-done
164 installed_xz_version=""
169 if [ "$AUTOCONF_VERSION" -a ! -f autoconf-$AUTOCONF_VERSION-done ] ; then
170 echo "Downloading, building and installing GNU autoconf..."
171 [ -f autoconf-$AUTOCONF_VERSION.tar.xz ] || curl -O ftp://ftp.gnu.org/gnu/autoconf/autoconf-$AUTOCONF_VERSION.tar.xz || exit 1
172 xzcat autoconf-$AUTOCONF_VERSION.tar.xz | tar xf - || exit 1
173 cd autoconf-$AUTOCONF_VERSION
174 ./configure || exit 1
175 make $MAKE_BUILD_OPTS || exit 1
176 $DO_MAKE_INSTALL || exit 1
178 touch autoconf-$AUTOCONF_VERSION-done
182 uninstall_autoconf() {
183 if [ ! -z "$installed_autoconf_version" ] ; then
184 echo "Uninstalling GNU autoconf:"
185 cd autoconf-$installed_autoconf_version
186 $DO_MAKE_UNINSTALL || exit 1
187 make distclean || exit 1
189 rm autoconf-$installed_autoconf_version-done
190 installed_autoconf_version=""
195 if [ "$AUTOMAKE_VERSION" -a ! -f automake-$AUTOMAKE_VERSION-done ] ; then
196 echo "Downloading, building and installing GNU automake..."
197 [ -f automake-$AUTOMAKE_VERSION.tar.xz ] || curl -O ftp://ftp.gnu.org/gnu/automake/automake-$AUTOMAKE_VERSION.tar.xz || exit 1
198 xzcat automake-$AUTOMAKE_VERSION.tar.xz | tar xf - || exit 1
199 cd automake-$AUTOMAKE_VERSION
200 ./configure || exit 1
201 make $MAKE_BUILD_OPTS || exit 1
202 $DO_MAKE_INSTALL || exit 1
204 touch automake-$AUTOMAKE_VERSION-done
208 uninstall_automake() {
209 if [ ! -z "$installed_automake_version" ] ; then
210 echo "Uninstalling GNU automake:"
211 cd automake-$installed_automake_version
212 $DO_MAKE_UNINSTALL || exit 1
213 make distclean || exit 1
215 rm automake-$installed_automake_version-done
216 installed_automake_version=""
221 if [ "$LIBTOOL_VERSION" -a ! -f libtool-$LIBTOOL_VERSION-done ] ; then
222 echo "Downloading, building and installing GNU libtool..."
223 [ -f libtool-$LIBTOOL_VERSION.tar.xz ] || curl -O ftp://ftp.gnu.org/gnu/libtool/libtool-$LIBTOOL_VERSION.tar.xz || exit 1
224 xzcat libtool-$LIBTOOL_VERSION.tar.xz | tar xf - || exit 1
225 cd libtool-$LIBTOOL_VERSION
226 ./configure || exit 1
227 make $MAKE_BUILD_OPTS || exit 1
228 $DO_MAKE_INSTALL || exit 1
229 $DO_MV /usr/local/bin/libtool /usr/local/bin/glibtool
230 $DO_MV /usr/local/bin/libtoolize /usr/local/bin/glibtoolize
232 touch libtool-$LIBTOOL_VERSION-done
236 uninstall_libtool() {
237 if [ ! -z "$installed_libtool_version" ] ; then
238 echo "Uninstalling GNU libtool:"
239 cd libtool-$installed_libtool_version
240 $DO_MV /usr/local/bin/glibtool /usr/local/bin/libtool
241 $DO_MV /usr/local/bin/glibtoolize /usr/local/bin/libtoolize
242 $DO_MAKE_UNINSTALL || exit 1
243 make distclean || exit 1
245 rm libtool-$installed_libtool_version-done
246 installed_libtool_version=""
251 if [ -n "$CMAKE" -a ! -f cmake-$CMAKE_VERSION-done ]; then
252 echo "Downloading and installing CMake:"
253 cmake_dir=`expr $CMAKE_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
255 # NOTE: the "64" in "Darwin64" doesn't mean "64-bit-only"; the
256 # package in question supports both 32-bit and 64-bit x86.
258 [ -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
259 sudo hdiutil attach http://www.cmake.org/files/v2.8/cmake-$CMAKE_VERSION-Darwin64-universal.dmg || exit 1
260 sudo installer -target / -pkg /Volumes/cmake-$CMAKE_VERSION-Darwin64-universal/cmake-$CMAKE_VERSION-Darwin64-universal.pkg || exit 1
261 sudo hdiutil detach /Volumes/cmake-$CMAKE_VERSION-Darwin64-universal
262 touch cmake-$CMAKE_VERSION-done
267 if [ ! -z "$installed_cmake_version" ]; then
268 echo "Uninstalling CMake:"
269 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
270 sudo rm /usr/bin/ccmake
271 sudo rm /usr/bin/cmake
272 sudo rm /usr/bin/cmake-gui
273 sudo rm /usr/bin/cmakexbuild
274 sudo rm /usr/bin/cpack
275 sudo rm /usr/bin/ctest
276 sudo pkgutil --forget com.Kitware.CMake
277 rm cmake-$installed_cmake_version-done
278 installed_cmake_version=""
283 if [ ! -f gettext-$GETTEXT_VERSION-done ] ; then
284 echo "Downloading, building, and installing GNU gettext:"
285 [ -f gettext-$GETTEXT_VERSION.tar.gz ] || curl -O http://ftp.gnu.org/pub/gnu/gettext/gettext-$GETTEXT_VERSION.tar.gz || exit 1
286 gzcat gettext-$GETTEXT_VERSION.tar.gz | tar xf - || exit 1
287 cd gettext-$GETTEXT_VERSION
288 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
289 make $MAKE_BUILD_OPTS || exit 1
290 $DO_MAKE_INSTALL || exit 1
292 touch gettext-$GETTEXT_VERSION-done
296 uninstall_gettext() {
297 if [ ! -z "$installed_gettext_version" ] ; then
298 echo "Uninstalling GNU gettext:"
299 cd gettext-$installed_gettext_version
300 $DO_MAKE_UNINSTALL || exit 1
301 make distclean || exit 1
303 rm gettext-$installed_gettext_version-done
304 installed_gettext_version=""
308 install_pkg_config() {
309 if [ ! -f pkg-config-$PKG_CONFIG_VERSION-done ] ; then
310 echo "Downloading, building, and installing pkg-config:"
311 [ -f pkg-config-$PKG_CONFIG_VERSION.tar.gz ] || curl -O http://pkgconfig.freedesktop.org/releases/pkg-config-$PKG_CONFIG_VERSION.tar.gz || exit 1
312 gzcat pkg-config-$PKG_CONFIG_VERSION.tar.gz | tar xf - || exit 1
313 cd pkg-config-$PKG_CONFIG_VERSION
314 ./configure --with-internal-glib || exit 1
315 make $MAKE_BUILD_OPTS || exit 1
316 $DO_MAKE_INSTALL || exit 1
318 touch pkg-config-$PKG_CONFIG_VERSION-done
322 uninstall_pkg_config() {
323 if [ ! -z "$installed_pkg_config_version" ] ; then
324 echo "Uninstalling pkg-config:"
325 cd pkg-config-$installed_pkg_config_version
326 $DO_MAKE_UNINSTALL || exit 1
327 make distclean || exit 1
329 rm pkg-config-$installed_pkg_config_version-done
330 installed_pkg_config_version=""
335 if [ ! -f glib-$GLIB_VERSION-done ] ; then
336 echo "Downloading, building, and installing GLib:"
337 glib_dir=`expr $GLIB_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
338 GLIB_MAJOR_VERSION="`expr $GLIB_VERSION : '\([0-9][0-9]*\).*'`"
339 GLIB_MINOR_VERSION="`expr $GLIB_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
340 GLIB_DOTDOT_VERSION="`expr $GLIB_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
341 if [[ $GLIB_MAJOR_VERSION -gt 2 ||
342 $GLIB_MINOR_VERSION -gt 28 ||
343 ($GLIB_MINOR_VERSION -eq 28 && $GLIB_DOTDOT_VERSION -ge 8) ]]
346 # Starting with GLib 2.28.8, xz-compressed tarballs are available.
348 [ -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
349 xzcat glib-$GLIB_VERSION.tar.xz | tar xf - || exit 1
351 [ -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
352 bzcat glib-$GLIB_VERSION.tar.bz2 | tar xf - || exit 1
354 cd glib-$GLIB_VERSION
356 # OS X ships with libffi, but doesn't provide its pkg-config file;
357 # explicitly specify LIBFFI_CFLAGS and LIBFFI_LIBS, so the configure
358 # script doesn't try to use pkg-config to get the appropriate
359 # C flags and loader flags.
361 # And, what's worse, at least with the version of Xcode that comes
362 # with Leopard, /usr/include/ffi/fficonfig.h doesn't define MACOSX,
363 # which causes the build of GLib to fail. If we don't find
364 # "#define.*MACOSX" in /usr/include/ffi/fficonfig.h, explicitly
367 # While we're at it, suppress -Wformat-nonliteral to avoid a case
368 # where clang's stricter rules on when not to complain about
369 # non-literal format arguments cause it to complain about code
370 # that's safe but it wasn't told that. See my comment #25 in
373 # https://bugzilla.gnome.org/show_bug.cgi?id=691608#c25
375 # First, determine where the system include files are. (It's not
376 # necessarily /usr/include.) There's a bit of a greasy hack here;
377 # pre-5.x versions of the developer tools don't support the
378 # --show-sdk-path option, and will produce no output, so includedir
379 # will be set to /usr/include (in those older versions of the
380 # developer tools, there is a /usr/include directory).
382 includedir=`xcrun --show-sdk-path 2>/dev/null`/usr/include
383 if grep -qs '#define.*MACOSX' $includedir/ffi/fficonfig.h
385 # It's defined, nothing to do
386 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
388 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
392 # Apply the fix to GNOME bug 529806:
394 # https://bugzilla.gnome.org/show_bug.cgi?id=529806
396 # if we have a version of GLib prior to 2.30.
398 if [[ $GLIB_MAJOR_VERSION -eq 2 && $GLIB_MINOR_VERSION -le 30 ]]
400 patch -p0 <../../macosx-support-lib-patches/glib-gconvert.c.patch || exit 1
402 make $MAKE_BUILD_OPTS || exit 1
403 $DO_MAKE_INSTALL || exit 1
405 touch glib-$GLIB_VERSION-done
410 if [ ! -z "$installed_glib_version" ] ; then
411 echo "Uninstalling GLib:"
412 cd glib-$installed_glib_version
413 $DO_MAKE_UNINSTALL || exit 1
414 make distclean || exit 1
416 rm glib-$installed_glib_version-done
417 installed_glib_version=""
422 if [ "$QT_VERSION" -a ! -f qt-$QT_VERSION-done ]; then
423 echo "Downloading, building, and installing Qt:"
424 QT_MAJOR_VERSION="`expr $QT_VERSION : '\([0-9][0-9]*\).*'`"
425 QT_MINOR_VERSION="`expr $QT_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
426 QT_DOTDOT_VERSION="`expr $QT_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
427 QT_MAJOR_MINOR_VERSION=$QT_MAJOR_VERSION.$QT_MINOR_VERSION
429 # What you get for this URL might just be a 302 Found reply, so use
430 # -L so we get redirected.
432 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
434 # Qt 5.1.x sets QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
435 # in qtbase/mkspecs/$TARGET_PLATFORM/qmake.conf
436 # We may need to adjust this manually in the future.
438 # The -no-c++11 flag is needed to work around
439 # https://bugreports.qt-project.org/browse/QTBUG-30487
441 tar xf qt-everywhere-opensource-src-$QT_VERSION.tar.gz
442 cd qt-everywhere-opensource-src-$QT_VERSION
444 # We don't build Qt in its Full Shining Glory, as we don't need all
445 # of its components, and it takes *forever* to build in that form.
447 # Qt 5.2.0 beta1 fails to build on OS X without -no-xcb due to bug
450 # Qt 5.x fails to build on OS X with -no-opengl due to bug
453 ./configure -v $qt_sdk_arg -platform $TARGET_PLATFORM \
454 -opensource -confirm-license -no-c++11 -no-dbus \
455 -no-sql-sqlite -no-xcb -nomake examples \
456 -skip qtdoc -skip qtquickcontrols -skip qtwebkit \
457 -skip qtwebkit-examples -skip qtxmlpatterns
459 $DO_MAKE_INSTALL || exit 1
461 touch qt-$QT_VERSION-done
466 if [ ! -z "$installed_qt_version" ] ; then
467 echo "Uninstalling Qt:"
468 cd qt-everywhere-opensource-src-$installed_qt_version
469 $DO_MAKE_UNINSTALL || exit 1
471 # XXX - "make distclean" doesn't work. qmake sure does a
472 # good job of constructing Makefiles that work correctly....
474 #make distclean || exit 1
476 rm qt-$installed_qt_version-done
477 installed_qt_version=""
482 if [ ! -f libpng-$PNG_VERSION-done ] ; then
483 echo "Downloading, building, and installing libpng:"
485 # The FTP site puts libpng x.y.* into a libpngxy directory.
487 subdir=`echo $PNG_VERSION | sed 's/\([1-9][0-9]*\)\.\([1-9][0-9]*\).*/libpng\1\2'/`
488 [ -f libpng-$PNG_VERSION.tar.xz ] || curl -O ftp://ftp.simplesystems.org/pub/libpng/png/src/$subdir/libpng-$PNG_VERSION.tar.xz
489 xzcat libpng-$PNG_VERSION.tar.xz | tar xf - || exit 1
490 cd libpng-$PNG_VERSION
491 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
492 make $MAKE_BUILD_OPTS || exit 1
493 $DO_MAKE_INSTALL || exit 1
495 touch libpng-$PNG_VERSION-done
500 if [ ! -z "$installed_libpng_version" ] ; then
501 echo "Uninstalling libpng:"
502 cd libpng-$installed_libpng_version
503 $DO_MAKE_UNINSTALL || exit 1
504 make distclean || exit 1
506 rm libpng-$installed_libpng_version-done
507 installed_libpng_version=""
511 install_libpixman() {
512 if [ ! -f pixman-$PIXMAN_VERSION-done ] ; then
513 echo "Downloading, building, and installing pixman:"
514 [ -f pixman-$PIXMAN_VERSION.tar.gz ] || curl -O http://www.cairographics.org/releases/pixman-$PIXMAN_VERSION.tar.gz
515 gzcat pixman-$PIXMAN_VERSION.tar.gz | tar xf - || exit 1
516 cd pixman-$PIXMAN_VERSION
517 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
518 make $MAKE_BUILD_OPTS || exit 1
519 $DO_MAKE_INSTALL || exit 1
521 touch pixman-$PIXMAN_VERSION-done
526 if [ ! -z "$installed_pixman_version" ] ; then
527 echo "Uninstalling pixman:"
528 cd pixman-$installed_pixman_version
529 $DO_MAKE_UNINSTALL || exit 1
530 make distclean || exit 1
532 rm pixman-$installed_pixman_version-done
533 installed_pixman_version=""
538 if [ ! -f cairo-$CAIRO_VERSION-done ] ; then
539 echo "Downloading, building, and installing Cairo:"
540 CAIRO_MAJOR_VERSION="`expr $CAIRO_VERSION : '\([0-9][0-9]*\).*'`"
541 CAIRO_MINOR_VERSION="`expr $CAIRO_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
542 CAIRO_DOTDOT_VERSION="`expr $CAIRO_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
543 if [[ $CAIRO_MAJOR_VERSION -gt 1 ||
544 $CAIRO_MINOR_VERSION -gt 12 ||
545 ($CAIRO_MINOR_VERSION -eq 12 && $CAIRO_DOTDOT_VERSION -ge 2) ]]
548 # Starting with Cairo 1.12.2, the tarballs are compressed with
549 # xz rather than gzip.
551 [ -f cairo-$CAIRO_VERSION.tar.xz ] || curl -O http://cairographics.org/releases/cairo-$CAIRO_VERSION.tar.xz || exit 1
552 xzcat cairo-$CAIRO_VERSION.tar.xz | tar xf - || exit 1
554 [ -f cairo-$CAIRO_VERSION.tar.gz ] || curl -O http://cairographics.org/releases/cairo-$CAIRO_VERSION.tar.gz || exit 1
555 gzcat cairo-$CAIRO_VERSION.tar.gz | tar xf - || exit 1
557 cd cairo-$CAIRO_VERSION
558 # CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --enable-quartz=no || exit 1
559 # Maybe follow http://cairographics.org/end_to_end_build_for_mac_os_x/
560 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --enable-quartz=yes || exit 1
562 # We must avoid the version of libpng that comes with X11; the
563 # only way I've found to force that is to forcibly set INCLUDES
564 # when we do the build, so that this comes before CAIRO_CFLAGS,
565 # which has -I/usr/X11/include added to it before anything
566 # connected to libpng is.
568 INCLUDES="-I/usr/local/include/libpng15" make $MAKE_BUILD_OPTS || exit 1
569 $DO_MAKE_INSTALL || exit 1
571 touch cairo-$CAIRO_VERSION-done
576 if [ ! -z "$installed_cairo_version" ] ; then
577 echo "Uninstalling Cairo:"
578 cd cairo-$installed_cairo_version
579 $DO_MAKE_UNINSTALL || exit 1
580 make distclean || exit 1
582 rm cairo-$installed_cairo_version-done
583 installed_cairo_version=""
588 if [ ! -f atk-$ATK_VERSION-done ] ; then
589 echo "Downloading, building, and installing ATK:"
590 atk_dir=`expr $ATK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
591 ATK_MAJOR_VERSION="`expr $ATK_VERSION : '\([0-9][0-9]*\).*'`"
592 ATK_MINOR_VERSION="`expr $ATK_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
593 ATK_DOTDOT_VERSION="`expr $ATK_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
594 if [[ $ATK_MAJOR_VERSION -gt 2 ||
595 ($ATK_MAJOR_VERSION -eq 2 && $ATK_MINOR_VERSION -gt 0) ||
596 ($ATK_MANOR_VERSION -eq 2 && $ATK_MINOR_VERSION -eq 0 && $ATK_DOTDOT_VERSION -ge 1) ]]
599 # Starting with ATK 2.0.1, xz-compressed tarballs are available.
601 [ -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
602 xzcat atk-$ATK_VERSION.tar.xz | tar xf - || exit 1
604 [ -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
605 bzcat atk-$ATK_VERSION.tar.bz2 | tar xf - || exit 1
608 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
609 make $MAKE_BUILD_OPTS || exit 1
610 $DO_MAKE_INSTALL || exit 1
612 touch atk-$ATK_VERSION-done
617 if [ ! -z "$installed_atk_version" ] ; then
618 echo "Uninstalling ATK:"
619 cd atk-$installed_atk_version
620 $DO_MAKE_UNINSTALL || exit 1
621 make distclean || exit 1
623 rm atk-$installed_atk_version-done
624 installed_atk_version=""
629 if [ ! -f pango-$PANGO_VERSION-done ] ; then
630 echo "Downloading, building, and installing Pango:"
631 pango_dir=`expr $PANGO_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
632 PANGO_MAJOR_VERSION="`expr $PANGO_VERSION : '\([0-9][0-9]*\).*'`"
633 PANGO_MINOR_VERSION="`expr $PANGO_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
634 if [[ $PANGO_MAJOR_VERSION -gt 1 ||
635 $PANGO_MINOR_VERSION -ge 29 ]]
638 # Starting with Pango 1.29, the tarballs are compressed with
639 # xz rather than bzip2.
641 [ -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
642 xzcat pango-$PANGO_VERSION.tar.xz | tar xf - || exit 1
644 [ -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
645 bzcat pango-$PANGO_VERSION.tar.bz2 | tar xf - || exit 1
647 cd pango-$PANGO_VERSION
648 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
649 make $MAKE_BUILD_OPTS || exit 1
650 $DO_MAKE_INSTALL || exit 1
652 touch pango-$PANGO_VERSION-done
657 if [ ! -z "$installed_pango_version" ] ; then
658 echo "Uninstalling Pango:"
659 cd pango-$installed_pango_version
660 $DO_MAKE_UNINSTALL || exit 1
661 make distclean || exit 1
663 rm pango-$installed_pango_version-done
664 installed_pango_version=""
668 install_gdk_pixbuf() {
669 if [ "$GDK_PIXBUF_VERSION" -a ! -f gdk-pixbuf-$GDK_PIXBUF_VERSION-done ] ; then
670 echo "Downloading, building, and installing gdk-pixbuf:"
671 gdk_pixbuf_dir=`expr $GDK_PIXBUF_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
672 [ -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
673 xzcat gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.xz | tar xf - || exit 1
674 cd gdk-pixbuf-$GDK_PIXBUF_VERSION
676 # If we're building using the 10.6 SDK, force the use of libpng12.
678 # The OS's X11, and corresponding SDK, didn't introduce libpng15,
679 # or pkg-config files, until 10.7, so, for 10.6 have to explicitly
680 # set LIBPNG to override the configure script, and also force the
681 # CFLAGS to look for the header files for libpng12 (note that
682 # -isysroot doesn't affect the arguments to -I, so we need to
683 # include the SDK path explicitly).
685 if [[ "$sdk_target" = 10.6 ]]
687 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
689 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
691 make $MAKE_BUILD_OPTS || exit 1
692 $DO_MAKE_INSTALL || exit 1
694 touch gdk-pixbuf-$GDK_PIXBUF_VERSION-done
698 uninstall_gdk_pixbuf() {
699 if [ ! -z "$installed_gdk_pixbuf_version" ] ; then
700 echo "Uninstalling gdk-pixbuf:"
701 cd gdk-pixbuf-$installed_gdk_pixbuf_version
702 $DO_MAKE_UNINSTALL || exit 1
703 make distclean || exit 1
705 rm gdk-pixbuf-$installed_gdk_pixbuf_version-done
706 installed_gdk_pixbuf_version=""
711 if [ ! -f gtk+-$GTK_VERSION-done ] ; then
712 echo "Downloading, building, and installing GTK+:"
713 gtk_dir=`expr $GTK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
714 if [[ $GTK_MAJOR_VERSION -gt 2 ||
715 $GTK_MINOR_VERSION -gt 24 ||
716 ($GTK_MINOR_VERSION -eq 24 && $GTK_DOTDOT_VERSION -ge 5) ]]
719 # Starting with GTK+ 2.24.5, the tarballs are compressed with
720 # xz rather than gzip, in addition to bzip2; use xz, as we've
721 # built and installed it, and as xz compresses better than
722 # bzip2 so the tarballs take less time to download.
724 [ -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
725 xzcat gtk+-$GTK_VERSION.tar.xz | tar xf - || exit 1
727 [ -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
728 bzcat gtk+-$GTK_VERSION.tar.bz2 | tar xf - || exit 1
731 if [ $DARWIN_MAJOR_VERSION -ge "12" ]
734 # GTK+ 2.24.10, at least, doesn't build on Mountain Lion with the
735 # CUPS printing backend - either the CUPS API changed incompatibly
736 # or the backend was depending on non-API implementation details.
738 # Configure it out, on Mountain Lion and later, for now.
739 # (12 is the Darwin major version number in Mountain Lion.)
741 # Also, configure out libtiff and libjpeg; configure scripts
742 # just ignore unknown --enable/--disable and --with/--without
743 # options (at least they've always do so up to now).
745 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
747 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
749 make $MAKE_BUILD_OPTS || exit 1
750 $DO_MAKE_INSTALL || exit 1
752 touch gtk+-$GTK_VERSION-done
757 if [ ! -z "$installed_gtk_version" ] ; then
758 echo "Uninstalling GTK+:"
759 cd gtk+-$installed_gtk_version
760 $DO_MAKE_UNINSTALL || exit 1
761 make distclean || exit 1
763 rm gtk+-$installed_gtk_version-done
764 installed_gtk_version=""
769 if [ "$LIBSMI_VERSION" -a ! -f libsmi-$LIBSMI_VERSION-done ] ; then
770 echo "Downloading, building, and installing libsmi:"
771 [ -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
772 gzcat libsmi-$LIBSMI_VERSION.tar.gz | tar xf - || exit 1
773 cd libsmi-$LIBSMI_VERSION
774 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
775 make $MAKE_BUILD_OPTS || exit 1
776 $DO_MAKE_INSTALL || exit 1
778 touch libsmi-$LIBSMI_VERSION-done
783 if [ ! -z "$installed_libsmi_version" ] ; then
784 echo "Uninstalling libsmi:"
785 cd libsmi-$installed_libsmi_version
786 $DO_MAKE_UNINSTALL || exit 1
787 make distclean || exit 1
789 rm libsmi-$installed_libsmi_version-done
790 installed_libsmi_version=""
794 install_libgpg_error() {
795 if [ "$LIBGPG_ERROR_VERSION" -a ! -f libgpg-error-$LIBGPG_ERROR_VERSION-done ] ; then
796 echo "Downloading, building, and installing libgpg-error:"
797 [ -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
798 bzcat libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 | tar xf - || exit 1
799 cd libgpg-error-$LIBGPG_ERROR_VERSION
800 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
801 make $MAKE_BUILD_OPTS || exit 1
802 $DO_MAKE_INSTALL || exit 1
804 touch libgpg-error-$LIBGPG_ERROR_VERSION-done
808 uninstall_libgpg_error() {
809 if [ ! -z "$installed_libgpg_error_version" ] ; then
810 echo "Uninstalling libgpg-error:"
811 cd libgpg-error-$installed_libgpg_error_version
812 $DO_MAKE_UNINSTALL || exit 1
813 make distclean || exit 1
815 rm libgpg-error-$installed_libgpg_error_version-done
816 installed_libgpg_error_version=""
820 install_libgcrypt() {
821 if [ "$LIBGCRYPT_VERSION" -a ! -f libgcrypt-$LIBGCRYPT_VERSION-done ] ; then
823 # libgpg-error is required for libgcrypt.
825 if [ -z $LIBGPG_ERROR_VERSION ]
827 echo "libgcrypt requires libgpg-error, but you didn't install libgpg-error." 1>&2
831 echo "Downloading, building, and installing libgcrypt:"
832 [ -f libgcrypt-$LIBGCRYPT_VERSION.tar.gz ] || curl -L -O ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-$LIBGCRYPT_VERSION.tar.gz || exit 1
833 gzcat libgcrypt-$LIBGCRYPT_VERSION.tar.gz | tar xf - || exit 1
834 cd libgcrypt-$LIBGCRYPT_VERSION
836 # The assembler language code is not compatible with the OS X
837 # x86 assembler (or is it an x86-64 vs. x86-32 issue?).
839 # libgcrypt expects gnu89, not c99/gnu99, semantics for
840 # "inline". See, for example:
842 # http://lists.freebsd.org/pipermail/freebsd-ports-bugs/2010-October/198809.html
844 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
845 make $MAKE_BUILD_OPTS || exit 1
846 $DO_MAKE_INSTALL || exit 1
848 touch libgcrypt-$LIBGCRYPT_VERSION-done
852 uninstall_libgcrypt() {
853 if [ ! -z "$installed_libgcrypt_version" ] ; then
854 echo "Uninstalling libgcrypt:"
855 cd libgcrypt-$installed_libgcrypt_version
856 $DO_MAKE_UNINSTALL || exit 1
857 make distclean || exit 1
859 rm libgcrypt-$installed_libgcrypt_version-done
860 installed_libgcrypt_version=""
865 if [ "$GNUTLS_VERSION" -a ! -f gnutls-$GNUTLS_VERSION-done ] ; then
867 # GnuTLS requires libgcrypt (or nettle, in newer versions).
869 if [ -z $LIBGCRYPT_VERSION ]
871 echo "GnuTLS requires libgcrypt, but you didn't install libgcrypt" 1>&2
875 echo "Downloading, building, and installing GnuTLS:"
876 [ -f gnutls-$GNUTLS_VERSION.tar.bz2 ] || curl -L -O http://ftp.gnu.org/gnu/gnutls/gnutls-$GNUTLS_VERSION.tar.bz2 || exit 1
877 bzcat gnutls-$GNUTLS_VERSION.tar.bz2 | tar xf - || exit 1
878 cd gnutls-$GNUTLS_VERSION
880 # Use libgcrypt, not nettle.
881 # XXX - is there some reason to prefer nettle? Or does
882 # Wireshark directly use libgcrypt routines?
884 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
885 make $MAKE_BUILD_OPTS || exit 1
887 # The pkgconfig file for GnuTLS says "requires zlib", but OS X,
888 # while it supplies zlib, doesn't supply a pkgconfig file for
891 # Patch the GnuTLS pkgconfig file not to require zlib.
892 # (If the capabilities of GnuTLS that Wireshark uses don't
893 # depend on building GnuTLS with zlib, an alternative would be
894 # to configure it not to use zlib.)
896 patch -p0 lib/gnutls.pc.in <../../macosx-support-lib-patches/gnutls-pkgconfig.patch || exit 1
897 $DO_MAKE_INSTALL || exit 1
899 touch gnutls-$GNUTLS_VERSION-done
904 if [ ! -z "$installed_gnutls_version" ] ; then
905 echo "Uninstalling GnuTLS:"
906 cd gnutls-$installed_gnutls_version
907 $DO_MAKE_UNINSTALL || exit 1
908 make distclean || exit 1
910 rm gnutls-$installed_gnutls_version-done
911 installed_gnutls_version=""
916 if [ "$LUA_VERSION" -a ! -f lua-$LUA_VERSION-done ] ; then
917 echo "Downloading, building, and installing Lua:"
918 [ -f lua-$LUA_VERSION.tar.gz ] || curl -L -O http://www.lua.org/ftp/lua-$LUA_VERSION.tar.gz || exit 1
919 gzcat lua-$LUA_VERSION.tar.gz | tar xf - || exit 1
921 make $MAKE_BUILD_OPTS macosx || exit 1
922 $DO_MAKE_INSTALL || exit 1
924 touch lua-$LUA_VERSION-done
929 if [ ! -z "$installed_lua_version" ] ; then
930 echo "Uninstalling Lua:"
932 # Lua has no "make uninstall", so just remove stuff manually.
933 # There's no configure script, so there's no need for
934 # "make distclean", either; just do "make clean".
936 (cd /usr/local/bin; $DO_RM -f lua luac)
937 (cd /usr/local/include; $DO_RM -f lua.h luaconf.h lualib.h lauxlib.h lua.hpp)
938 (cd /usr/local/lib; $DO_RM -f liblua.a)
939 (cd /usr/local/man/man1; $DO_RM -f lua.1 luac.1)
940 cd lua-$installed_lua_version
943 rm lua-$installed_lua_version-done
944 installed_lua_version=""
948 install_portaudio() {
949 if [ "$PORTAUDIO_VERSION" -a ! -f portaudio-done ] ; then
950 echo "Downloading, building, and installing PortAudio:"
951 [ -f $PORTAUDIO_VERSION.tgz ] || curl -L -O http://www.portaudio.com/archives/$PORTAUDIO_VERSION.tgz || exit 1
952 gzcat $PORTAUDIO_VERSION.tgz | tar xf - || exit 1
955 # Un-comment an include that's required on Lion.
957 patch -p0 include/pa_mac_core.h <../../macosx-support-lib-patches/portaudio-pa_mac_core.h.patch
959 # Fix a bug that showed up with clang (but is a bug with any
962 patch -p0 src/hostapi/coreaudio/pa_mac_core.c <../../macosx-support-lib-patches/portaudio-pa_mac_core.c.patch
964 # Disable fat builds - the configure script doesn't work right
965 # with Xcode 4 if you leave them enabled, and we don't build
966 # any other libraries fat (GLib, for example, would be very
967 # hard to build fat), so there's no advantage to having PortAudio
970 # Set the minimum OS X version to 10.4, to suppress some
971 # deprecation warnings. (Good luck trying to make any of
972 # this build on an OS+Xcode with a pre-10.4 SDK; we don't
973 # worry about the user requesting that.)
975 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
976 make $MAKE_BUILD_OPTS || exit 1
977 $DO_MAKE_INSTALL || exit 1
983 uninstall_portaudio() {
984 if [ "$PORTAUDIO_VERSION" -a -f portaudio-done ] ; then
985 echo "Uninstalling PortAudio:"
987 $DO_MAKE_UNINSTALL || exit 1
988 make distclean || exit 1
995 if [ "$GEOIP_VERSION" -a ! -f geoip-$GEOIP_VERSION-done ] ; then
996 echo "Downloading, building, and installing GeoIP API:"
997 [ -f GeoIP-$GEOIP_VERSION.tar.gz ] || curl -L -O http://geolite.maxmind.com/download/geoip/api/c/GeoIP-$GEOIP_VERSION.tar.gz || exit 1
998 gzcat GeoIP-$GEOIP_VERSION.tar.gz | tar xf - || exit 1
999 cd GeoIP-$GEOIP_VERSION
1000 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
1002 # Grr. Their man pages "helpfully" have an ISO 8859-1
1003 # copyright symbol in the copyright notice, but OS X's
1004 # default character encoding is UTF-8. sed on Mountain
1005 # Lion barfs at the "illegal character sequence" represented
1006 # by an ISO 8859-1 copyright symbol, as it's not a valid
1009 # iconv the relevant man pages into UTF-8.
1011 for i in geoipupdate.1.in geoiplookup6.1.in geoiplookup.1.in
1013 iconv -f iso8859-1 -t utf-8 man/"$i" >man/"$i".tmp &&
1014 mv man/"$i".tmp man/"$i"
1016 make $MAKE_BUILD_OPTS || exit 1
1017 $DO_MAKE_INSTALL || exit 1
1019 touch geoip-$GEOIP_VERSION-done
1024 if [ ! -z "$installed_geoip_version" ] ; then
1025 echo "Uninstalling GeoIP API:"
1026 cd GeoIP-$installed_geoip_version
1027 $DO_MAKE_UNINSTALL || exit 1
1028 make distclean || exit 1
1030 rm geoip-$installed_geoip_version-done
1031 installed_geoip_version=""
1036 if [ "$CARES_VERSION" -a ! -f c-ares-$CARES_VERSION-done ] ; then
1037 echo "Downloading, building, and installing C-Ares API:"
1038 [ -f c-ares-$CARES_VERSION.tar.gz ] || curl -L -O http://c-ares.haxx.se/download/c-ares-$CARES_VERSION.tar.gz || exit 1
1039 gzcat c-ares-$CARES_VERSION.tar.gz | tar xf - || exit 1
1040 cd c-ares-$CARES_VERSION
1041 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
1042 make $MAKE_BUILD_OPTS || exit 1
1043 $DO_MAKE_INSTALL || exit 1
1045 touch c-ares-$CARES_VERSION-done
1049 uninstall_c_ares() {
1050 if [ ! -z "$installed_cares_version" ] ; then
1051 echo "Uninstalling C-Ares API:"
1052 cd c-ares-$installed_cares_version
1053 $DO_MAKE_UNINSTALL || exit 1
1054 make distclean || exit 1
1056 rm c-ares-$installed_cares_version-done
1057 installed_cares_version=""
1063 # Start with xz: It is the sole download format of glib later than 2.31.2
1076 # Start with GNU gettext; GLib requires it, and OS X doesn't have it
1077 # or a BSD-licensed replacement.
1079 # At least on Lion with Xcode 4, _FORTIFY_SOURCE gets defined as 2
1080 # by default, which causes, for example, stpncpy to be defined as
1081 # a hairy macro that collides with the GNU gettext configure script's
1082 # attempts to workaround AIX's lack of a declaration for stpncpy,
1083 # with the result being a huge train wreck. Define _FORTIFY_SOURCE
1084 # as 0 in an attempt to keep the trains on separate tracks.
1089 # GLib depends on pkg-config.
1090 # By default, pkg-config depends on GLib; we break the dependency cycle
1091 # by configuring pkg-config to use its own internal version of GLib.
1098 # Now we have reached a point where we can build everything but
1099 # the GUI (Wireshark).
1103 if [ "$GTK_VERSION" ]; then
1105 # GTK+ 3 requires a newer Cairo build than the one that comes with
1106 # 10.6, so we build Cairo if we are using GTK+ 3.
1108 # In 10.6 and 10.7, it's an X11 library; if we build with "native" GTK+
1109 # rather than X11 GTK+, we might have to build and install Cairo.
1110 # In 10.8 and later, there is no X11, but it's included in Xquartz;
1111 # again, if we build with "native" GTK+, we'd have to build and install
1114 if [[ "$GTK_MAJOR_VERSION" -eq 3 || "$cairo_not_in_the_os" = yes ]]; then
1116 # Requirements for Cairo first
1118 # The libpng that comes with the X11 for Leopard has a bogus
1119 # pkg-config file that lies about where the header files are,
1120 # which causes other packages not to be able to find its
1123 # The libpng in later versions is not what the version of
1124 # libpixman we build below wants - it wants libpng15.
1129 # The libpixman versions that come with the X11s for Leopard,
1130 # Snow Leopard, and Lion is too old to support Cairo's image
1131 # surface backend feature (which requires pixman-1 >= 0.22.0).
1133 # XXX - what about the one that comes with the latest version
1139 # And now Cairo itself.
1140 # XXX - with the libxcb that comes with 10.6,
1141 # xcb_discard_reply() is missing, and the build fails.
1156 # Now we have reached a point where we can build everything including
1157 # the GUI (Wireshark), but not with any optional features such as
1158 # SNMP OID resolution, some forms of decryption, Lua scripting, playback
1159 # of audio, or GeoIP mapping of IP addresses.
1161 # We now conditionally download optional libraries to support them;
1162 # the default is to download them all.
1167 install_libgpg_error
1183 if [ -d macosx-support-libs ]
1185 cd macosx-support-libs
1188 # Uninstall items in the reverse order from the order in which they're
1189 # installed. Only uninstall if the download/build/install process
1190 # completed; uninstall the version that appears in the name of
1193 # We also do a "make distclean", so that we don't have leftovers from
1194 # old configurations.
1208 uninstall_libgpg_error
1214 uninstall_gdk_pixbuf
1230 uninstall_pkg_config
1235 # XXX - really remove this?
1236 # Or should we remember it as installed only if this script
1252 # Do we have permission to write in /usr/local?
1254 # If so, assume we have permission to write in its subdirectories.
1255 # (If that's not the case, this test needs to check the subdirectories
1258 # If not, do "make install", "make uninstall", the removes for Lua,
1259 # and the renames of [g]libtool* with sudo.
1261 if [ -w /usr/local ]
1263 DO_MAKE_INSTALL="make install"
1264 DO_MAKE_UNINSTALL="make uninstall"
1268 DO_MAKE_INSTALL="sudo make install"
1269 DO_MAKE_UNINSTALL="sudo make uninstall"
1275 # If we have SDKs available, the default target OS is the major version
1276 # of the one we're running; get that and strip off the third component
1279 for i in /Developer/SDKs \
1280 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \
1281 /Library/Developer/CommandLineTools/SDKs
1285 min_osx_target=`sw_vers -productVersion | sed 's/\([0-9]*\)\.\([0-9]*\)\.[0-9]*/\1.\2/'`
1288 # That's also the OS whose SDK we'd be using.
1290 sdk_target=$min_osx_target
1296 # Parse command-line flags:
1299 # -t <target> - build libraries so that they'll work on the specified
1300 # version of OS X and later versions.
1301 # -u - do an uninstall.
1303 while getopts ht:u name
1310 min_osx_target="$OPTARG"
1313 echo "Usage: macosx-setup.sh [ -t <target> ] [ -u ]" 1>&1
1320 # Get the version numbers of installed packages, if any.
1322 if [ -d macosx-support-libs ]
1324 cd macosx-support-libs
1326 installed_xz_version=`ls xz-*-done 2>/dev/null | sed 's/xz-\(.*\)-done/\1/'`
1327 installed_autoconf_version=`ls autoconf-*-done 2>/dev/null | sed 's/autoconf-\(.*\)-done/\1/'`
1328 installed_automake_version=`ls automake-*-done 2>/dev/null | sed 's/automake-\(.*\)-done/\1/'`
1329 installed_libtool_version=`ls libtool-*-done 2>/dev/null | sed 's/libtool-\(.*\)-done/\1/'`
1330 installed_cmake_version=`ls cmake-*-done 2>/dev/null | sed 's/cmake-\(.*\)-done/\1/'`
1331 installed_gettext_version=`ls gettext-*-done 2>/dev/null | sed 's/gettext-\(.*\)-done/\1/'`
1332 installed_pkg_config_version=`ls pkg-config-*-done 2>/dev/null | sed 's/pkg-config-\(.*\)-done/\1/'`
1333 installed_glib_version=`ls glib-*-done 2>/dev/null | sed 's/glib-\(.*\)-done/\1/'`
1334 installed_qt_version=`ls qt-*-done 2>/dev/null | sed 's/qt-\(.*\)-done/\1/'`
1335 installed_libpng_version=`ls libpng-*-done 2>/dev/null | sed 's/libpng-\(.*\)-done/\1/'`
1336 installed_pixman_version=`ls pixman-*-done 2>/dev/null | sed 's/pixman-\(.*\)-done/\1/'`
1337 installed_cairo_version=`ls cairo-*-done 2>/dev/null | sed 's/cairo-\(.*\)-done/\1/'`
1338 installed_atk_version=`ls atk-*-done 2>/dev/null | sed 's/atk-\(.*\)-done/\1/'`
1339 installed_pango_version=`ls pango-*-done 2>/dev/null | sed 's/pango-\(.*\)-done/\1/'`
1340 installed_gdk_pixbuf_version=`ls gdk-pixbuf-*-done 2>/dev/null | sed 's/gdk-pixbuf-\(.*\)-done/\1/'`
1341 installed_gtk_version=`ls gtk+-*-done 2>/dev/null | sed 's/gtk+-\(.*\)-done/\1/'`
1342 installed_libsmi_version=`ls libsmi-*-done 2>/dev/null | sed 's/libsmi-\(.*\)-done/\1/'`
1343 installed_libgpg_error_version=`ls libgpg-error-*-done 2>/dev/null | sed 's/libgpg-error-\(.*\)-done/\1/'`
1344 installed_libgcrypt_version=`ls libgcrypt-*-done 2>/dev/null | sed 's/libgcrypt-\(.*\)-done/\1/'`
1345 installed_gnutls_version=`ls gnutls-*-done 2>/dev/null | sed 's/gnutls-\(.*\)-done/\1/'`
1346 installed_lua_version=`ls lua-*-done 2>/dev/null | sed 's/lua-\(.*\)-done/\1/'`
1347 installed_geoip_version=`ls geoip-*-done 2>/dev/null | sed 's/geoip-\(.*\)-done/\1/'`
1348 installed_cares_version=`ls c-ares-*-done 2>/dev/null | sed 's/c-ares-\(.*\)-done/\1/'`
1353 if [ "$do_uninstall" = "yes" ]
1360 # Configure scripts tend to set CFLAGS and CXXFLAGS to "-g -O2" if
1361 # invoked without CFLAGS or CXXFLAGS being set in the environment.
1363 # However, we *are* setting them in the environment, for our own
1364 # nefarious purposes, so start them out as "-g -O2".
1370 # To make this work on Leopard (rather than working *on* Snow Leopard
1371 # when building *for* Leopard) will take more work.
1373 # For one thing, Leopard's /usr/X11/lib/libXdamage.la claims, at least
1374 # with all software updates applied, that the Xdamage shared library
1375 # is libXdamage.1.0.0.dylib, but it is, in fact, libXdamage.1.1.0.dylib.
1376 # This causes problems when building GTK+, so the script would have to
1379 if [[ $DARWIN_MAJOR_VERSION -le 9 ]]; then
1380 echo "This script does not support any versions of OS X before Snow Leopard" 1>&2
1384 # if no make options are present, set default options
1385 if [ -z "$MAKE_BUILD_OPTS" ] ; then
1386 # by default use 1.5x number of cores for parallel build
1387 MAKE_BUILD_OPTS="-j $(( $(sysctl -n hw.logicalcpu) * 3 / 2))"
1391 # If we have a target release, look for the oldest SDK that's for an
1392 # OS equal to or later than that one, and build libraries against it
1393 # rather than against the headers and, more importantly, libraries
1394 # that come with the OS, so that we don't end up with support libraries
1395 # that only work on the OS version on which we built them, not earlier
1396 # versions of the same release, or earlier releases if the minimum is
1399 if [ ! -z "$min_osx_target" ]
1402 # Get the real version - strip off the "10.".
1403 # We'll worry about that if, as, and when there's ever
1406 deploy_real_version=`echo "$min_osx_target" | sed -n 's/10\.\(.*\)/\1/p'`
1409 # Search each directory that might contain SDKs.
1412 for sdksdir in /Developer/SDKs \
1413 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \
1414 /Library/Developer/CommandLineTools/SDKs
1417 # Get a list of all the SDKs.
1419 if ! test -d "$sdksdir"
1422 # There is no directory with that name.
1423 # Move on to the next one in the list, if any.
1429 # Get a list of all the SDKs in that directory, if any.
1431 sdklist=`(cd "$sdksdir"; ls -d MacOSX10.[0-9]*.sdk 2>/dev/null)`
1436 # Get the real version for this SDK.
1438 sdk_real_version=`echo "$sdk" | sed -n 's/MacOSX10\.\(.*\)\.sdk/\1/p'`
1441 # Is it for the deployment target or some later release?
1443 if test "$sdk_real_version" -ge "$deploy_real_version"
1448 sdkpath="$sdksdir/$sdk"
1449 qt_sdk_arg="-sdk $sdk"
1455 if [ -z "$sdkpath" ]
1457 echo "macosx-setup.sh: Couldn't find an SDK for OS X $min_osx_target or later" 1>&2
1462 sdk_target=10.$sdk_real_version
1463 echo "Using the 10.$sdk_real_version SDK"
1466 # Make sure there are links to /usr/local/include and /usr/local/lib
1467 # in the SDK's usr/local.
1469 if [ ! -e $SDKPATH/usr/local/include ]
1471 if [ ! -d $SDKPATH/usr/local ]
1473 sudo mkdir $SDKPATH/usr/local
1475 sudo ln -s /usr/local/include $SDKPATH/usr/local/include
1477 if [ ! -e $SDKPATH/usr/local/lib ]
1479 if [ ! -d $SDKPATH/usr/local ]
1481 sudo mkdir $SDKPATH/usr/local
1483 sudo ln -s /usr/local/lib $SDKPATH/usr/local/lib
1487 # Set the minimum OS version for which to build to the specified
1488 # minimum target OS version, so we don't, for example, end up using
1489 # linker features supported by the OS verson on which we're building
1490 # but not by the target version.
1492 VERSION_MIN_FLAGS="-mmacosx-version-min=$min_osx_target"
1495 # Compile and link against the SDK.
1497 SDKFLAGS="-isysroot $SDKPATH"
1499 if [[ "$min_osx_target" == "10.5" ]]
1502 # Cairo is part of Mac OS X 10.6 and later.
1503 # The *headers* are supplied by 10.5, but the *libraries*
1504 # aren't, so we have to build it if we're building for 10.5.
1506 cairo_not_in_the_os=yes
1509 # Build with older versions of the support libraries, as
1510 # were used on the Wireshark Leopard buildbot at one
1511 # point. (Most of these versions come from the About page
1512 # from Wireshark 1.8.6, the last build done on that buildbot;
1513 # the ATK version isn't reported, so this is a guess.)
1515 # If you want to try building with newer versions of
1516 # the libraries, note that:
1518 # The version of fontconfig that comes with Leopard doesn't
1519 # support FC_WEIGHT_EXTRABLACK, so we can't use any version
1520 # of Pango newer than 1.22.4.
1522 # However, Pango 1.22.4 doesn't work with versions of GLib
1523 # after 2.29.6, because Pango 1.22.4 uses G_CONST_RETURN and
1524 # GLib 2.29.8 and later deprecate it (there doesn't appear to
1525 # be a GLib 2.29.7). That means we'd either have to patch
1526 # Pango not to use it (just use "const"; G_CONST_RETURN was
1527 # there to allow code to choose whether to use "const" or not),
1528 # or use GLib 2.29.6 or earlier.
1530 # GLib 2.29.6 includes an implementation of g_bit_lock() that,
1531 # on x86 (32-bit and 64-bit), uses asms in a fashion
1532 # ("asm volatile goto") that requires GCC 4.5 or later, which
1533 # is later than the compilers that come with Leopard and Snow
1534 # Leopard. Recent versions of GLib check for that, but 2.29.6
1535 # doesn't, so, if you want to build GLib 2.29.6 on Leopard or
1536 # Snow Leopard, you would have to patch glib/gbitlock.c to do
1537 # what the newer versions of GLib do:
1539 # define a USE_ASM_GOTO macro that indicates whether "asm goto"
1541 # #if (defined (i386) || defined (__amd64__))
1542 # #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
1543 # #define USE_ASM_GOTO 1
1547 # replace all occurrences of
1549 # #if defined (__GNUC__) && (defined (i386) || defined (__amd64__))
1553 # #ifdef USE_ASM_GOTO
1555 # Using GLib 2.29.6 or earlier, however, means that we can't
1556 # use a version of ATK later than 2.3.93, as those versions
1557 # don't work with GLib 2.29.6. The same applies to gdk-pixbuf;
1558 # versions of gdk-pixbuf after 2.24.1 won't work with GLib
1561 # Then you have to make sure that what you've build doesn't
1562 # cause the X server that comes with Leopard to crash; at
1563 # least one attempt at building for Leopard did.
1565 # At least if building on Leopard, you might also find
1566 # that, with various older versions of Cairo, including
1567 # 1.6.4 and at least some 1.8.x versions, when you try to
1568 # build it, the build fails because it can't find
1569 # png_set_longjmp_fn(). I vaguely remember dealing with that,
1570 # ages ago, but don't remember what I did.
1575 PANGO_VERSION=1.20.2
1579 # That version of GTK+ includes gdk-pixbuf.
1580 # XXX - base this on the version of GTK+ requested.
1585 # Libgcrypt 1.5.0 fails to compile due to some problem with an
1586 # asm in rijndael.c, at least with i686-apple-darwin10-gcc-4.2.1
1587 # (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3) when building
1590 # We try libgcrypt 1.4.3 instead, as that's what shows up in
1591 # the version from the Leopard buildbot.
1592 LIBGCRYPT_VERSION=1.4.3
1595 # Build 32-bit while we're at it; Leopard has a bug that
1596 # causes some BPF functions not to work with 64-bit userland
1597 # code, so capturing won't work.
1599 CFLAGS="$CFLAGS -arch i386"
1600 CXXFLAGS="$CXXFLAGS -arch i386"
1601 export LDFLAGS="$LDFLAGS -arch i386"
1609 # You need Xcode or the command-line tools installed to get the compilers.
1611 if [ ! -x /usr/bin/xcodebuild ]; then
1612 echo "Please install Xcode first (should be available on DVD or from http://developer.apple.com/xcode/index.php)."
1616 if [ "$QT_VERSION" ]; then
1618 # We need Xcode, not just the command-line tools, installed to build
1621 if ! /usr/bin/xcrun -find xcrun >/dev/null 2>&1; then
1622 echo "Please install Xcode first (should be available on DVD or from http://developer.apple.com/xcode/index.php)."
1623 echo "The command-line build tools are not sufficient to build Qt."
1627 if [ "$GTK_VERSION" ]; then
1629 # If we're building with GTK+, you also need the X11 SDK; with at least
1630 # some versions of OS X and Xcode, that is, I think, an optional install.
1631 # (Or it might be installed with X11, but I think *that* is an optional
1632 # install on at least some versions of OS X.)
1634 if [ ! -d /usr/X11/include ]; then
1635 echo "Please install X11 and the X11 SDK first."
1636 echo " You can either use http://xquartz.macosforge.org/, e.g."
1637 echo " http://xquartz-dl.macosforge.org/SL/XQuartz-$XQUARTZ_VERSION.dmg"
1638 echo " or the native Apple packages if you are on Lion or below."
1643 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig
1646 # Do all the downloads and untarring in a subdirectory, so all that
1647 # stuff can be removed once we've installed the support libraries.
1649 if [ ! -d macosx-support-libs ]
1651 mkdir macosx-support-libs || exit 1
1653 cd macosx-support-libs
1659 echo "You are now prepared to build Wireshark. To do so do:"
1660 echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig"
1662 if [ -n "$CMAKE" ]; then
1663 echo "mkdir build; cd build"
1670 echo "mkdir build; cd build"
1673 echo "make $MAKE_BUILD_OPTS"
1678 echo "Make sure you are allowed capture access to the network devices"
1679 echo "See: http://wiki.wireshark.org/CaptureSetup/CapturePrivileges"