2 # Setup development environment on macOS (tested with 10.6.8 and Xcode
3 # 3.2.6 and with 10.12.4 and Xcode 8.3).
5 # Copyright 2011 Michael Tuexen, Joerg Mayer, Guy Harris (see AUTHORS file)
7 # Wireshark - Network traffic analyzer
8 # By Gerald Combs <gerald@wireshark.org>
9 # Copyright 1998 Gerald Combs
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License
13 # as published by the Free Software Foundation; either version 2
14 # of the License, or (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 # To install autotools
34 # To build all libraries as 32-bit libraries uncomment the following three lines.
36 # export CFLAGS="$CFLAGS -arch i386"
37 # export CXXFLAGS="$CXXFLAGS -arch i386"
38 # export LDFLAGS="$LDFLAGS -arch i386"
40 # and change "macx-clang" to "macx-clang-32" in the line below.
42 # Note: when building against the 10.6 SDK, clang fails, because there's
43 # a missing libstdc++.dylib in the SDK; this does not bother g++, however.
45 #TARGET_PLATFORM=macx-g++
46 TARGET_PLATFORM=macx-clang
49 # Versions of packages to download and install.
53 # Some packages need xz to unpack their current source.
54 # While tar, in newer versions of macOS, can uncompress xz'ed tarballs,
55 # it can't do so in older versions, and xz isn't provided with macOS.
60 # Some packages need lzip to unpack their current source.
65 # In case we want to build with cmake.
67 CMAKE_VERSION=${CMAKE_VERSION-2.8.12.2}
70 # The following libraries and tools are required even to build only TShark.
72 GETTEXT_VERSION=0.18.2
74 PKG_CONFIG_VERSION=0.28
76 # libgpg-error is required for libgcrypt.
78 LIBGPG_ERROR_VERSION=1.27
80 # libgcrypt is required.
82 LIBGCRYPT_VERSION=1.7.7
85 # One or more of the following libraries are required to build Wireshark.
87 # To override the version of Qt or build the deprecated GTK interface call
88 # the script with some of the variables set to the new values. Setting a
89 # variable to empty will disable building the toolkit and will uninstall
90 # any version previously installed by the script, e.g.
91 # "GTK_VERSION=3.5.2 QT_VERSION= ./macos-setup.sh"
92 # will build and install with GTK+ 3.5.2 and will not install Qt (and,
93 # if the script installed Qt earlier, will un-install that version of Qt).
95 # Note that Qt 5, prior to 5.5.0, mishandles context menus in ways that,
96 # for example, cause them not to work reliably in the packet detail or
97 # packet data pane; see, for example, Qt bugs QTBUG-31937, QTBUG-41017,
98 # and QTBUG-43464, all of which seem to be the same bug.
100 QT_VERSION=${QT_VERSION-5.8.0}
101 #GTK_VERSION=${GTK_VERSION-2.24.17}
102 if [ "$GTK_VERSION" ]; then
104 # We'll be building GTK+, so we need some additional libraries.
106 GTK_MAJOR_VERSION="`expr $GTK_VERSION : '\([0-9][0-9]*\).*'`"
107 GTK_MINOR_VERSION="`expr $GTK_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
108 GTK_DOTDOT_VERSION="`expr $GTK_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
113 PIXMAN_VERSION=0.26.0
115 GDK_PIXBUF_VERSION=2.28.0
117 if [ "$QT_VERSION" ]; then
118 QT_MAJOR_VERSION="`expr $QT_VERSION : '\([0-9][0-9]*\).*'`"
119 QT_MINOR_VERSION="`expr $QT_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
120 QT_DOTDOT_VERSION="`expr $QT_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
121 QT_MAJOR_MINOR_VERSION=$QT_MAJOR_VERSION.$QT_MINOR_VERSION
122 QT_MAJOR_MINOR_DOTDOT_VERSION=$QT_MAJOR_VERSION.$QT_MINOR_VERSION.$QT_DOTDOT_VERSION
126 # The following libraries are optional.
127 # Comment them out if you don't want them, but note that some of
128 # the optional libraries are required by other optional libraries.
131 GNUTLS_VERSION=3.4.17
132 if [ "$GNUTLS_VERSION" ]; then
134 # We'll be building GnuTLS, so we may need some additional libraries.
135 # We assume GnuTLS can work with Nettle; newer versions *only* use
136 # Nettle, not libgcrypt.
138 GNUTLS_MAJOR_VERSION="`expr $GNUTLS_VERSION : '\([0-9][0-9]*\).*'`"
139 GNUTLS_MINOR_VERSION="`expr $GNUTLS_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
140 GNUTLS_DOTDOT_VERSION="`expr $GNUTLS_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
144 # And, in turn, Nettle requires GMP.
148 # Use 5.2.4, not 5.3, for now; lua_bitop.c hasn't been ported to 5.3
149 # yet, and we need to check for compatibility issues (we'd want Lua
150 # scripts to work with 5.1, 5.2, and 5.3, as long as they only use Lua
151 # features present in all three versions)
153 PORTAUDIO_VERSION=pa_stable_v19_20111121
155 LIBXML2_VERSION=2.9.4
164 NGHTTP2_VERSION=1.14.0
166 DARWIN_MAJOR_VERSION=`uname -r | sed 's/\([0-9]*\).*/\1/'`
169 # GNU autotools; they're provided with releases up to Snow Leopard, but
170 # not in later releases, and the Snow Leopard version is too old for
171 # current Wireshark, so we install them unconditionally.
173 AUTOCONF_VERSION=2.69
174 AUTOMAKE_VERSION=1.13.3
175 LIBTOOL_VERSION=2.4.6
178 if [ "$XZ_VERSION" -a ! -f xz-$XZ_VERSION-done ] ; then
179 echo "Downloading, building, and installing xz:"
180 [ -f xz-$XZ_VERSION.tar.bz2 ] || curl -L -O http://tukaani.org/xz/xz-$XZ_VERSION.tar.bz2 || exit 1
181 $no_build && echo "Skipping installation" && return
182 bzcat xz-$XZ_VERSION.tar.bz2 | tar xf - || exit 1
184 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0" ./configure || exit 1
185 make $MAKE_BUILD_OPTS || exit 1
186 $DO_MAKE_INSTALL || exit 1
188 touch xz-$XZ_VERSION-done
193 if [ ! -z "$installed_xz_version" ] ; then
194 echo "Uninstalling xz:"
195 cd xz-$installed_xz_version
196 $DO_MAKE_UNINSTALL || exit 1
197 make distclean || exit 1
199 rm xz-$installed_xz_version-done
201 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
203 # Get rid of the previously downloaded and unpacked version.
205 rm -rf xz-$installed_xz_version
206 rm -rf xz-$installed_xz_version.tar.bz2
209 installed_xz_version=""
214 if [ "$LZIP_VERSION" -a ! -f lzip-$LZIP_VERSION-done ] ; then
215 echo "Downloading, building, and installing lzip:"
216 [ -f lzip-$LZIP_VERSION.tar.gz ] || curl -L -O http://download.savannah.gnu.org/releases/lzip/lzip-$LZIP_VERSION.tar.gz || exit 1
217 $no_build && echo "Skipping installation" && return
218 gzcat lzip-$LZIP_VERSION.tar.gz | tar xf - || exit 1
219 cd lzip-$LZIP_VERSION
220 ./configure || exit 1
221 make $MAKE_BUILD_OPTS || exit 1
222 $DO_MAKE_INSTALL || exit 1
224 touch lzip-$LZIP_VERSION-done
229 if [ ! -z "$installed_lzip_version" ] ; then
230 echo "Uninstalling lzip:"
231 cd lzip-$installed_lzip_version
232 $DO_MAKE_UNINSTALL || exit 1
233 make distclean || exit 1
235 rm lzip-$installed_lzip_version-done
237 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
239 # Get rid of the previously downloaded and unpacked version.
241 rm -rf lzip-$installed_lzip_version
242 rm -rf lzip-$installed_lzip_version.tar.gz
245 installed_lzip_version=""
250 if [ "$AUTOCONF_VERSION" -a ! -f autoconf-$AUTOCONF_VERSION-done ] ; then
251 echo "Downloading, building and installing GNU autoconf..."
252 [ -f autoconf-$AUTOCONF_VERSION.tar.xz ] || curl -L -O ftp://ftp.gnu.org/gnu/autoconf/autoconf-$AUTOCONF_VERSION.tar.xz || exit 1
253 $no_build && echo "Skipping installation" && return
254 xzcat autoconf-$AUTOCONF_VERSION.tar.xz | tar xf - || exit 1
255 cd autoconf-$AUTOCONF_VERSION
256 ./configure || exit 1
257 make $MAKE_BUILD_OPTS || exit 1
258 $DO_MAKE_INSTALL || exit 1
260 touch autoconf-$AUTOCONF_VERSION-done
264 uninstall_autoconf() {
265 if [ ! -z "$installed_autoconf_version" ] ; then
267 # automake and libtool depend on this, so uninstall them.
272 echo "Uninstalling GNU autoconf:"
273 cd autoconf-$installed_autoconf_version
274 $DO_MAKE_UNINSTALL || exit 1
275 make distclean || exit 1
277 rm autoconf-$installed_autoconf_version-done
279 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
281 # Get rid of the previously downloaded and unpacked version.
283 rm -rf autoconf-$installed_autoconf_version
284 rm -rf autoconf-$installed_autoconf_version.tar.xz
287 installed_autoconf_version=""
292 if [ "$AUTOMAKE_VERSION" -a ! -f automake-$AUTOMAKE_VERSION-done ] ; then
293 echo "Downloading, building and installing GNU automake..."
294 [ -f automake-$AUTOMAKE_VERSION.tar.xz ] || curl -L -O ftp://ftp.gnu.org/gnu/automake/automake-$AUTOMAKE_VERSION.tar.xz || exit 1
295 $no_build && echo "Skipping installation" && return
296 xzcat automake-$AUTOMAKE_VERSION.tar.xz | tar xf - || exit 1
297 cd automake-$AUTOMAKE_VERSION
298 ./configure || exit 1
299 make $MAKE_BUILD_OPTS || exit 1
300 $DO_MAKE_INSTALL || exit 1
302 touch automake-$AUTOMAKE_VERSION-done
306 uninstall_automake() {
307 if [ ! -z "$installed_automake_version" ] ; then
309 # libtool depends on this(?), so uninstall it.
311 uninstall_libtool "$@"
313 echo "Uninstalling GNU automake:"
314 cd automake-$installed_automake_version
315 $DO_MAKE_UNINSTALL || exit 1
316 make distclean || exit 1
318 rm automake-$installed_automake_version-done
320 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
322 # Get rid of the previously downloaded and unpacked version.
324 rm -rf automake-$installed_automake_version
325 rm -rf automake-$installed_automake_version.tar.xz
328 installed_automake_version=""
333 if [ "$LIBTOOL_VERSION" -a ! -f libtool-$LIBTOOL_VERSION-done ] ; then
334 echo "Downloading, building and installing GNU libtool..."
335 [ -f libtool-$LIBTOOL_VERSION.tar.xz ] || curl -L -O ftp://ftp.gnu.org/gnu/libtool/libtool-$LIBTOOL_VERSION.tar.xz || exit 1
336 $no_build && echo "Skipping installation" && return
337 xzcat libtool-$LIBTOOL_VERSION.tar.xz | tar xf - || exit 1
338 cd libtool-$LIBTOOL_VERSION
339 ./configure || exit 1
340 make $MAKE_BUILD_OPTS || exit 1
341 $DO_MAKE_INSTALL || exit 1
342 $DO_MV /usr/local/bin/libtool /usr/local/bin/glibtool
343 $DO_MV /usr/local/bin/libtoolize /usr/local/bin/glibtoolize
345 touch libtool-$LIBTOOL_VERSION-done
349 uninstall_libtool() {
350 if [ ! -z "$installed_libtool_version" ] ; then
351 echo "Uninstalling GNU libtool:"
352 cd libtool-$installed_libtool_version
353 $DO_MV /usr/local/bin/glibtool /usr/local/bin/libtool
354 $DO_MV /usr/local/bin/glibtoolize /usr/local/bin/libtoolize
355 $DO_MAKE_UNINSTALL || exit 1
356 make distclean || exit 1
358 rm libtool-$installed_libtool_version-done
360 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
362 # Get rid of the previously downloaded and unpacked version.
364 rm -rf libtool-$installed_libtool_version
365 rm -rf libtool-$installed_libtool_version.tar.xz
368 installed_libtool_version=""
373 if [ -n "$CMAKE" -a ! -f cmake-$CMAKE_VERSION-done ]; then
374 echo "Downloading and installing CMake:"
375 CMAKE_MAJOR_VERSION="`expr $CMAKE_VERSION : '\([0-9][0-9]*\).*'`"
376 CMAKE_MINOR_VERSION="`expr $CMAKE_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
377 CMAKE_DOTDOT_VERSION="`expr $CMAKE_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
378 CMAKE_MAJOR_MINOR_VERSION=$CMAKE_MAJOR_VERSION.$CMAKE_MINOR_VERSION
381 # NOTE: the "64" in "Darwin64" doesn't mean "64-bit-only"; the
382 # package in question supports both 32-bit and 64-bit x86.
384 case "$CMAKE_MAJOR_VERSION" in
387 echo "CMake $CMAKE_VERSION" is too old 1>&2
392 # Download the DMG, run the installer.
394 [ -f cmake-$CMAKE_VERSION-Darwin64-universal.dmg ] || curl -L -O https://cmake.org/files/v$CMAKE_MAJOR_MINOR_VERSION/cmake-$CMAKE_VERSION-Darwin64-universal.dmg || exit 1
395 $no_build && echo "Skipping installation" && return
396 sudo hdiutil attach cmake-$CMAKE_VERSION-Darwin64-universal.dmg || exit 1
397 sudo installer -target / -pkg /Volumes/cmake-$CMAKE_VERSION-Darwin64-universal/cmake-$CMAKE_VERSION-Darwin64-universal.pkg || exit 1
398 sudo hdiutil detach /Volumes/cmake-$CMAKE_VERSION-Darwin64-universal
403 # Download the DMG and do a drag install, where "drag" means
406 # 3.0.* and 3.1.0 have a Darwin64-universal DMG.
407 # 3.1.1 and later have a Darwin-x86_64 DMG.
408 # Probably not many people are still developing on 32-bit
409 # Macs, so we don't worry about them.
411 if [ "$CMAKE_MINOR_VERSION" = 0 -o \
412 "$CMAKE_VERSION" = 3.1.0 ]; then
413 type="Darwin64-universal"
417 [ -f cmake-$CMAKE_VERSION-$type.dmg ] || curl -L -O https://cmake.org/files/v$CMAKE_MAJOR_MINOR_VERSION/cmake-$CMAKE_VERSION-$type.dmg || exit 1
418 $no_build && echo "Skipping installation" && return
419 sudo hdiutil attach cmake-$CMAKE_VERSION-$type.dmg || exit 1
420 sudo ditto /Volumes/cmake-$CMAKE_VERSION-$type/CMake.app /Applications/CMake.app || exit 1
423 # Plant the appropriate symbolic links in /usr/local/bin.
424 # It's a drag-install, so there's no installer to make them,
425 # and the CMake code to put them in place is lame, as
427 # 1) it defaults to /usr/bin, not /usr/local/bin;
428 # 2) it doesn't request the necessary root privileges;
429 # 3) it can't be run from the command line;
431 # so we do it ourselves.
433 for i in ccmake cmake cmake-gui cmakexbuild cpack ctest
435 sudo ln -s /Applications/CMake.app/Contents/bin/$i /usr/local/bin/$i
437 sudo hdiutil detach /Volumes/cmake-$CMAKE_VERSION-$type
443 touch cmake-$CMAKE_VERSION-done
448 if [ ! -z "$installed_cmake_version" ]; then
449 echo "Uninstalling CMake:"
450 installed_cmake_major_version="`expr $installed_cmake_version : '\([0-9][0-9]*\).*'`"
451 case "$installed_cmake_major_version" in
454 echo "CMake $installed_cmake_version" is too old 1>&2
458 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
459 for i in ccmake cmake cmake-gui cmakexbuild cpack ctest
461 sudo rm -f /usr/bin/$i /usr/local/bin/$i
463 sudo pkgutil --forget com.Kitware.CMake
464 rm cmake-$installed_cmake_version-done
468 sudo rm -rf /Applications/CMake.app
469 for i in ccmake cmake cmake-gui cmakexbuild cpack ctest
471 sudo rm -f /usr/local/bin/$i
473 rm cmake-$installed_cmake_version-done
477 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
479 # Get rid of the previously downloaded and unpacked version,
480 # whatever it might happen to be called.
482 rm -f cmake-$installed_cmake_version-Darwin64-universal.dmg
483 rm -f cmake-$installed_cmake_version-Darwin-x86_64.dmg
486 installed_cmake_version=""
491 if [ ! -f gettext-$GETTEXT_VERSION-done ] ; then
492 echo "Downloading, building, and installing GNU gettext:"
493 [ -f gettext-$GETTEXT_VERSION.tar.gz ] || curl -L -O http://ftp.gnu.org/pub/gnu/gettext/gettext-$GETTEXT_VERSION.tar.gz || exit 1
494 $no_build && echo "Skipping installation" && return
495 gzcat gettext-$GETTEXT_VERSION.tar.gz | tar xf - || exit 1
496 cd gettext-$GETTEXT_VERSION
497 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
498 make $MAKE_BUILD_OPTS || exit 1
499 $DO_MAKE_INSTALL || exit 1
501 touch gettext-$GETTEXT_VERSION-done
505 uninstall_gettext() {
506 if [ ! -z "$installed_gettext_version" ] ; then
508 # GLib depends on this, so uninstall it.
512 echo "Uninstalling GNU gettext:"
513 cd gettext-$installed_gettext_version
514 $DO_MAKE_UNINSTALL || exit 1
515 make distclean || exit 1
517 rm gettext-$installed_gettext_version-done
519 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
521 # Get rid of the previously downloaded and unpacked version.
523 rm -rf gettext-$installed_gettext_version
524 rm -rf gettext-$installed_gettext_version.tar.gz
527 installed_gettext_version=""
531 install_pkg_config() {
532 if [ ! -f pkg-config-$PKG_CONFIG_VERSION-done ] ; then
533 echo "Downloading, building, and installing pkg-config:"
534 [ -f pkg-config-$PKG_CONFIG_VERSION.tar.gz ] || curl -L -O https://pkgconfig.freedesktop.org/releases/pkg-config-$PKG_CONFIG_VERSION.tar.gz || exit 1
535 $no_build && echo "Skipping installation" && return
536 gzcat pkg-config-$PKG_CONFIG_VERSION.tar.gz | tar xf - || exit 1
537 cd pkg-config-$PKG_CONFIG_VERSION
538 ./configure --with-internal-glib || exit 1
539 make $MAKE_BUILD_OPTS || exit 1
540 $DO_MAKE_INSTALL || exit 1
542 touch pkg-config-$PKG_CONFIG_VERSION-done
546 uninstall_pkg_config() {
547 if [ ! -z "$installed_pkg_config_version" ] ; then
548 echo "Uninstalling pkg-config:"
549 cd pkg-config-$installed_pkg_config_version
550 $DO_MAKE_UNINSTALL || exit 1
551 make distclean || exit 1
553 rm pkg-config-$installed_pkg_config_version-done
555 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
557 # Get rid of the previously downloaded and unpacked version.
559 rm -rf pkg-config-$installed_pkg_config_version
560 rm -rf pkg-config-$installed_pkg_config_version.tar.gz
563 installed_pkg_config_version=""
568 if [ ! -f glib-$GLIB_VERSION-done ] ; then
569 echo "Downloading, building, and installing GLib:"
570 glib_dir=`expr $GLIB_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
571 GLIB_MAJOR_VERSION="`expr $GLIB_VERSION : '\([0-9][0-9]*\).*'`"
572 GLIB_MINOR_VERSION="`expr $GLIB_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
573 GLIB_DOTDOT_VERSION="`expr $GLIB_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
574 if [[ $GLIB_MAJOR_VERSION -gt 2 ||
575 ($GLIB_MAJOR_VERSION -eq 2 && $GLIB_MINOR_VERSION -gt 28) ||
576 ($GLIB_MAJOR_VERSION -eq 2 && $GLIB_MINOR_VERSION -eq 28 && $GLIB_DOTDOT_VERSION -ge 8) ]]
579 # Starting with GLib 2.28.8, xz-compressed tarballs are available.
581 [ -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
582 $no_build && echo "Skipping installation" && return
583 xzcat glib-$GLIB_VERSION.tar.xz | tar xf - || exit 1
585 [ -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
586 $no_build && echo "Skipping installation" && return
587 bzcat glib-$GLIB_VERSION.tar.bz2 | tar xf - || exit 1
589 cd glib-$GLIB_VERSION
591 # macOS ships with libffi, but doesn't provide its pkg-config file;
592 # explicitly specify LIBFFI_CFLAGS and LIBFFI_LIBS, so the configure
593 # script doesn't try to use pkg-config to get the appropriate
594 # C flags and loader flags.
596 # And, what's worse, at least with the version of Xcode that comes
597 # with Leopard, /usr/include/ffi/fficonfig.h doesn't define MACOSX,
598 # which causes the build of GLib to fail. If we don't find
599 # "#define.*MACOSX" in /usr/include/ffi/fficonfig.h, explicitly
602 # While we're at it, suppress -Wformat-nonliteral to avoid a case
603 # where clang's stricter rules on when not to complain about
604 # non-literal format arguments cause it to complain about code
605 # that's safe but it wasn't told that. See my comment #25 in
608 # https://bugzilla.gnome.org/show_bug.cgi?id=691608#c25
610 # First, determine where the system include files are. (It's not
611 # necessarily /usr/include.) There's a bit of a greasy hack here;
612 # pre-5.x versions of the developer tools don't support the
613 # --show-sdk-path option, and will produce no output, so includedir
614 # will be set to /usr/include (in those older versions of the
615 # developer tools, there is a /usr/include directory).
617 includedir=`xcrun --show-sdk-path 2>/dev/null`/usr/include
618 if grep -qs '#define.*MACOSX' $includedir/ffi/fficonfig.h
620 # It's defined, nothing to do
621 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
623 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
627 # Apply the fix to GNOME bug 529806:
629 # https://bugzilla.gnome.org/show_bug.cgi?id=529806
631 # if we have a version of GLib prior to 2.30.
633 if [[ $GLIB_MAJOR_VERSION -eq 2 && $GLIB_MINOR_VERSION -le 30 ]]
635 patch -p0 <../../macosx-support-lib-patches/glib-gconvert.c.patch || exit 1
637 make $MAKE_BUILD_OPTS || exit 1
638 $DO_MAKE_INSTALL || exit 1
640 touch glib-$GLIB_VERSION-done
645 if [ ! -z "$installed_glib_version" ] ; then
647 # ATK, Pango, and GTK depend on this, so uninstall them.
653 echo "Uninstalling GLib:"
654 cd glib-$installed_glib_version
655 $DO_MAKE_UNINSTALL || exit 1
656 make distclean || exit 1
658 rm glib-$installed_glib_version-done
660 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
662 # Get rid of the previously downloaded and unpacked version.
664 rm -rf glib-$installed_glib_version
665 rm -rf glib-$installed_glib_version.tar.xz glib-$installed_glib_version.tar.bz2
668 installed_glib_version=""
673 if [ "$QT_VERSION" -a ! -f qt-$QT_VERSION-done ]; then
674 echo "Downloading, building, and installing Qt:"
676 # What you get for this URL might just be a 302 Found reply, so use
677 # -L so we get redirected.
679 if [ "$QT_MAJOR_VERSION" -ge 5 ]
681 QT_VOLUME=qt-opensource-mac-x64-clang-$QT_VERSION
683 QT_VOLUME=qt-opensource-mac-$QT_VERSION
685 [ -f $QT_VOLUME.dmg ] || curl -L -O http://download.qt.io/archive/qt/$QT_MAJOR_MINOR_VERSION/$QT_MAJOR_MINOR_DOTDOT_VERSION/$QT_VOLUME.dmg || exit 1
686 $no_build && echo "Skipping installation" && return
687 sudo hdiutil attach $QT_VOLUME.dmg || exit 1
689 if [ "$QT_MAJOR_VERSION" -ge 5 ]
692 # Run the installer executable directly, so that we wait for
693 # it to finish. Then unmount the volume.
695 /Volumes/$QT_VOLUME/$QT_VOLUME.app/Contents/MacOS/$QT_VOLUME
696 sudo hdiutil detach /Volumes/$QT_VOLUME
699 # Open the installer package; use -W, so that we wait for
700 # the installer to finish. Then unmount the volume.
702 open -W "/Volumes/Qt $QT_MAJOR_MINOR_DOTDOT_VERSION/Qt.mpkg"
703 sudo hdiutil detach "/Volumes/Qt $QT_MAJOR_MINOR_DOTDOT_VERSION"
707 # Versions 5.3.x through 5.5.0, at least, have bogus .pc files.
708 # See bugs QTBUG-35256 and QTBUG-47162.
712 for i in $HOME/Qt$QT_VERSION/$QT_MAJOR_MINOR_VERSION/clang_64/lib/pkgconfig/*.pc
716 g/Cflags: /s;;Cflags: -F\${libdir} ;
717 g/Cflags: /s;-I\${includedir}/Qt\([a-zA-Z0-9_]*\);-I\${libdir}/Qt\1.framework/Versions/5/Headers;
723 touch qt-$QT_VERSION-done
728 if [ ! -z "$installed_qt_version" ] ; then
729 echo "Uninstalling Qt:"
730 rm -rf $HOME/Qt$installed_qt_version
731 rm qt-$installed_qt_version-done
733 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
735 # Get rid of the previously downloaded version.
737 rm -rf qt-opensource-mac-x64-clang-$installed_qt_version.dmg
740 installed_qt_version=""
745 if [ ! -f libpng-$PNG_VERSION-done ] ; then
746 echo "Downloading, building, and installing libpng:"
748 # The FTP site puts libpng x.y.* into a libpngxy directory.
750 subdir=`echo $PNG_VERSION | sed 's/\([1-9][0-9]*\)\.\([1-9][0-9]*\).*/libpng\1\2'/`
751 [ -f libpng-$PNG_VERSION.tar.xz ] || curl -L -O ftp://ftp.simplesystems.org/pub/libpng/png/src/$subdir/libpng-$PNG_VERSION.tar.xz
752 $no_build && echo "Skipping installation" && return
753 xzcat libpng-$PNG_VERSION.tar.xz | tar xf - || exit 1
754 cd libpng-$PNG_VERSION
755 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
756 make $MAKE_BUILD_OPTS || exit 1
757 $DO_MAKE_INSTALL || exit 1
759 touch libpng-$PNG_VERSION-done
764 if [ ! -z "$installed_libpng_version" ] ; then
766 # Cairo depends on this, so uninstall it.
770 echo "Uninstalling libpng:"
771 cd libpng-$installed_libpng_version
772 $DO_MAKE_UNINSTALL || exit 1
773 make distclean || exit 1
775 rm libpng-$installed_libpng_version-done
777 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
779 # Get rid of the previously downloaded and unpacked version.
781 rm -rf libpng-$installed_libpng_version
782 rm -rf libpng-$installed_libpng_version.tar.xz
785 installed_libpng_version=""
790 if [ ! -f pixman-$PIXMAN_VERSION-done ] ; then
791 echo "Downloading, building, and installing pixman:"
792 [ -f pixman-$PIXMAN_VERSION.tar.gz ] || curl -L -O http://www.cairographics.org/releases/pixman-$PIXMAN_VERSION.tar.gz
793 $no_build && echo "Skipping installation" && return
794 gzcat pixman-$PIXMAN_VERSION.tar.gz | tar xf - || exit 1
795 cd pixman-$PIXMAN_VERSION
796 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
797 make $MAKE_BUILD_OPTS || exit 1
798 $DO_MAKE_INSTALL || exit 1
800 touch pixman-$PIXMAN_VERSION-done
805 if [ ! -z "$installed_pixman_version" ] ; then
807 # Cairo depends on this, so uninstall it.
811 echo "Uninstalling pixman:"
812 cd pixman-$installed_pixman_version
813 $DO_MAKE_UNINSTALL || exit 1
814 make distclean || exit 1
816 rm pixman-$installed_pixman_version-done
818 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
820 # Get rid of the previously downloaded and unpacked version.
822 rm -rf pixman-$installed_pixman_version
823 rm -rf pixman-$installed_pixman_version.tar.gz
826 installed_pixman_version=""
831 if [ ! -f cairo-$CAIRO_VERSION-done ] ; then
832 echo "Downloading, building, and installing Cairo:"
833 CAIRO_MAJOR_VERSION="`expr $CAIRO_VERSION : '\([0-9][0-9]*\).*'`"
834 CAIRO_MINOR_VERSION="`expr $CAIRO_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
835 CAIRO_DOTDOT_VERSION="`expr $CAIRO_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
836 if [[ $CAIRO_MAJOR_VERSION -gt 1 ||
837 ($CAIRO_MAJOR_VERSION -eq 2 && $CAIRO_MINOR_VERSION -gt 12) ||
838 ($CAIRO_MAJOR_VERSION -eq 2 && $CAIRO_MINOR_VERSION -eq 12 && $CAIRO_DOTDOT_VERSION -ge 2) ]]
841 # Starting with Cairo 1.12.2, the tarballs are compressed with
842 # xz rather than gzip.
844 [ -f cairo-$CAIRO_VERSION.tar.xz ] || curl -L -O http://cairographics.org/releases/cairo-$CAIRO_VERSION.tar.xz || exit 1
845 $no_build && echo "Skipping installation" && return
846 xzcat cairo-$CAIRO_VERSION.tar.xz | tar xf - || exit 1
848 [ -f cairo-$CAIRO_VERSION.tar.gz ] || curl -L -O http://cairographics.org/releases/cairo-$CAIRO_VERSION.tar.gz || exit 1
849 $no_build && echo "Skipping installation" && return
850 gzcat cairo-$CAIRO_VERSION.tar.gz | tar xf - || exit 1
852 cd cairo-$CAIRO_VERSION
853 # CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --enable-quartz=no || exit 1
854 # Maybe follow http://cairographics.org/end_to_end_build_for_mac_os_x/
855 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --enable-quartz=yes || exit 1
857 # We must avoid the version of libpng that comes with X11; the
858 # only way I've found to force that is to forcibly set INCLUDES
859 # when we do the build, so that this comes before CAIRO_CFLAGS,
860 # which has -I/usr/X11/include added to it before anything
861 # connected to libpng is.
863 INCLUDES="-I/usr/local/include/libpng15" make $MAKE_BUILD_OPTS || exit 1
864 $DO_MAKE_INSTALL || exit 1
866 touch cairo-$CAIRO_VERSION-done
871 if [ ! -z "$installed_cairo_version" ] ; then
873 # GTK+ depends on this, so uninstall it.
877 echo "Uninstalling Cairo:"
878 cd cairo-$installed_cairo_version
879 $DO_MAKE_UNINSTALL || exit 1
880 make distclean || exit 1
882 rm cairo-$installed_cairo_version-done
884 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
886 # Get rid of the previously downloaded and unpacked version.
888 rm -rf cairo-$installed_cairo_version
889 rm -rf cairo-$installed_cairo_version.tar.xz cairo-$installed_cairo_version.tar.gz
892 installed_cairo_version=""
897 if [ ! -f atk-$ATK_VERSION-done ] ; then
898 echo "Downloading, building, and installing ATK:"
899 atk_dir=`expr $ATK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
900 ATK_MAJOR_VERSION="`expr $ATK_VERSION : '\([0-9][0-9]*\).*'`"
901 ATK_MINOR_VERSION="`expr $ATK_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
902 ATK_DOTDOT_VERSION="`expr $ATK_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
903 if [[ $ATK_MAJOR_VERSION -gt 2 ||
904 ($ATK_MAJOR_VERSION -eq 2 && $ATK_MINOR_VERSION -gt 0) ||
905 ($ATK_MAJOR_VERSION -eq 2 && $ATK_MINOR_VERSION -eq 0 && $ATK_DOTDOT_VERSION -ge 1) ]]
908 # Starting with ATK 2.0.1, xz-compressed tarballs are available.
910 [ -f atk-$ATK_VERSION.tar.xz ] || curl -L -O http://ftp.gnome.org/pub/gnome/sources/atk/$atk_dir/atk-$ATK_VERSION.tar.xz || exit 1
911 $no_build && echo "Skipping installation" && return
912 xzcat atk-$ATK_VERSION.tar.xz | tar xf - || exit 1
914 [ -f atk-$ATK_VERSION.tar.bz2 ] || curl -L -O http://ftp.gnome.org/pub/gnome/sources/atk/$atk_dir/atk-$ATK_VERSION.tar.bz2 || exit 1
915 $no_build && echo "Skipping installation" && return
916 bzcat atk-$ATK_VERSION.tar.bz2 | tar xf - || exit 1
919 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
920 make $MAKE_BUILD_OPTS || exit 1
921 $DO_MAKE_INSTALL || exit 1
923 touch atk-$ATK_VERSION-done
928 if [ ! -z "$installed_atk_version" ] ; then
930 # GTK+ depends on this, so uninstall it.
934 echo "Uninstalling ATK:"
935 cd atk-$installed_atk_version
936 $DO_MAKE_UNINSTALL || exit 1
937 make distclean || exit 1
939 rm atk-$installed_atk_version-done
941 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
943 # Get rid of the previously downloaded and unpacked version.
945 rm -rf atk-$installed_atk_version
946 rm -rf atk-$installed_atk_version.tar.xz atk-$installed_atk_version.tar.bz2
949 installed_atk_version=""
954 if [ ! -f pango-$PANGO_VERSION-done ] ; then
955 echo "Downloading, building, and installing Pango:"
956 pango_dir=`expr $PANGO_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
957 PANGO_MAJOR_VERSION="`expr $PANGO_VERSION : '\([0-9][0-9]*\).*'`"
958 PANGO_MINOR_VERSION="`expr $PANGO_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
959 if [[ $PANGO_MAJOR_VERSION -gt 1 ||
960 $PANGO_MINOR_VERSION -ge 29 ]]
963 # Starting with Pango 1.29, the tarballs are compressed with
964 # xz rather than bzip2.
966 [ -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
967 $no_build && echo "Skipping installation" && return
968 xzcat pango-$PANGO_VERSION.tar.xz | tar xf - || exit 1
970 [ -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
971 $no_build && echo "Skipping installation" && return
972 bzcat pango-$PANGO_VERSION.tar.bz2 | tar xf - || exit 1
974 cd pango-$PANGO_VERSION
975 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
976 make $MAKE_BUILD_OPTS || exit 1
977 $DO_MAKE_INSTALL || exit 1
979 touch pango-$PANGO_VERSION-done
984 if [ ! -z "$installed_pango_version" ] ; then
986 # GTK+ depends on this, so uninstall it.
990 echo "Uninstalling Pango:"
991 cd pango-$installed_pango_version
992 $DO_MAKE_UNINSTALL || exit 1
993 make distclean || exit 1
995 rm pango-$installed_pango_version-done
997 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
999 # Get rid of the previously downloaded and unpacked version.
1001 rm -rf pango-$installed_pango_version
1002 rm -rf pango-$installed_pango_version.tar.xz pango-$installed_pango_version.tar.bz2
1005 installed_pango_version=""
1009 install_gdk_pixbuf() {
1010 if [ "$GDK_PIXBUF_VERSION" -a ! -f gdk-pixbuf-$GDK_PIXBUF_VERSION-done ] ; then
1011 echo "Downloading, building, and installing gdk-pixbuf:"
1012 gdk_pixbuf_dir=`expr $GDK_PIXBUF_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
1013 [ -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
1014 $no_build && echo "Skipping installation" && return
1015 xzcat gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.xz | tar xf - || exit 1
1016 cd gdk-pixbuf-$GDK_PIXBUF_VERSION
1018 # If we're building using the 10.6 SDK, force the use of libpng12.
1020 # The OS's X11, and corresponding SDK, didn't introduce libpng15,
1021 # or pkg-config files, until 10.7, so, for 10.6 have to explicitly
1022 # set LIBPNG to override the configure script, and also force the
1023 # CFLAGS to look for the header files for libpng12 (note that
1024 # -isysroot doesn't affect the arguments to -I, so we need to
1025 # include the SDK path explicitly).
1027 if [[ "$sdk_target" = 10.6 ]]
1029 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
1031 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
1033 make $MAKE_BUILD_OPTS || exit 1
1034 $DO_MAKE_INSTALL || exit 1
1036 touch gdk-pixbuf-$GDK_PIXBUF_VERSION-done
1040 uninstall_gdk_pixbuf() {
1041 if [ ! -z "$installed_gdk_pixbuf_version" ] ; then
1043 # GTK+ depends on this, so uninstall it.
1047 echo "Uninstalling gdk-pixbuf:"
1048 cd gdk-pixbuf-$installed_gdk_pixbuf_version
1049 $DO_MAKE_UNINSTALL || exit 1
1050 make distclean || exit 1
1052 rm gdk-pixbuf-$installed_gdk_pixbuf_version-done
1054 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1056 # Get rid of the previously downloaded and unpacked version.
1058 rm -rf gdk-pixbuf-$installed_gdk_pixbuf_version
1059 rm -rf gdk-pixbuf-$installed_gdk_pixbuf_version.tar.xz
1062 installed_gdk_pixbuf_version=""
1067 if [ ! -f gtk+-$GTK_VERSION-done ] ; then
1068 echo "Downloading, building, and installing GTK+:"
1069 gtk_dir=`expr $GTK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
1070 if [[ $GTK_MAJOR_VERSION -gt 2 ||
1071 ($GTK_MAJOR_VERSION -eq 2 && $GTK_MINOR_VERSION -gt 24) ||
1072 ($GTK_MAJOR_VERSION -eq 2 && $GTK_MINOR_VERSION -eq 24 && $GTK_DOTDOT_VERSION -ge 5) ]]
1075 # Starting with GTK+ 2.24.5, the tarballs are compressed with
1076 # xz rather than gzip, in addition to bzip2; use xz, as we've
1077 # built and installed it, and as xz compresses better than
1078 # bzip2 so the tarballs take less time to download.
1080 [ -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
1081 $no_build && echo "Skipping installation" && return
1082 xzcat gtk+-$GTK_VERSION.tar.xz | tar xf - || exit 1
1084 [ -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
1085 $no_build && echo "Skipping installation" && return
1086 bzcat gtk+-$GTK_VERSION.tar.bz2 | tar xf - || exit 1
1088 cd gtk+-$GTK_VERSION
1089 if [ $DARWIN_MAJOR_VERSION -ge "12" ]
1092 # GTK+ 2.24.10, at least, doesn't build on Mountain Lion with the
1093 # CUPS printing backend - either the CUPS API changed incompatibly
1094 # or the backend was depending on non-API implementation details.
1096 # Configure it out, on Mountain Lion and later, for now.
1097 # (12 is the Darwin major version number in Mountain Lion.)
1099 # Also, configure out libtiff and libjpeg; configure scripts
1100 # just ignore unknown --enable/--disable and --with/--without
1101 # options (at least they've always do so up to now).
1103 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
1105 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
1107 make $MAKE_BUILD_OPTS || exit 1
1108 $DO_MAKE_INSTALL || exit 1
1110 touch gtk+-$GTK_VERSION-done
1115 if [ ! -z "$installed_gtk_version" ] ; then
1116 echo "Uninstalling GTK+:"
1117 cd gtk+-$installed_gtk_version
1118 $DO_MAKE_UNINSTALL || exit 1
1119 make distclean || exit 1
1121 rm gtk+-$installed_gtk_version-done
1123 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1125 # Get rid of the previously downloaded and unpacked version.
1127 rm -rf gtk+-$installed_gtk_version
1128 rm -rf gtk+-$installed_gtk_version.tar.xz gtk+-$installed_gtk_version.tar.bz2
1131 installed_gtk_version=""
1136 if [ "$LIBSMI_VERSION" -a ! -f libsmi-$LIBSMI_VERSION-done ] ; then
1137 echo "Downloading, building, and installing libsmi:"
1138 [ -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
1139 $no_build && echo "Skipping installation" && return
1140 gzcat libsmi-$LIBSMI_VERSION.tar.gz | tar xf - || exit 1
1141 cd libsmi-$LIBSMI_VERSION
1142 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
1143 make $MAKE_BUILD_OPTS || exit 1
1144 $DO_MAKE_INSTALL || exit 1
1146 touch libsmi-$LIBSMI_VERSION-done
1150 uninstall_libsmi() {
1151 if [ ! -z "$installed_libsmi_version" ] ; then
1152 echo "Uninstalling libsmi:"
1153 cd libsmi-$installed_libsmi_version
1154 $DO_MAKE_UNINSTALL || exit 1
1155 make distclean || exit 1
1157 rm libsmi-$installed_libsmi_version-done
1159 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1161 # Get rid of the previously downloaded and unpacked version.
1163 rm -rf libsmi-$installed_libsmi_version
1164 rm -rf libsmi-$installed_libsmi_version.tar.gz
1167 installed_libsmi_version=""
1171 install_libgpg_error() {
1172 if [ "$LIBGPG_ERROR_VERSION" -a ! -f libgpg-error-$LIBGPG_ERROR_VERSION-done ] ; then
1173 echo "Downloading, building, and installing libgpg-error:"
1174 [ -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
1175 $no_build && echo "Skipping installation" && return
1176 bzcat libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 | tar xf - || exit 1
1177 cd libgpg-error-$LIBGPG_ERROR_VERSION
1178 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
1179 make $MAKE_BUILD_OPTS || exit 1
1180 $DO_MAKE_INSTALL || exit 1
1182 touch libgpg-error-$LIBGPG_ERROR_VERSION-done
1186 uninstall_libgpg_error() {
1187 if [ ! -z "$installed_libgpg_error_version" ] ; then
1189 # libgcrypt depends on this, so uninstall it.
1191 uninstall_libgcrypt "$@"
1193 echo "Uninstalling libgpg-error:"
1194 cd libgpg-error-$installed_libgpg_error_version
1195 $DO_MAKE_UNINSTALL || exit 1
1196 make distclean || exit 1
1198 rm libgpg-error-$installed_libgpg_error_version-done
1200 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1202 # Get rid of the previously downloaded and unpacked version.
1204 rm -rf libgpg-error-$installed_libgpg_error_version
1205 rm -rf libgpg-error-$installed_libgpg_error_version.tar.bz2
1208 installed_libgpg_error_version=""
1212 install_libgcrypt() {
1213 if [ "$LIBGCRYPT_VERSION" -a ! -f libgcrypt-$LIBGCRYPT_VERSION-done ] ; then
1215 # libgpg-error is required for libgcrypt.
1217 if [ -z $LIBGPG_ERROR_VERSION ]
1219 echo "libgcrypt requires libgpg-error, but you didn't install libgpg-error." 1>&2
1223 echo "Downloading, building, and installing libgcrypt:"
1224 [ -f libgcrypt-$LIBGCRYPT_VERSION.tar.gz ] || curl -L -O ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-$LIBGCRYPT_VERSION.tar.gz || exit 1
1225 $no_build && echo "Skipping installation" && return
1226 gzcat libgcrypt-$LIBGCRYPT_VERSION.tar.gz | tar xf - || exit 1
1227 cd libgcrypt-$LIBGCRYPT_VERSION
1229 # The assembler language code is not compatible with the macOS
1230 # x86 assembler (or is it an x86-64 vs. x86-32 issue?).
1232 # libgcrypt expects gnu89, not c99/gnu99, semantics for
1233 # "inline". See, for example:
1235 # http://lists.freebsd.org/pipermail/freebsd-ports-bugs/2010-October/198809.html
1237 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
1238 make $MAKE_BUILD_OPTS || exit 1
1239 $DO_MAKE_INSTALL || exit 1
1241 touch libgcrypt-$LIBGCRYPT_VERSION-done
1245 uninstall_libgcrypt() {
1246 if [ ! -z "$installed_libgcrypt_version" ] ; then
1247 echo "Uninstalling libgcrypt:"
1248 cd libgcrypt-$installed_libgcrypt_version
1249 $DO_MAKE_UNINSTALL || exit 1
1250 make distclean || exit 1
1252 rm libgcrypt-$installed_libgcrypt_version-done
1254 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1256 # Get rid of the previously downloaded and unpacked version.
1258 rm -rf libgcrypt-$installed_libgcrypt_version
1259 rm -rf libgcrypt-$installed_libgcrypt_version.tar.gz
1262 installed_libgcrypt_version=""
1267 if [ "$GMP_VERSION" -a ! -f gmp-$GMP_VERSION-done ] ; then
1268 echo "Downloading, building, and installing GMP:"
1269 [ -f gmp-$GMP_VERSION.tar.lz ] || curl -L -O https://gmplib.org/download/gmp/gmp-$GMP_VERSION.tar.lz || exit 1
1270 $no_build && echo "Skipping installation" && return
1271 lzip -c -d gmp-$GMP_VERSION.tar.lz | tar xf - || exit 1
1273 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
1274 make $MAKE_BUILD_OPTS || exit 1
1275 $DO_MAKE_INSTALL || exit 1
1277 touch gmp-$GMP_VERSION-done
1282 if [ ! -z "$installed_gmp_version" ] ; then
1284 # Nettle depends on this, so uninstall it.
1286 uninstall_nettle "$@"
1288 echo "Uninstalling GMP:"
1289 cd gmp-$installed_gmp_version
1290 $DO_MAKE_UNINSTALL || exit 1
1291 make distclean || exit 1
1293 rm gmp-$installed_gmp_version-done
1295 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1297 # Get rid of the previously downloaded and unpacked version.
1299 rm -rf gmp-$installed_gmp_version
1300 rm -rf gmp-$installed_gmp_version.tar.lz
1303 installed_gmp_version=""
1308 if [ "$NETTLE_VERSION" -a ! -f nettle-$NETTLE_VERSION-done ] ; then
1309 echo "Downloading, building, and installing Nettle:"
1310 [ -f nettle-$NETTLE_VERSION.tar.gz ] || curl -L -O https://ftp.gnu.org/gnu/nettle/nettle-$NETTLE_VERSION.tar.gz || exit 1
1311 $no_build && echo "Skipping installation" && return
1312 gzcat nettle-$NETTLE_VERSION.tar.gz | tar xf - || exit 1
1313 cd nettle-$NETTLE_VERSION
1314 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
1315 make $MAKE_BUILD_OPTS || exit 1
1316 $DO_MAKE_INSTALL || exit 1
1318 touch nettle-$NETTLE_VERSION-done
1322 uninstall_nettle() {
1323 if [ ! -z "$installed_nettle_version" ] ; then
1325 # GnuTLS depends on this, so uninstall it.
1327 uninstall_gnutls "$@"
1329 echo "Uninstalling Nettle:"
1330 cd nettle-$installed_nettle_version
1331 $DO_MAKE_UNINSTALL || exit 1
1332 make distclean || exit 1
1334 rm nettle-$installed_nettle_version-done
1336 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1338 # Get rid of the previously downloaded and unpacked version.
1340 rm -rf nettle-$installed_nettle_version
1341 rm -rf nettle-$installed_nettle_version.tar.gz
1344 installed_nettle_version=""
1349 if [ "$GNUTLS_VERSION" -a ! -f gnutls-$GNUTLS_VERSION-done ] ; then
1351 # GnuTLS requires Nettle.
1353 if [ -z $NETTLE_VERSION ]
1355 echo "GnuTLS requires Nettle, but you didn't install Nettle" 1>&2
1359 echo "Downloading, building, and installing GnuTLS:"
1360 if [[ $GNUTLS_MAJOR_VERSION -ge 3 ]]
1363 # Starting with GnuTLS 3.x, the tarballs are compressed with
1364 # xz rather than bzip2.
1366 [ -f gnutls-$GNUTLS_VERSION.tar.xz ] || curl -L -O https://www.gnupg.org/ftp/gcrypt/gnutls/v$GNUTLS_MAJOR_VERSION.$GNUTLS_MINOR_VERSION/gnutls-$GNUTLS_VERSION.tar.xz || exit 1
1367 $no_build && echo "Skipping installation" && return
1368 xzcat gnutls-$GNUTLS_VERSION.tar.xz | tar xf - || exit 1
1370 [ -f gnutls-$GNUTLS_VERSION.tar.bz2 ] || curl -L -O https://www.gnupg.org/ftp/gcrypt/gnutls/v$GNUTLS_MAJOR_VERSION.$GNUTLS_MINOR_VERSION/gnutls-$GNUTLS_VERSION.tar.bz2 || exit 1
1371 $no_build && echo "Skipping installation" && return
1372 bzcat gnutls-$GNUTLS_VERSION.tar.bz2 | tar xf - || exit 1
1374 cd gnutls-$GNUTLS_VERSION
1375 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --with-included-libtasn1 --with-included-unistring --without-p11-kit || exit 1
1376 make $MAKE_BUILD_OPTS || exit 1
1377 $DO_MAKE_INSTALL || exit 1
1379 touch gnutls-$GNUTLS_VERSION-done
1383 uninstall_gnutls() {
1384 if [ ! -z "$installed_gnutls_version" ] ; then
1385 echo "Uninstalling GnuTLS:"
1386 cd gnutls-$installed_gnutls_version
1387 $DO_MAKE_UNINSTALL || exit 1
1388 make distclean || exit 1
1390 rm gnutls-$installed_gnutls_version-done
1392 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1394 # Get rid of the previously downloaded and unpacked version.
1396 rm -rf gnutls-$installed_gnutls_version
1397 rm -rf gnutls-$installed_gnutls_version.tar.bz2
1400 installed_gnutls_version=""
1405 if [ "$LUA_VERSION" -a ! -f lua-$LUA_VERSION-done ] ; then
1406 echo "Downloading, building, and installing Lua:"
1407 [ -f lua-$LUA_VERSION.tar.gz ] || curl -L -O http://www.lua.org/ftp/lua-$LUA_VERSION.tar.gz || exit 1
1408 $no_build && echo "Skipping installation" && return
1409 gzcat lua-$LUA_VERSION.tar.gz | tar xf - || exit 1
1411 make MYCFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" MYLDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" $MAKE_BUILD_OPTS macosx || exit 1
1412 $DO_MAKE_INSTALL || exit 1
1414 touch lua-$LUA_VERSION-done
1419 if [ ! -z "$installed_lua_version" ] ; then
1420 echo "Uninstalling Lua:"
1422 # Lua has no "make uninstall", so just remove stuff manually.
1423 # There's no configure script, so there's no need for
1424 # "make distclean", either; just do "make clean".
1426 (cd /usr/local/bin; $DO_RM -f lua luac)
1427 (cd /usr/local/include; $DO_RM -f lua.h luaconf.h lualib.h lauxlib.h lua.hpp)
1428 (cd /usr/local/lib; $DO_RM -f liblua.a)
1429 (cd /usr/local/man/man1; $DO_RM -f lua.1 luac.1)
1430 cd lua-$installed_lua_version
1431 make clean || exit 1
1433 rm lua-$installed_lua_version-done
1435 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1437 # Get rid of the previously downloaded and unpacked version.
1439 rm -rf lua-$installed_lua_version
1440 rm -rf lua-$installed_lua_version.tar.gz
1443 installed_lua_version=""
1447 install_portaudio() {
1449 # Check for both the old versionless portaudio-done and the new
1450 # versioned -done file.
1452 if [ "$PORTAUDIO_VERSION" -a ! -f portaudio-$PORTAUDIO_VERSION-done ] ; then
1453 echo "Downloading, building, and installing PortAudio:"
1454 [ -f $PORTAUDIO_VERSION.tgz ] || curl -L -O http://www.portaudio.com/archives/$PORTAUDIO_VERSION.tgz || exit 1
1455 $no_build && echo "Skipping installation" && return
1456 gzcat $PORTAUDIO_VERSION.tgz | tar xf - || exit 1
1459 # Un-comment an include that's required on Lion.
1461 patch -p0 include/pa_mac_core.h <../../macosx-support-lib-patches/portaudio-pa_mac_core.h.patch
1463 # Fix a bug that showed up with clang (but is a bug with any
1466 patch -p0 src/hostapi/coreaudio/pa_mac_core.c <../../macosx-support-lib-patches/portaudio-pa_mac_core.c.patch
1468 # Disable fat builds - the configure script doesn't work right
1469 # with Xcode 4 if you leave them enabled, and we don't build
1470 # any other libraries fat (GLib, for example, would be very
1471 # hard to build fat), so there's no advantage to having PortAudio
1474 # Set the minimum macOS version to 10.4, to suppress some
1475 # deprecation warnings. (Good luck trying to make any of
1476 # this build on an OS+Xcode with a pre-10.4 SDK; we don't
1477 # worry about the user requesting that.)
1479 # Explicitly disable deprecation, so the damn thing will build
1480 # on El Capitan with Xcode 7.
1482 CFLAGS="$CFLAGS -Wno-deprecated-declarations -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
1483 make $MAKE_BUILD_OPTS || exit 1
1484 $DO_MAKE_INSTALL || exit 1
1486 touch portaudio-$PORTAUDIO_VERSION-done
1490 uninstall_portaudio() {
1491 if [ ! -z "$installed_portaudio_version" ] ; then
1492 echo "Uninstalling PortAudio:"
1494 $DO_MAKE_UNINSTALL || exit 1
1495 make distclean || exit 1
1497 rm portaudio-$installed_portaudio_version-done
1499 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1501 # Get rid of the previously downloaded and unpacked version.
1504 rm -rf $installed_portaudio_version.tgz
1507 installed_portaudio_version=""
1512 if [ "$SNAPPY_VERSION" -a ! -f snappy-$SNAPPY_VERSION-done ] ; then
1513 echo "Downloading, building, and installing snappy:"
1514 [ -f snappy-$SNAPPY_VERSION.tar.gz ] || curl -L -O https://github.com/google/snappy/releases/download/$SNAPPY_VERSION/snappy-$SNAPPY_VERSION.tar.gz || exit 1
1515 $no_build && echo "Skipping installation" && return
1516 gzcat snappy-$SNAPPY_VERSION.tar.gz | tar xf - || exit 1
1517 cd snappy-$SNAPPY_VERSION
1518 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0" ./configure || exit 1
1519 make $MAKE_BUILD_OPTS || exit 1
1520 $DO_MAKE_INSTALL || exit 1
1522 touch snappy-$SNAPPY_VERSION-done
1526 uninstall_snappy() {
1527 if [ ! -z "$installed_snappy_version" ] ; then
1528 echo "Uninstalling snappy:"
1529 cd snappy-$installed_snappy_version
1530 $DO_MAKE_UNINSTALL || exit 1
1531 make distclean || exit 1
1533 rm snappy-$installed_snappy_version-done
1535 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1537 # Get rid of the previously downloaded and unpacked version.
1539 rm -rf snappy-$installed_snappy_version
1540 rm -rf snappy-$installed_snappy_version.tar.gz
1543 installed_snappy_version=""
1548 if [ "$LIBXML2_VERSION" -a ! -f libxml2-$LIBXML2_VERSION-done ] ; then
1549 echo "Downloading, building, and installing libxml2:"
1550 [ -f libxml2-$LIBXML2_VERSION.tar.gz ] || curl -L -O ftp://xmlsoft.org/libxml2/libxml2-$LIBXML2_VERSION.tar.gz || exit 1
1551 $no_build && echo "Skipping installation" && return
1552 gzcat libxml2-$LIBXML2_VERSION.tar.gz | tar xf - || exit 1
1553 cd libxml2-$LIBXML2_VERSION
1554 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0" ./configure || exit 1
1555 make $MAKE_BUILD_OPTS || exit 1
1556 $DO_MAKE_INSTALL || exit 1
1558 touch libxml2-$LIBXML2_VERSION-done
1562 uninstall_libxml2() {
1563 if [ ! -z "$installed_libxml2_version" ] ; then
1564 echo "Uninstalling libxml2:"
1565 cd libxml2-$installed_libxml2_version
1566 $DO_MAKE_UNINSTALL || exit 1
1567 make distclean || exit 1
1569 rm libxml2-$installed_libxml2_version-done
1571 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1573 # Get rid of the previously downloaded and unpacked version.
1575 rm -rf libxml2-$installed_libxml2_version
1576 rm -rf libxml2-$installed_libxml2_version.tar.gz
1579 installed_libxml2_version=""
1584 if [ "$LZ4_VERSION" -a ! -f lz4-$LZ4_VERSION-done ] ; then
1585 echo "Downloading, building, and installing lz4:"
1586 [ -f lz4-$LZ4_VERSION.tar.gz ] || curl -L -o lz4-$LZ4_VERSION.tar.gz https://github.com/lz4/lz4/archive/$LZ4_VERSION.tar.gz || exit 1
1587 $no_build && echo "Skipping installation" && return
1588 gzcat lz4-$LZ4_VERSION.tar.gz | tar xf - || exit 1
1590 # CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0" ./configure || exit 1
1591 make $MAKE_BUILD_OPTS || exit 1
1592 $DO_MAKE_INSTALL || exit 1
1594 touch lz4-$LZ4_VERSION-done
1599 if [ ! -z "$installed_lz4_version" ] ; then
1600 echo "Uninstalling lz4:"
1601 cd lz4-$installed_lz4_version
1602 $DO_MAKE_UNINSTALL || exit 1
1603 make distclean || exit 1
1605 rm lz4-$installed_lz4_version-done
1607 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1609 # Get rid of the previously downloaded and unpacked version.
1611 rm -rf lz4-$installed_lz4_version
1612 rm -rf lz4-$installed_lz4_version.tar.gz
1615 installed_lz4_version=""
1620 if [ "$SBC_VERSION" -a ! -f sbc-$SBC_VERSION-done ] ; then
1621 echo "Downloading, building, and installing sbc:"
1622 [ -f sbc-$SBC_VERSION.tar.gz ] || curl -L -O https://www.kernel.org/pub/linux/bluetooth/sbc-$SBC_VERSION.tar.gz || exit 1
1623 $no_build && echo "Skipping installation" && return
1624 gzcat sbc-$SBC_VERSION.tar.gz | tar xf - || exit 1
1626 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0" ./configure --disable-tools --disable-tester --disable-shared || exit 1
1627 make $MAKE_BUILD_OPTS || exit 1
1628 $DO_MAKE_INSTALL || exit 1
1630 touch sbc-$SBC_VERSION-done
1635 if [ ! -z "$installed_sbc_version" ] ; then
1636 echo "Uninstalling sbc:"
1637 cd sbc-$installed_sbc_version
1638 $DO_MAKE_UNINSTALL || exit 1
1639 make distclean || exit 1
1641 rm sbc-$installed_sbc_version-done
1643 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1645 # Get rid of the previously downloaded and unpacked version.
1647 rm -rf sbc-$installed_sbc_version
1648 rm -rf sbc-$installed_sbc_version.tar.gz
1651 installed_sbc_version=""
1656 if [ "$GEOIP_VERSION" -a ! -f geoip-$GEOIP_VERSION-done ] ; then
1657 echo "Downloading, building, and installing GeoIP API:"
1658 GEOIP_MAJOR_VERSION="`expr $GEOIP_VERSION : '\([0-9][0-9]*\).*'`"
1659 GEOIP_MINOR_VERSION="`expr $GEOIP_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
1660 GEOIP_DOTDOT_VERSION="`expr $GEOIP_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
1661 if [[ $GEOIP_MAJOR_VERSION -gt 1 ||
1662 ($GEOIP_MAJOR_VERSION -eq 1 && $GEOIP_MINOR_VERSION -gt 6) ||
1663 ($GEOIP_MAJOR_VERSION -eq 1 && $GEOIP_MINOR_VERSION -eq 6 && $GEOIP_DOTDOT_VERSION -ge 1) ]]
1666 # Starting with GeoIP 1.6.1, the tarballs are on GitHub.
1668 [ -f GeoIP-$GEOIP_VERSION.tar.gz ] || curl -L -O https://github.com/maxmind/geoip-api-c/releases/download/v$GEOIP_VERSION/GeoIP-$GEOIP_VERSION.tar.gz || exit 1
1670 [ -f GeoIP-$GEOIP_VERSION.tar.gz ] || curl -L -O http://geolite.maxmind.com/download/geoip/api/c/GeoIP-$GEOIP_VERSION.tar.gz || exit 1
1672 $no_build && echo "Skipping installation" && return
1673 gzcat GeoIP-$GEOIP_VERSION.tar.gz | tar xf - || exit 1
1674 cd GeoIP-$GEOIP_VERSION
1675 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
1677 # Grr. Their man pages "helpfully" have an ISO 8859-1
1678 # copyright symbol in the copyright notice, but macOS's
1679 # default character encoding is UTF-8. sed on Mountain
1680 # Lion barfs at the "illegal character sequence" represented
1681 # by an ISO 8859-1 copyright symbol, as it's not a valid
1684 # iconv the relevant man pages into UTF-8.
1686 for i in geoipupdate.1.in geoiplookup6.1.in geoiplookup.1.in
1688 iconv -f iso8859-1 -t utf-8 man/"$i" >man/"$i".tmp &&
1689 mv man/"$i".tmp man/"$i"
1691 make $MAKE_BUILD_OPTS || exit 1
1692 $DO_MAKE_INSTALL || exit 1
1694 touch geoip-$GEOIP_VERSION-done
1699 if [ ! -z "$installed_geoip_version" ] ; then
1700 echo "Uninstalling GeoIP API:"
1701 cd GeoIP-$installed_geoip_version
1702 $DO_MAKE_UNINSTALL || exit 1
1703 make distclean || exit 1
1705 rm geoip-$installed_geoip_version-done
1707 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1709 # Get rid of the previously downloaded and unpacked version.
1711 rm -rf GeoIP-$installed_geoip_version
1712 rm -rf GeoIP-$installed_geoip_version.tar.gz
1715 installed_geoip_version=""
1720 if [ "$CARES_VERSION" -a ! -f c-ares-$CARES_VERSION-done ] ; then
1721 echo "Downloading, building, and installing C-Ares API:"
1722 [ -f c-ares-$CARES_VERSION.tar.gz ] || curl -L -O https://c-ares.haxx.se/download/c-ares-$CARES_VERSION.tar.gz || exit 1
1723 $no_build && echo "Skipping installation" && return
1724 gzcat c-ares-$CARES_VERSION.tar.gz | tar xf - || exit 1
1725 cd c-ares-$CARES_VERSION
1726 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
1727 make $MAKE_BUILD_OPTS || exit 1
1728 $DO_MAKE_INSTALL || exit 1
1730 touch c-ares-$CARES_VERSION-done
1734 uninstall_c_ares() {
1735 if [ ! -z "$installed_cares_version" ] ; then
1736 echo "Uninstalling C-Ares API:"
1737 cd c-ares-$installed_cares_version
1738 $DO_MAKE_UNINSTALL || exit 1
1739 make distclean || exit 1
1741 rm c-ares-$installed_cares_version-done
1743 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1745 # Get rid of the previously downloaded and unpacked version.
1747 rm -rf c-ares-$installed_cares_version
1748 rm -rf c-ares-$installed_cares_version.tar.gz
1751 installed_cares_version=""
1756 if [ "$LIBSSH_VERSION" -a ! -f libssh-$LIBSSH_VERSION-done ] ; then
1757 echo "Downloading, building, and installing libssh:"
1758 [ -f libssh-$LIBSSH_VERSION.tar.xz ] || curl -L -O https://red.libssh.org/attachments/download/195/libssh-$LIBSSH_VERSION.tar.xz || exit 1
1759 $no_build && echo "Skipping installation" && return
1760 xzcat libssh-$LIBSSH_VERSION.tar.xz | tar xf - || exit 1
1761 cd libssh-$LIBSSH_VERSION
1764 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" cmake -DWITH_GCRYPT=1 ../ || exit 1
1765 make $MAKE_BUILD_OPTS || exit 1
1766 $DO_MAKE_INSTALL || exit 1
1768 touch libssh-$LIBSSH_VERSION-done
1772 uninstall_libssh() {
1773 if [ ! -z "$installed_libssh_version" ] ; then
1774 echo "Sadly, libssh uses cmake, and doesn't support uninstall."
1779 if [ "$NGHTTP2_VERSION" -a ! -f nghttp2-$NGHTTP2_VERSION-done ] ; then
1780 echo "Downloading, building, and installing nghttp2:"
1781 [ -f nghttp2-$NGHTTP2_VERSION.tar.xz ] || curl -L -O https://github.com/nghttp2/nghttp2/releases/download/v$NGHTTP2_VERSION/nghttp2-$NGHTTP2_VERSION.tar.xz || exit 1
1782 $no_build && echo "Skipping installation" && return
1783 xzcat nghttp2-$NGHTTP2_VERSION.tar.xz | tar xf - || exit 1
1784 cd nghttp2-$NGHTTP2_VERSION
1785 ./configure || exit 1
1786 make $MAKE_BUILD_OPTS || exit 1
1787 $DO_MAKE_INSTALL || exit 1
1789 touch nghttp2-$NGHTTP2_VERSION-done
1793 uninstall_nghttp2() {
1794 if [ ! -z "$installed_nghttp2_version" ] ; then
1795 echo "Uninstalling nghttp2:"
1796 cd nghttp2-$installed_nghttp2_version
1797 $DO_MAKE_UNINSTALL || exit 1
1798 make distclean || exit 1
1800 rm nghttp2-$installed_nghttp2_version-done
1802 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1804 # Get rid of the previously downloaded and unpacked version.
1806 rm -rf nghttp2-$installed_nghttp2_version
1807 rm -rf nghttp2-$installed_nghttp2_version.tar.xz
1810 installed_nghttp2_version=""
1816 # Check whether the versions we have installed are the versions
1817 # requested; if not, uninstall the installed versions.
1819 if [ ! -z "$installed_nghttp2_version" -a \
1820 "$installed_nghttp2_version" != "$NGHTTP2_VERSION" ] ; then
1821 echo "Installed nghttp2 version is $installed_nghttp2_version"
1822 if [ -z "$NGHTTP2_VERSION" ] ; then
1823 echo "nghttp2 is not requested"
1825 echo "Requested nghttp2 version is $NGHTTP2_VERSION"
1827 uninstall_nghttp2 -r
1830 if [ ! -z "$installed_libssh_version" -a \
1831 "$installed_libssh_version" != "$LIBSSH_VERSION" ] ; then
1832 echo "Installed libssh version is $installed_libssh_version"
1833 if [ -z "$LIBSSH_VERSION" ] ; then
1834 echo "libssh is not requested"
1836 echo "Requested libssh version is $LIBSSH_VERSION"
1841 if [ ! -z "$installed_cares_version" -a \
1842 "$installed_cares_version" != "$CARES_VERSION" ] ; then
1843 echo "Installed C-Ares version is $installed_cares_version"
1844 if [ -z "$CARES_VERSION" ] ; then
1845 echo "C-Ares is not requested"
1847 echo "Requested C-Ares version is $CARES_VERSION"
1852 if [ ! -z "$installed_geoip_version" -a \
1853 "$installed_geoip_version" != "$GEOIP_VERSION" ] ; then
1854 echo "Installed GeoIP API version is $installed_geoip_version"
1855 if [ -z "$GEOIP_VERSION" ] ; then
1856 echo "GeoIP is not requested"
1858 echo "Requested GeoIP version is $GEOIP_VERSION"
1863 if [ ! -z "$installed_sbc_version" -a \
1864 "$installed_sbc_version" != "$SBC_VERSION" ] ; then
1865 echo "Installed SBC version is $installed_sbc_version"
1866 if [ -z "$SBC_VERSION" ] ; then
1867 echo "SBC is not requested"
1869 echo "Requested SBC version is $SBC_VERSION"
1874 if [ ! -z "$installed_lz4_version" -a \
1875 "$installed_lz4_version" != "$LZ4_VERSION" ] ; then
1876 echo "Installed LZ4 version is $installed_lz4_version"
1877 if [ -z "$LZ4_VERSION" ] ; then
1878 echo "LZ4 is not requested"
1880 echo "Requested LZ4 version is $LZ4_VERSION"
1885 if [ ! -z "$installed_libxml2_version" -a \
1886 "$installed_libxml2_version" != "$LIBXML2_VERSION" ] ; then
1887 echo "Installed libxml2 version is $installed_libxml2_version"
1888 if [ -z "$LIBXML2_VERSION" ] ; then
1889 echo "libxml2 is not requested"
1891 echo "Requested libxml2 version is $LIBXML2_VERSION"
1893 uninstall_libxml2 -r
1896 if [ ! -z "$installed_snappy_version" -a \
1897 "$installed_snappy_version" != "$SNAPPY_VERSION" ] ; then
1898 echo "Installed SNAPPY version is $installed_snappy_version"
1899 if [ -z "$SNAPPY_VERSION" ] ; then
1900 echo "SNAPPY is not requested"
1902 echo "Requested SNAPPY version is $SNAPPY_VERSION"
1907 if [ ! -z "$installed_portaudio_version" -a \
1908 "$installed_portaudio_version" != "$PORTAUDIO_VERSION" ] ; then
1909 echo "Installed PortAudio version is $installed_portaudio_version"
1910 if [ -z "$PORTAUDIO_VERSION" ] ; then
1911 echo "PortAudio is not requested"
1913 echo "Requested PortAudio version is $PORTAUDIO_VERSION"
1915 uninstall_portaudio -r
1918 if [ ! -z "$installed_lua_version" -a \
1919 "$installed_lua_version" != "$LUA_VERSION" ] ; then
1920 echo "Installed Lua version is $installed_lua_version"
1921 if [ -z "$LUA_VERSION" ] ; then
1922 echo "Lua is not requested"
1924 echo "Requested Lua version is $LUA_VERSION"
1929 if [ ! -z "$installed_gnutls_version" -a \
1930 "$installed_gnutls_version" != "$GNUTLS_VERSION" ] ; then
1931 echo "Installed GnuTLS version is $installed_gnutls_version"
1932 if [ -z "$GNUTLS_VERSION" ] ; then
1933 echo "GnuTLS is not requested"
1935 echo "Requested GnuTLS version is $GNUTLS_VERSION"
1940 if [ ! -z "$installed_nettle_version" -a \
1941 "$installed_nettle_version" != "$NETTLE_VERSION" ] ; then
1942 echo "Installed Nettle version is $installed_nettle_version"
1943 if [ -z "$NETTLE_VERSION" ] ; then
1944 echo "Nettle is not requested"
1946 echo "Requested Nettle version is $NETTLE_VERSION"
1951 if [ ! -z "$installed_gmp_version" -a \
1952 "$installed_gmp_version" != "$GMP_VERSION" ] ; then
1953 echo "Installed GMP version is $installed_gmp_version"
1954 if [ -z "$GMP_VERSION" ] ; then
1955 echo "GMP is not requested"
1957 echo "Requested GMP version is $GMP_VERSION"
1962 if [ ! -z "$installed_libgcrypt_version" -a \
1963 "$installed_libgcrypt_version" != "$LIBGCRYPT_VERSION" ] ; then
1964 echo "Installed libgcrypt version is $installed_libgcrypt_version"
1965 if [ -z "$LIBGCRYPT_VERSION" ] ; then
1966 echo "libgcrypt is not requested"
1968 echo "Requested libgcrypt version is $LIBGCRYPT_VERSION"
1970 uninstall_libgcrypt -r
1973 if [ ! -z "$installed_libgpg_error_version" -a \
1974 "$installed_libgpg_error_version" != "$LIBGPG_ERROR_VERSION" ] ; then
1975 echo "Installed libgpg-error version is $installed_libgpg_error_version"
1976 if [ -z "$LIBGPG_ERROR_VERSION" ] ; then
1977 echo "libgpg-error is not requested"
1979 echo "Requested libgpg-error version is $LIBGPG_ERROR_VERSION"
1981 uninstall_libgpg_error -r
1984 if [ ! -z "$installed_libsmi_version" -a \
1985 "$installed_libsmi_version" != "$LIBSMI_VERSION" ] ; then
1986 echo "Installed libsmi version is $installed_libsmi_version"
1987 if [ -z "$LIBSMI_VERSION" ] ; then
1988 echo "libsmi is not requested"
1990 echo "Requested libsmi version is $LIBSMI_VERSION"
1995 if [ ! -z "$installed_gtk_version" -a \
1996 "$installed_gtk_version" != "$GTK_VERSION" ] ; then
1997 echo "Installed GTK+ version is $installed_gtk_version"
1998 if [ -z "$GTK_VERSION" ] ; then
1999 echo "GTK+ is not requested"
2001 echo "Requested GTK+ version is $GTK_VERSION"
2006 if [ ! -z "$installed_gdk_pixbuf_version" -a \
2007 "$installed_gdk_pixbuf_version" != "$GDK_PIXBUF_VERSION" ] ; then
2008 echo "Installed gdk-pixbuf version is $installed_gdk_pixbuf_version"
2009 if [ -z "$GDK_PIXBUF_VERSION" ] ; then
2010 echo "gdk-pixbuf is not requested"
2012 echo "Requested gdk-pixbuf version is $GDK_PIXBUF_VERSION"
2014 uninstall_gdk_pixbuf -r
2017 if [ ! -z "$installed_pango_version" -a \
2018 "$installed_pango_version" != "$PANGO_VERSION" ] ; then
2019 echo "Installed Pango version is $installed_pango_version"
2020 if [ -z "$PANGO_VERSION" ] ; then
2021 echo "Pango is not requested"
2023 echo "Requested Pango version is $PANGO_VERSION"
2028 if [ ! -z "$installed_atk_version" -a \
2029 "$installed_atk_version" != "$ATK_VERSION" ] ; then
2030 echo "Installed ATK version is $installed_atk_version"
2031 if [ -z "$ATK_VERSION" ] ; then
2032 echo "ATK is not requested"
2034 echo "Requested ATK version is $ATK_VERSION"
2039 if [ ! -z "$installed_cairo_version" -a \
2040 "$installed_cairo_version" != "$CAIRO_VERSION" ] ; then
2041 echo "Installed Cairo version is $installed_cairo_version"
2042 if [ -z "$CAIRO_VERSION" ] ; then
2043 echo "Cairo is not requested"
2045 echo "Requested Cairo version is $CAIRO_VERSION"
2050 if [ ! -z "$installed_pixman_version" -a \
2051 "$installed_pixman_version" != "$PIXMAN_VERSION" ] ; then
2052 echo "Installed pixman version is $installed_pixman_version"
2053 if [ -z "$PIXMAN_VERSION" ] ; then
2054 echo "pixman is not requested"
2056 echo "Requested pixman version is $PIXMAN_VERSION"
2061 if [ ! -z "$installed_libpng_version" -a \
2062 "$installed_libpng_version" != "$PNG_VERSION" ] ; then
2063 echo "Installed libpng version is $installed_libpng_version"
2064 if [ -z "$PNG_VERSION" ] ; then
2065 echo "libpng is not requested"
2067 echo "Requested libpng version is $PNG_VERSION"
2072 if [ ! -z "$installed_qt_version" -a \
2073 "$installed_qt_version" != "$QT_VERSION" ] ; then
2074 echo "Installed Qt version is $installed_qt_version"
2075 if [ -z "$QT_VERSION" ] ; then
2076 echo "Qt is not requested"
2078 echo "Requested Qt version is $QT_VERSION"
2083 if [ ! -z "$installed_glib_version" -a \
2084 "$installed_glib_version" != "$GLIB_VERSION" ] ; then
2085 echo "Installed GLib version is $installed_glib_version"
2086 if [ -z "$GLIB_VERSION" ] ; then
2087 echo "GLib is not requested"
2089 echo "Requested GLib version is $GLIB_VERSION"
2094 if [ ! -z "$installed_pkg_config_version" -a \
2095 "$installed_pkg_config_version" != "$PKG_CONFIG_VERSION" ] ; then
2096 echo "Installed pkg-config version is $installed_pkg_config_version"
2097 if [ -z "$PKG_CONFIG_VERSION" ] ; then
2098 echo "pkg-config is not requested"
2100 echo "Requested pkg-config version is $PKG_CONFIG_VERSION"
2102 uninstall_pkg_config -r
2105 if [ ! -z "$installed_gettext_version" -a \
2106 "$installed_gettext_version" != "$GETTEXT_VERSION" ] ; then
2107 echo "Installed GNU gettext version is $installed_gettext_version"
2108 if [ -z "$GETTEXT_VERSION" ] ; then
2109 echo "GNU gettext is not requested"
2111 echo "Requested GNU gettext version is $GETTEXT_VERSION"
2113 uninstall_gettext -r
2116 if [ ! -z "$installed_cmake_version" -a \
2117 "$installed_cmake_version" != "$CMAKE_VERSION" ] ; then
2118 echo "Installed CMake version is $installed_cmake_version"
2119 if [ -z "$CMAKE_VERSION" ] ; then
2120 echo "CMake is not requested"
2122 echo "Requested CMake version is $CMAKE_VERSION"
2125 # XXX - really remove this?
2126 # Or should we remember it as installed only if this script
2132 if [ ! -z "$installed_libtool_version" -a \
2133 "$installed_libtool_version" != "$LIBTOOL_VERSION" ] ; then
2134 echo "Installed GNU libtool version is $installed_libtool_version"
2135 if [ -z "$LIBTOOL_VERSION" ] ; then
2136 echo "GNU libtool is not requested"
2138 echo "Requested GNU libtool version is $LIBTOOL_VERSION"
2140 uninstall_libtool -r
2143 if [ ! -z "$installed_automake_version" -a \
2144 "$installed_automake_version" != "$AUTOMAKE_VERSION" ] ; then
2145 echo "Installed GNU automake version is $installed_automake_version"
2146 if [ -z "$AUTOMAKE_VERSION" ] ; then
2147 echo "GNU automake is not requested"
2149 echo "Requested GNU automake version is $AUTOMAKE_VERSION"
2151 uninstall_automake -r
2154 if [ ! -z "$installed_autoconf_version" -a \
2155 "$installed_autoconf_version" != "$AUTOCONF_VERSION" ] ; then
2156 echo "Installed GNU autoconf version is $installed_autoconf_version"
2157 if [ -z "$AUTOCONF_VERSION" ] ; then
2158 echo "GNU autoconf is not requested"
2160 echo "Requested GNU autoconf version is $AUTOCONF_VERSION"
2162 uninstall_autoconf -r
2165 if [ ! -z "$installed_lzip_version" -a \
2166 "$installed_lzip_version" != "$LZIP_VERSION" ] ; then
2167 echo "Installed lzip version is $installed_lzip_version"
2168 if [ -z "$LZIP_VERSION" ] ; then
2169 echo "lzip is not requested"
2171 echo "Requested lzip version is $LZIP_VERSION"
2176 if [ ! -z "$installed_xz_version" -a \
2177 "$installed_xz_version" != "$XZ_VERSION" ] ; then
2178 echo "Installed xz version is $installed_xz_version"
2179 if [ -z "$XZ_VERSION" ] ; then
2180 echo "xz is not requested"
2182 echo "Requested xz version is $XZ_VERSION"
2188 # Start with xz: It is the sole download format of glib later than 2.31.2
2203 # Start with GNU gettext; GLib requires it, and macOS doesn't have it
2204 # or a BSD-licensed replacement.
2206 # At least on Lion with Xcode 4, _FORTIFY_SOURCE gets defined as 2
2207 # by default, which causes, for example, stpncpy to be defined as
2208 # a hairy macro that collides with the GNU gettext configure script's
2209 # attempts to workaround AIX's lack of a declaration for stpncpy,
2210 # with the result being a huge train wreck. Define _FORTIFY_SOURCE
2211 # as 0 in an attempt to keep the trains on separate tracks.
2216 # GLib depends on pkg-config.
2217 # By default, pkg-config depends on GLib; we break the dependency cycle
2218 # by configuring pkg-config to use its own internal version of GLib.
2225 # Now we have reached a point where we can build everything but
2226 # the GUI (Wireshark).
2230 if [ "$GTK_VERSION" ]; then
2232 # GTK+ 3 requires a newer Cairo build than the one that comes with
2233 # 10.6, so we build Cairo if we are using GTK+ 3.
2235 # In 10.6 and 10.7, it's an X11 library; if we build with "native" GTK+
2236 # rather than X11 GTK+, we might have to build and install Cairo.
2237 # In 10.8 and later, there is no X11, but it's included in Xquartz;
2238 # again, if we build with "native" GTK+, we'd have to build and install
2241 if [[ "$GTK_MAJOR_VERSION" -eq 3 || "$cairo_not_in_the_os" = yes ]]; then
2243 # Requirements for Cairo first
2245 # The libpng that comes with the X11 for Leopard has a bogus
2246 # pkg-config file that lies about where the header files are,
2247 # which causes other packages not to be able to find its
2250 # The libpng in later versions is not what the version of
2251 # libpixman we build below wants - it wants libpng15.
2256 # The libpixman versions that come with the X11s for Leopard,
2257 # Snow Leopard, and Lion is too old to support Cairo's image
2258 # surface backend feature (which requires pixman-1 >= 0.22.0).
2260 # XXX - what about the one that comes with the latest version
2266 # And now Cairo itself.
2267 # XXX - with the libxcb that comes with 10.6,
2268 # xcb_discard_reply() is missing, and the build fails.
2283 # Now we have reached a point where we can build everything including
2284 # the GUI (Wireshark), but not with any optional features such as
2285 # SNMP OID resolution, some forms of decryption, Lua scripting, playback
2286 # of audio, or GeoIP mapping of IP addresses.
2288 # We now conditionally download optional libraries to support them;
2289 # the default is to download them all.
2294 install_libgpg_error
2326 if [ -d macosx-support-libs ]
2328 cd macosx-support-libs
2331 # Uninstall items in the reverse order from the order in which they're
2332 # installed. Only uninstall if the download/build/install process
2333 # completed; uninstall the version that appears in the name of
2336 # We also do a "make distclean", so that we don't have leftovers from
2337 # old configurations.
2367 uninstall_libgpg_error
2373 uninstall_gdk_pixbuf
2389 uninstall_pkg_config
2394 # XXX - really remove this?
2395 # Or should we remember it as installed only if this script
2413 # Do we have permission to write in /usr/local?
2415 # If so, assume we have permission to write in its subdirectories.
2416 # (If that's not the case, this test needs to check the subdirectories
2419 # If not, do "make install", "make uninstall", the removes for Lua,
2420 # and the renames of [g]libtool* with sudo.
2422 if [ -w /usr/local ]
2424 DO_MAKE_INSTALL="make install"
2425 DO_MAKE_UNINSTALL="make uninstall"
2429 DO_MAKE_INSTALL="sudo make install"
2430 DO_MAKE_UNINSTALL="sudo make uninstall"
2436 # If we have SDKs available, the default target OS is the major version
2437 # of the one we're running; get that and strip off the third component
2440 for i in /Developer/SDKs \
2441 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \
2442 /Library/Developer/CommandLineTools/SDKs
2446 min_osx_target=`sw_vers -productVersion | sed 's/\([0-9]*\)\.\([0-9]*\)\.[0-9]*/\1.\2/'`
2449 # That's also the OS whose SDK we'd be using.
2451 sdk_target=$min_osx_target
2457 # Parse command-line flags:
2460 # -t <target> - build libraries so that they'll work on the specified
2461 # version of macOS and later versions.
2462 # -u - do an uninstall.
2463 # -n - download all packages, but don't build or install.
2468 while getopts ht:un name
2478 min_osx_target="$OPTARG"
2481 echo "Usage: macosx-setup.sh [ -t <target> ] [ -u ] [ -n ]" 1>&1
2488 # Get the version numbers of installed packages, if any.
2490 if [ -d macosx-support-libs ]
2492 cd macosx-support-libs
2494 installed_xz_version=`ls xz-*-done 2>/dev/null | sed 's/xz-\(.*\)-done/\1/'`
2495 installed_lzip_version=`ls lzip-*-done 2>/dev/null | sed 's/lzip-\(.*\)-done/\1/'`
2496 installed_autoconf_version=`ls autoconf-*-done 2>/dev/null | sed 's/autoconf-\(.*\)-done/\1/'`
2497 installed_automake_version=`ls automake-*-done 2>/dev/null | sed 's/automake-\(.*\)-done/\1/'`
2498 installed_libtool_version=`ls libtool-*-done 2>/dev/null | sed 's/libtool-\(.*\)-done/\1/'`
2499 installed_cmake_version=`ls cmake-*-done 2>/dev/null | sed 's/cmake-\(.*\)-done/\1/'`
2500 installed_gettext_version=`ls gettext-*-done 2>/dev/null | sed 's/gettext-\(.*\)-done/\1/'`
2501 installed_pkg_config_version=`ls pkg-config-*-done 2>/dev/null | sed 's/pkg-config-\(.*\)-done/\1/'`
2502 installed_glib_version=`ls glib-*-done 2>/dev/null | sed 's/glib-\(.*\)-done/\1/'`
2503 installed_qt_version=`ls qt-*-done 2>/dev/null | sed 's/qt-\(.*\)-done/\1/'`
2504 installed_libpng_version=`ls libpng-*-done 2>/dev/null | sed 's/libpng-\(.*\)-done/\1/'`
2505 installed_pixman_version=`ls pixman-*-done 2>/dev/null | sed 's/pixman-\(.*\)-done/\1/'`
2506 installed_cairo_version=`ls cairo-*-done 2>/dev/null | sed 's/cairo-\(.*\)-done/\1/'`
2507 installed_atk_version=`ls atk-*-done 2>/dev/null | sed 's/atk-\(.*\)-done/\1/'`
2508 installed_pango_version=`ls pango-*-done 2>/dev/null | sed 's/pango-\(.*\)-done/\1/'`
2509 installed_gdk_pixbuf_version=`ls gdk-pixbuf-*-done 2>/dev/null | sed 's/gdk-pixbuf-\(.*\)-done/\1/'`
2510 installed_gtk_version=`ls gtk+-*-done 2>/dev/null | sed 's/gtk+-\(.*\)-done/\1/'`
2511 installed_libsmi_version=`ls libsmi-*-done 2>/dev/null | sed 's/libsmi-\(.*\)-done/\1/'`
2512 installed_libgpg_error_version=`ls libgpg-error-*-done 2>/dev/null | sed 's/libgpg-error-\(.*\)-done/\1/'`
2513 installed_libgcrypt_version=`ls libgcrypt-*-done 2>/dev/null | sed 's/libgcrypt-\(.*\)-done/\1/'`
2514 installed_gmp_version=`ls gmp-*-done 2>/dev/null | sed 's/gmp-\(.*\)-done/\1/'`
2515 installed_nettle_version=`ls nettle-*-done 2>/dev/null | sed 's/nettle-\(.*\)-done/\1/'`
2516 installed_gnutls_version=`ls gnutls-*-done 2>/dev/null | sed 's/gnutls-\(.*\)-done/\1/'`
2517 installed_lua_version=`ls lua-*-done 2>/dev/null | sed 's/lua-\(.*\)-done/\1/'`
2518 installed_portaudio_version=`ls portaudio-*-done 2>/dev/null | sed 's/portaudio-\(.*\)-done/\1/'`
2519 installed_snappy_version=`ls snappy-*-done 2>/dev/null | sed 's/snappy-\(.*\)-done/\1/'`
2520 installed_libxml2_version=`ls libxml2-*-done 2>/dev/null | sed 's/libxml2-\(.*\)-done/\1/'`
2521 installed_lz4_version=`ls lz4-*-done 2>/dev/null | sed 's/lz4-\(.*\)-done/\1/'`
2522 installed_sbc_version=`ls sbc-*-done 2>/dev/null | sed 's/sbc-\(.*\)-done/\1/'`
2523 installed_geoip_version=`ls geoip-*-done 2>/dev/null | sed 's/geoip-\(.*\)-done/\1/'`
2524 installed_cares_version=`ls c-ares-*-done 2>/dev/null | sed 's/c-ares-\(.*\)-done/\1/'`
2525 installed_libssh_version=`ls libssh-*-done 2>/dev/null | sed 's/libssh-\(.*\)-done/\1/'`
2526 installed_nghttp2_version=`ls nghttp2-*-done 2>/dev/null | sed 's/nghttp2-\(.*\)-done/\1/'`
2529 # If we don't have a versioned -done file for portaudio, but do have
2530 # an unversioned -done file for it, assume the installed version is the
2531 # requested version, and rename the -done file to include that version.
2533 if [ -z "$installed_portaudio_version" -a -f portaudio-done ] ; then
2534 mv portaudio-done portaudio-$PORTAUDIO_VERSION-done
2535 installed_portaudio_version=`ls portaudio-*-done 2>/dev/null | sed 's/portaudio-\(.*\)-done/\1/'`
2541 if [ "$do_uninstall" = "yes" ]
2548 # Configure scripts tend to set CFLAGS and CXXFLAGS to "-g -O2" if
2549 # invoked without CFLAGS or CXXFLAGS being set in the environment.
2551 # However, we *are* setting them in the environment, for our own
2552 # nefarious purposes, so start them out as "-g -O2".
2558 # To make this work on Leopard (rather than working *on* Snow Leopard
2559 # when building *for* Leopard) will take more work.
2561 # For one thing, Leopard's /usr/X11/lib/libXdamage.la claims, at least
2562 # with all software updates applied, that the Xdamage shared library
2563 # is libXdamage.1.0.0.dylib, but it is, in fact, libXdamage.1.1.0.dylib.
2564 # This causes problems when building GTK+, so the script would have to
2567 if [[ $DARWIN_MAJOR_VERSION -le 9 ]]; then
2568 echo "This script does not support any versions of macOS before Snow Leopard" 1>&2
2572 # if no make options are present, set default options
2573 if [ -z "$MAKE_BUILD_OPTS" ] ; then
2574 # by default use 1.5x number of cores for parallel build
2575 MAKE_BUILD_OPTS="-j $(( $(sysctl -n hw.logicalcpu) * 3 / 2))"
2579 # If we have a target release, look for the oldest SDK that's for an
2580 # OS equal to or later than that one, and build libraries against it
2581 # rather than against the headers and, more importantly, libraries
2582 # that come with the OS, so that we don't end up with support libraries
2583 # that only work on the OS version on which we built them, not earlier
2584 # versions of the same release, or earlier releases if the minimum is
2587 if [ ! -z "$min_osx_target" ]
2590 # Get the real version - strip off the "10.".
2592 deploy_real_version=`echo "$min_osx_target" | sed -n 's/10\.\(.*\)/\1/p'`
2595 # Search each directory that might contain SDKs.
2598 for sdksdir in /Developer/SDKs \
2599 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \
2600 /Library/Developer/CommandLineTools/SDKs
2603 # Get a list of all the SDKs.
2605 if ! test -d "$sdksdir"
2608 # There is no directory with that name.
2609 # Move on to the next one in the list, if any.
2615 # Get a list of all the SDKs in that directory, if any.
2617 sdklist=`(cd "$sdksdir"; ls -d MacOSX10.[0-9]*.sdk 2>/dev/null)`
2622 # Get the real version for this SDK.
2624 sdk_real_version=`echo "$sdk" | sed -n 's/MacOSX10\.\(.*\)\.sdk/\1/p'`
2627 # Is it for the deployment target or some later release?
2629 if test "$sdk_real_version" -ge "$deploy_real_version"
2634 sdkpath="$sdksdir/$sdk"
2635 qt_sdk_arg="-sdk $sdk"
2641 if [ -z "$sdkpath" ]
2643 echo "macosx-setup.sh: Couldn't find an SDK for macOS $min_osx_target or later" 1>&2
2648 sdk_target=10.$sdk_real_version
2649 echo "Using the 10.$sdk_real_version SDK"
2652 # Make sure there are links to /usr/local/include and /usr/local/lib
2653 # in the SDK's usr/local.
2655 if [ ! -e $SDKPATH/usr/local/include ]
2657 if [ ! -d $SDKPATH/usr/local ]
2659 sudo mkdir $SDKPATH/usr/local
2661 sudo ln -s /usr/local/include $SDKPATH/usr/local/include
2663 if [ ! -e $SDKPATH/usr/local/lib ]
2665 if [ ! -d $SDKPATH/usr/local ]
2667 sudo mkdir $SDKPATH/usr/local
2669 sudo ln -s /usr/local/lib $SDKPATH/usr/local/lib
2673 # Set the minimum OS version for which to build to the specified
2674 # minimum target OS version, so we don't, for example, end up using
2675 # linker features supported by the OS verson on which we're building
2676 # but not by the target version.
2678 VERSION_MIN_FLAGS="-mmacosx-version-min=$min_osx_target"
2681 # Compile and link against the SDK.
2683 SDKFLAGS="-isysroot $SDKPATH"
2685 if [[ "$min_osx_target" == "10.5" ]]
2688 # Cairo is part of Mac OS X 10.6 and later.
2689 # The *headers* are supplied by 10.5, but the *libraries*
2690 # aren't, so we have to build it if we're building for 10.5.
2692 cairo_not_in_the_os=yes
2695 # Build with older versions of the support libraries, as
2696 # were used on the Wireshark Leopard buildbot at one
2697 # point. (Most of these versions come from the About page
2698 # from Wireshark 1.8.6, the last build done on that buildbot;
2699 # the ATK version isn't reported, so this is a guess.)
2701 # If you want to try building with newer versions of
2702 # the libraries, note that:
2704 # The version of fontconfig that comes with Leopard doesn't
2705 # support FC_WEIGHT_EXTRABLACK, so we can't use any version
2706 # of Pango newer than 1.22.4.
2708 # However, Pango 1.22.4 doesn't work with versions of GLib
2709 # after 2.29.6, because Pango 1.22.4 uses G_CONST_RETURN and
2710 # GLib 2.29.8 and later deprecate it (there doesn't appear to
2711 # be a GLib 2.29.7). That means we'd either have to patch
2712 # Pango not to use it (just use "const"; G_CONST_RETURN was
2713 # there to allow code to choose whether to use "const" or not),
2714 # or use GLib 2.29.6 or earlier.
2716 # GLib 2.29.6 includes an implementation of g_bit_lock() that,
2717 # on x86 (32-bit and 64-bit), uses asms in a fashion
2718 # ("asm volatile goto") that requires GCC 4.5 or later, which
2719 # is later than the compilers that come with Leopard and Snow
2720 # Leopard. Recent versions of GLib check for that, but 2.29.6
2721 # doesn't, so, if you want to build GLib 2.29.6 on Leopard or
2722 # Snow Leopard, you would have to patch glib/gbitlock.c to do
2723 # what the newer versions of GLib do:
2725 # define a USE_ASM_GOTO macro that indicates whether "asm goto"
2727 # #if (defined (i386) || defined (__amd64__))
2728 # #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
2729 # #define USE_ASM_GOTO 1
2733 # replace all occurrences of
2735 # #if defined (__GNUC__) && (defined (i386) || defined (__amd64__))
2739 # #ifdef USE_ASM_GOTO
2741 # Using GLib 2.29.6 or earlier, however, means that we can't
2742 # use a version of ATK later than 2.3.93, as those versions
2743 # don't work with GLib 2.29.6. The same applies to gdk-pixbuf;
2744 # versions of gdk-pixbuf after 2.24.1 won't work with GLib
2747 # Then you have to make sure that what you've build doesn't
2748 # cause the X server that comes with Leopard to crash; at
2749 # least one attempt at building for Leopard did.
2751 # At least if building on Leopard, you might also find
2752 # that, with various older versions of Cairo, including
2753 # 1.6.4 and at least some 1.8.x versions, when you try to
2754 # build it, the build fails because it can't find
2755 # png_set_longjmp_fn(). I vaguely remember dealing with that,
2756 # ages ago, but don't remember what I did.
2759 if [ "$CAIRO_VERSION" ]
2763 if [ "$ATK_VERSION" ]
2767 if [ "$PANGO_VERSION" ]
2769 PANGO_VERSION=1.20.2
2771 if [ "$GTK_VERSION" ]
2777 # That version of GTK+ includes gdk-pixbuf.
2778 # XXX - base this on the version of GTK+ requested.
2783 # Libgcrypt 1.5.0 fails to compile due to some problem with an
2784 # asm in rijndael.c, at least with i686-apple-darwin10-gcc-4.2.1
2785 # (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3) when building
2788 # We try libgcrypt 1.4.3 instead, as that's what shows up in
2789 # the version from the Leopard buildbot.
2790 LIBGCRYPT_VERSION=1.4.3
2793 # Build 32-bit while we're at it; Leopard has a bug that
2794 # causes some BPF functions not to work with 64-bit userland
2795 # code, so capturing won't work.
2797 CFLAGS="$CFLAGS -arch i386"
2798 CXXFLAGS="$CXXFLAGS -arch i386"
2799 export LDFLAGS="$LDFLAGS -arch i386"
2807 # You need Xcode or the command-line tools installed to get the compilers.
2809 if [ ! -x /usr/bin/xcodebuild ]; then
2810 echo "Please install Xcode first (should be available on DVD or from the Mac App Store)."
2814 if [ "$QT_VERSION" ]; then
2816 # We need Xcode, not just the command-line tools, installed to build
2819 # At least with Xcode 8, /usr/bin/xcodebuild --help fails if only
2820 # the command-line tools are installed and succeeds if Xcode is
2821 # installed. Unfortunately, it fails *with* Xcode 3, but
2822 # /usr/bin/xcodebuild -version works with that and with Xcode 8.
2823 # Hopefully it fails with only the command-line tools installed.
2825 if /usr/bin/xcodebuild -version >/dev/null 2>&1; then
2828 echo "Please install Xcode first (should be available on DVD or from the Mac App Store)."
2829 echo "The command-line build tools are not sufficient to build Qt."
2833 if [ "$GTK_VERSION" ]; then
2835 # If we're building with GTK+, you also need the X11 SDK; with at least
2836 # some versions of macOS and Xcode, that is, I think, an optional install.
2837 # (Or it might be installed with X11, but I think *that* is an optional
2838 # install on at least some versions of macOS.)
2840 if [ ! -d /usr/X11/include ]; then
2841 echo "Please install X11 and the X11 SDK first."
2842 echo " You can either download the latest package from"
2843 echo " http://www.xquartz.org/ and install it or install"
2844 echo " the native Apple package if you are on Lion or below."
2849 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig
2852 # Do all the downloads and untarring in a subdirectory, so all that
2853 # stuff can be removed once we've installed the support libraries.
2855 if [ ! -d macosx-support-libs ]
2857 mkdir macosx-support-libs || exit 1
2859 cd macosx-support-libs
2866 # Indicate what paths to use for pkg-config and cmake.
2868 pkg_config_path=/usr/local/lib/pkgconfig
2869 if [ "$QT_VERSION" ]; then
2870 qt_base_path=$HOME/Qt$QT_VERSION/$QT_MAJOR_MINOR_VERSION/clang_64
2871 pkg_config_path="$pkg_config_path":"$qt_base_path/lib/pkgconfig"
2872 CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH":"$qt_base_path/lib/cmake"
2874 if [ "$GTK_VERSION" ]; then
2875 pkg_config_path="$pkg_config_path":/usr/X11/lib/pkgconfig
2879 echo "All required dependencies downloaded. Run without -n to install them."
2883 echo "You are now prepared to build Wireshark."
2885 if [[ $CMAKE ]]; then
2886 echo "To build with CMAKE:"
2888 echo "export PKG_CONFIG_PATH=$pkg_config_path"
2889 echo "export CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH"
2890 echo "export PATH=$PATH:$qt_base_path/bin"
2892 echo "mkdir build; cd build"
2894 echo "make $MAKE_BUILD_OPTS app_bundle"
2895 echo "make install/strip"
2898 if [[ $AUTOTOOLS ]]; then
2899 echo "To build with AUTOTOOLS:"
2901 echo "export PKG_CONFIG_PATH=$pkg_config_path"
2904 echo "mkdir build; cd build"
2906 echo "make $MAKE_BUILD_OPTS"
2910 echo "Make sure you are allowed capture access to the network devices"
2911 echo "See: https://wiki.wireshark.org/CaptureSetup/CapturePrivileges"