nexmon – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 #!/bin/sh
2 # Setup development environment on Mac OS X (tested with 10.6.8 and Xcode 3.2.6)
3 #
4 # Copyright 2011 Michael Tuexen, Joerg Mayer, Guy Harris (see AUTHORS file)
5 #
6 # Wireshark - Network traffic analyzer
7 # By Gerald Combs <gerald@wireshark.org>
8 # Copyright 1998 Gerald Combs
9 #
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.
14 #
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.
19 #
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.
23  
24 #
25 # To install cmake
26 #
27 CMAKE=1
28 #
29 # To install autotools
30 #
31 AUTOTOOLS=1
32 #
33 # To build all libraries as 32-bit libraries uncomment the following three lines.
34 #
35 # export CFLAGS="$CFLAGS -arch i386"
36 # export CXXFLAGS="$CXXFLAGS -arch i386"
37 # export LDFLAGS="$LDFLAGS -arch i386"
38 #
39 # and change "macx-clang" to "macx-clang-32" in the line below.
40 #
41 # Note: when building against the 10.6 SDK, clang fails, because there's
42 # a missing libstdc++.dylib in the SDK; this does not bother g++, however.
43 #
44 #TARGET_PLATFORM=macx-g++
45 TARGET_PLATFORM=macx-clang
46  
47 #
48 # Versions of packages to download and install.
49 #
50  
51 #
52 # Some packages need xz to unpack their current source.
53 # xz is not yet provided with OS X.
54 #
55 XZ_VERSION=5.0.8
56  
57 #
58 # In case we want to build with cmake.
59 #
60 CMAKE_VERSION=${CMAKE_VERSION-2.8.12.2}
61  
62 #
63 # The following libraries and tools are required even to build only TShark.
64 #
65 GETTEXT_VERSION=0.18.2
66 GLIB_VERSION=2.36.0
67 PKG_CONFIG_VERSION=0.28
68  
69 #
70 # One or more of the following libraries are required to build Wireshark.
71 #
72 # To override the versions of Qt and GTK call the script with some of the
73 # variables set to the new values. Setting a variable to empty will disable
74 # building the toolkit and will un-install any version previously installed
75 # by the script, e.g. "GTK_VERSION=3.5.2 QT_VERSION= ./macos-setup.sh"
76 # will build and install with GTK+ 3.5.2 and will not install Qt (and,
77 # if the script installed Qt earlier, will un-install that version of Qt).
78 #
79 # Note that Qt 5, prior to 5.5.0, mishandles context menus in ways that,
80 # for example, cause them not to work reliably in the packet detail or
81 # packet data pane; see, for example, Qt bugs QTBUG-31937, QTBUG-41017,
82 # and QTBUG-43464, all of which seem to be the same bug.
83 #
84 QT_VERSION=${QT_VERSION-5.5.0}
85 GTK_VERSION=${GTK_VERSION-2.24.17}
86 if [ "$GTK_VERSION" ]; then
87 #
88 # We'll be building GTK+, so we need some additional libraries.
89 #
90 GTK_MAJOR_VERSION="`expr $GTK_VERSION : '\([0-9][0-9]*\).*'`"
91 GTK_MINOR_VERSION="`expr $GTK_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
92 GTK_DOTDOT_VERSION="`expr $GTK_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
93  
94 ATK_VERSION=2.8.0
95 PANGO_VERSION=1.30.1
96 PNG_VERSION=1.6.20
97 PIXMAN_VERSION=0.26.0
98 CAIRO_VERSION=1.12.2
99 GDK_PIXBUF_VERSION=2.28.0
100 fi
101 if [ "$QT_VERSION" ]; then
102 QT_MAJOR_VERSION="`expr $QT_VERSION : '\([0-9][0-9]*\).*'`"
103 QT_MINOR_VERSION="`expr $QT_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
104 QT_DOTDOT_VERSION="`expr $QT_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
105 QT_MAJOR_MINOR_VERSION=$QT_MAJOR_VERSION.$QT_MINOR_VERSION
106 QT_MAJOR_MINOR_DOTDOT_VERSION=$QT_MAJOR_VERSION.$QT_MINOR_VERSION.$QT_DOTDOT_VERSION
107 fi
108  
109 #
110 # The following libraries are optional.
111 # Comment them out if you don't want them, but note that some of
112 # the optional libraries are required by other optional libraries.
113 #
114 LIBSMI_VERSION=0.4.8
115 #
116 # libgpg-error is required for libgcrypt.
117 #
118 LIBGPG_ERROR_VERSION=1.10
119 #
120 # libgcrypt is required for GnuTLS.
121 #
122 LIBGCRYPT_VERSION=1.5.0
123 GNUTLS_VERSION=2.12.19
124 # Use 5.2.4, not 5.3, for now; lua_bitop.c hasn't been ported to 5.3
125 # yet, and we need to check for compatibility issues (we'd want Lua
126 # scripts to work with 5.1, 5.2, and 5.3, as long as they only use Lua
127 # features present in all three versions)
128 LUA_VERSION=5.2.4
129 PORTAUDIO_VERSION=pa_stable_v19_20111121
130 #
131 # XXX - they appear to have an unversioned gzipped tarball for the
132 # current version; should we just download that, with some other
133 # way of specifying whether to download the GeoIP API?
134 #
135 GEOIP_VERSION=1.4.8
136  
137 CARES_VERSION=1.10.0
138  
139 LIBSSH_VERSION=0.7.3
140  
141 DARWIN_MAJOR_VERSION=`uname -r | sed 's/\([0-9]*\).*/\1/'`
142  
143 #
144 # GNU autotools; they're provided with releases up to Snow Leopard, but
145 # not in later releases, and the Snow Leopard version is too old for
146 # current Wireshark, so we install them unconditionally.
147 #
148 AUTOCONF_VERSION=2.69
149 AUTOMAKE_VERSION=1.13.3
150 LIBTOOL_VERSION=2.4.6
151  
152 install_xz() {
153 if [ "$XZ_VERSION" -a ! -f xz-$XZ_VERSION-done ] ; then
154 echo "Downloading, building, and installing xz:"
155 [ -f xz-$XZ_VERSION.tar.bz2 ] || curl -O http://tukaani.org/xz/xz-$XZ_VERSION.tar.bz2 || exit 1
156 bzcat xz-$XZ_VERSION.tar.bz2 | tar xf - || exit 1
157 cd xz-$XZ_VERSION
158 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0" ./configure || exit 1
159 make $MAKE_BUILD_OPTS || exit 1
160 $DO_MAKE_INSTALL || exit 1
161 cd ..
162 touch xz-$XZ_VERSION-done
163 fi
164 }
165  
166 uninstall_xz() {
167 if [ ! -z "$installed_xz_version" ] ; then
168 echo "Uninstalling xz:"
169 cd xz-$installed_xz_version
170 $DO_MAKE_UNINSTALL || exit 1
171 make distclean || exit 1
172 cd ..
173 rm xz-$installed_xz_version-done
174  
175 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
176 #
177 # Get rid of the previously downloaded and unpacked version.
178 #
179 rm -rf xz-$installed_xz_version
180 rm -rf xz-$installed_xz_version.tar.bz2
181 fi
182  
183 installed_xz_version=""
184 fi
185 }
186  
187 install_autoconf() {
188 if [ "$AUTOCONF_VERSION" -a ! -f autoconf-$AUTOCONF_VERSION-done ] ; then
189 echo "Downloading, building and installing GNU autoconf..."
190 [ -f autoconf-$AUTOCONF_VERSION.tar.xz ] || curl -O ftp://ftp.gnu.org/gnu/autoconf/autoconf-$AUTOCONF_VERSION.tar.xz || exit 1
191 xzcat autoconf-$AUTOCONF_VERSION.tar.xz | tar xf - || exit 1
192 cd autoconf-$AUTOCONF_VERSION
193 ./configure || exit 1
194 make $MAKE_BUILD_OPTS || exit 1
195 $DO_MAKE_INSTALL || exit 1
196 cd ..
197 touch autoconf-$AUTOCONF_VERSION-done
198 fi
199 }
200  
201 uninstall_autoconf() {
202 if [ ! -z "$installed_autoconf_version" ] ; then
203 #
204 # automake and libtool depend on this, so uninstall them.
205 #
206 uninstall_libtool
207 uninstall_automake
208  
209 echo "Uninstalling GNU autoconf:"
210 cd autoconf-$installed_autoconf_version
211 $DO_MAKE_UNINSTALL || exit 1
212 make distclean || exit 1
213 cd ..
214 rm autoconf-$installed_autoconf_version-done
215  
216 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
217 #
218 # Get rid of the previously downloaded and unpacked version.
219 #
220 rm -rf autoconf-$installed_autoconf_version
221 rm -rf autoconf-$installed_autoconf_version.tar.xz
222 fi
223  
224 installed_autoconf_version=""
225 fi
226 }
227  
228 install_automake() {
229 if [ "$AUTOMAKE_VERSION" -a ! -f automake-$AUTOMAKE_VERSION-done ] ; then
230 echo "Downloading, building and installing GNU automake..."
231 [ -f automake-$AUTOMAKE_VERSION.tar.xz ] || curl -O ftp://ftp.gnu.org/gnu/automake/automake-$AUTOMAKE_VERSION.tar.xz || exit 1
232 xzcat automake-$AUTOMAKE_VERSION.tar.xz | tar xf - || exit 1
233 cd automake-$AUTOMAKE_VERSION
234 ./configure || exit 1
235 make $MAKE_BUILD_OPTS || exit 1
236 $DO_MAKE_INSTALL || exit 1
237 cd ..
238 touch automake-$AUTOMAKE_VERSION-done
239 fi
240 }
241  
242 uninstall_automake() {
243 if [ ! -z "$installed_automake_version" ] ; then
244 #
245 # libtool depends on this(?), so uninstall it.
246 #
247 uninstall_libtool "$@"
248  
249 echo "Uninstalling GNU automake:"
250 cd automake-$installed_automake_version
251 $DO_MAKE_UNINSTALL || exit 1
252 make distclean || exit 1
253 cd ..
254 rm automake-$installed_automake_version-done
255  
256 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
257 #
258 # Get rid of the previously downloaded and unpacked version.
259 #
260 rm -rf automake-$installed_automake_version
261 rm -rf automake-$installed_automake_version.tar.xz
262 fi
263  
264 installed_automake_version=""
265 fi
266 }
267  
268 install_libtool() {
269 if [ "$LIBTOOL_VERSION" -a ! -f libtool-$LIBTOOL_VERSION-done ] ; then
270 echo "Downloading, building and installing GNU libtool..."
271 [ -f libtool-$LIBTOOL_VERSION.tar.xz ] || curl -O ftp://ftp.gnu.org/gnu/libtool/libtool-$LIBTOOL_VERSION.tar.xz || exit 1
272 xzcat libtool-$LIBTOOL_VERSION.tar.xz | tar xf - || exit 1
273 cd libtool-$LIBTOOL_VERSION
274 ./configure || exit 1
275 make $MAKE_BUILD_OPTS || exit 1
276 $DO_MAKE_INSTALL || exit 1
277 $DO_MV /usr/local/bin/libtool /usr/local/bin/glibtool
278 $DO_MV /usr/local/bin/libtoolize /usr/local/bin/glibtoolize
279 cd ..
280 touch libtool-$LIBTOOL_VERSION-done
281 fi
282 }
283  
284 uninstall_libtool() {
285 if [ ! -z "$installed_libtool_version" ] ; then
286 echo "Uninstalling GNU libtool:"
287 cd libtool-$installed_libtool_version
288 $DO_MV /usr/local/bin/glibtool /usr/local/bin/libtool
289 $DO_MV /usr/local/bin/glibtoolize /usr/local/bin/libtoolize
290 $DO_MAKE_UNINSTALL || exit 1
291 make distclean || exit 1
292 cd ..
293 rm libtool-$installed_libtool_version-done
294  
295 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
296 #
297 # Get rid of the previously downloaded and unpacked version.
298 #
299 rm -rf libtool-$installed_libtool_version
300 rm -rf libtool-$installed_libtool_version.tar.xz
301 fi
302  
303 installed_libtool_version=""
304 fi
305 }
306  
307 install_cmake() {
308 if [ -n "$CMAKE" -a ! -f cmake-$CMAKE_VERSION-done ]; then
309 echo "Downloading and installing CMake:"
310 CMAKE_MAJOR_VERSION="`expr $CMAKE_VERSION : '\([0-9][0-9]*\).*'`"
311 CMAKE_MINOR_VERSION="`expr $CMAKE_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
312 CMAKE_DOTDOT_VERSION="`expr $CMAKE_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
313 CMAKE_MAJOR_MINOR_VERSION=$CMAKE_MAJOR_VERSION.$CMAKE_MINOR_VERSION
314  
315 #
316 # NOTE: the "64" in "Darwin64" doesn't mean "64-bit-only"; the
317 # package in question supports both 32-bit and 64-bit x86.
318 #
319 case "$CMAKE_MAJOR_VERSION" in
320  
321 0|1)
322 echo "CMake $CMAKE_VERSION" is too old 1>&2
323 ;;
324  
325 2)
326 #
327 # Download the DMG, run the installer.
328 #
329 [ -f cmake-$CMAKE_VERSION-Darwin64-universal.dmg ] || curl -O https://cmake.org/files/v$CMAKE_MAJOR_MINOR_VERSION/cmake-$CMAKE_VERSION-Darwin64-universal.dmg || exit 1
330 sudo hdiutil attach cmake-$CMAKE_VERSION-Darwin64-universal.dmg || exit 1
331 sudo installer -target / -pkg /Volumes/cmake-$CMAKE_VERSION-Darwin64-universal/cmake-$CMAKE_VERSION-Darwin64-universal.pkg || exit 1
332 sudo hdiutil detach /Volumes/cmake-$CMAKE_VERSION-Darwin64-universal
333 ;;
334  
335 3)
336 #
337 # Download the DMG and do a drag install, where "drag" means
338 # "mv".
339 #
340 # 3.0.* and 3.1.0 have a Darwin64-universal DMG.
341 # 3.1.1 and later have a Darwin-x86_64 DMG.
342 # Probably not many people are still developing on 32-bit
343 # Macs, so we don't worry about them.
344 #
345 if [ "$CMAKE_MINOR_VERSION" = 0 -o \
346 "$CMAKE_VERSION" = 3.1.0 ]; then
347 type="Darwin64-universal"
348 else
349 type="Darwin-x86_64"
350 fi
351 [ -f cmake-$CMAKE_VERSION-$type.dmg ] || curl -O https://cmake.org/files/v$CMAKE_MAJOR_MINOR_VERSION/cmake-$CMAKE_VERSION-$type.dmg || exit 1
352 sudo hdiutil attach cmake-$CMAKE_VERSION-$type.dmg || exit 1
353 sudo ditto /Volumes/cmake-$CMAKE_VERSION-$type/CMake.app /Applications/CMake.app || exit 1
354  
355 #
356 # Plant the appropriate symbolic links in /usr/local/bin.
357 # It's a drag-install, so there's no installer to make them,
358 # and the CMake code to put them in place is lame, as
359 #
360 # 1) it defaults to /usr/bin, not /usr/local/bin;
361 # 2) it doesn't request the necessary root privileges;
362 # 3) it can't be run from the command line;
363 #
364 # so we do it ourselves.
365 #
366 for i in ccmake cmake cmake-gui cmakexbuild cpack ctest
367 do
368 sudo ln -s /Applications/CMake.app/Contents/bin/$i /usr/local/bin/$i
369 done
370 sudo hdiutil detach /Volumes/cmake-$CMAKE_VERSION-$type
371 ;;
372  
373 *)
374 ;;
375 esac
376 touch cmake-$CMAKE_VERSION-done
377 fi
378 }
379  
380 uninstall_cmake() {
381 if [ ! -z "$installed_cmake_version" ]; then
382 echo "Uninstalling CMake:"
383 installed_cmake_major_version="`expr $installed_cmake_version : '\([0-9][0-9]*\).*'`"
384 case "$installed_cmake_major_version" in
385  
386 0|1)
387 echo "CMake $installed_cmake_version" is too old 1>&2
388 ;;
389  
390 2)
391 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
392 for i in ccmake cmake cmake-gui cmakexbuild cpack ctest
393 do
394 sudo rm -f /usr/bin/$i /usr/local/bin/$i
395 done
396 sudo pkgutil --forget com.Kitware.CMake
397 rm cmake-$installed_cmake_version-done
398 ;;
399  
400 3)
401 sudo rm -rf /Applications/CMake.app
402 for i in ccmake cmake cmake-gui cmakexbuild cpack ctest
403 do
404 sudo rm -f /usr/local/bin/$i
405 done
406 rm cmake-$installed_cmake_version-done
407 ;;
408 esac
409  
410 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
411 #
412 # Get rid of the previously downloaded and unpacked version,
413 # whatever it might happen to be called.
414 #
415 rm -f cmake-$installed_cmake_version-Darwin64-universal.dmg
416 rm -f cmake-$installed_cmake_version-Darwin-x86_64.dmg
417 fi
418  
419 installed_cmake_version=""
420 fi
421 }
422  
423 install_gettext() {
424 if [ ! -f gettext-$GETTEXT_VERSION-done ] ; then
425 echo "Downloading, building, and installing GNU gettext:"
426 [ -f gettext-$GETTEXT_VERSION.tar.gz ] || curl -O http://ftp.gnu.org/pub/gnu/gettext/gettext-$GETTEXT_VERSION.tar.gz || exit 1
427 gzcat gettext-$GETTEXT_VERSION.tar.gz | tar xf - || exit 1
428 cd gettext-$GETTEXT_VERSION
429 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
430 make $MAKE_BUILD_OPTS || exit 1
431 $DO_MAKE_INSTALL || exit 1
432 cd ..
433 touch gettext-$GETTEXT_VERSION-done
434 fi
435 }
436  
437 uninstall_gettext() {
438 if [ ! -z "$installed_gettext_version" ] ; then
439 #
440 # GLib depends on this, so uninstall it.
441 #
442 uninstall_glib "$@"
443  
444 echo "Uninstalling GNU gettext:"
445 cd gettext-$installed_gettext_version
446 $DO_MAKE_UNINSTALL || exit 1
447 make distclean || exit 1
448 cd ..
449 rm gettext-$installed_gettext_version-done
450  
451 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
452 #
453 # Get rid of the previously downloaded and unpacked version.
454 #
455 rm -rf gettext-$installed_gettext_version
456 rm -rf gettext-$installed_gettext_version.tar.gz
457 fi
458  
459 installed_gettext_version=""
460 fi
461 }
462  
463 install_pkg_config() {
464 if [ ! -f pkg-config-$PKG_CONFIG_VERSION-done ] ; then
465 echo "Downloading, building, and installing pkg-config:"
466 [ -f pkg-config-$PKG_CONFIG_VERSION.tar.gz ] || curl -O https://pkgconfig.freedesktop.org/releases/pkg-config-$PKG_CONFIG_VERSION.tar.gz || exit 1
467 gzcat pkg-config-$PKG_CONFIG_VERSION.tar.gz | tar xf - || exit 1
468 cd pkg-config-$PKG_CONFIG_VERSION
469 ./configure --with-internal-glib || exit 1
470 make $MAKE_BUILD_OPTS || exit 1
471 $DO_MAKE_INSTALL || exit 1
472 cd ..
473 touch pkg-config-$PKG_CONFIG_VERSION-done
474 fi
475 }
476  
477 uninstall_pkg_config() {
478 if [ ! -z "$installed_pkg_config_version" ] ; then
479 echo "Uninstalling pkg-config:"
480 cd pkg-config-$installed_pkg_config_version
481 $DO_MAKE_UNINSTALL || exit 1
482 make distclean || exit 1
483 cd ..
484 rm pkg-config-$installed_pkg_config_version-done
485  
486 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
487 #
488 # Get rid of the previously downloaded and unpacked version.
489 #
490 rm -rf pkg-config-$installed_pkg_config_version
491 rm -rf pkg-config-$installed_pkg_config_version.tar.gz
492 fi
493  
494 installed_pkg_config_version=""
495 fi
496 }
497  
498 install_glib() {
499 if [ ! -f glib-$GLIB_VERSION-done ] ; then
500 echo "Downloading, building, and installing GLib:"
501 glib_dir=`expr $GLIB_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
502 GLIB_MAJOR_VERSION="`expr $GLIB_VERSION : '\([0-9][0-9]*\).*'`"
503 GLIB_MINOR_VERSION="`expr $GLIB_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
504 GLIB_DOTDOT_VERSION="`expr $GLIB_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
505 if [[ $GLIB_MAJOR_VERSION -gt 2 ||
506 $GLIB_MINOR_VERSION -gt 28 ||
507 ($GLIB_MINOR_VERSION -eq 28 && $GLIB_DOTDOT_VERSION -ge 8) ]]
508 then
509 #
510 # Starting with GLib 2.28.8, xz-compressed tarballs are available.
511 #
512 [ -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
513 xzcat glib-$GLIB_VERSION.tar.xz | tar xf - || exit 1
514 else
515 [ -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
516 bzcat glib-$GLIB_VERSION.tar.bz2 | tar xf - || exit 1
517 fi
518 cd glib-$GLIB_VERSION
519 #
520 # OS X ships with libffi, but doesn't provide its pkg-config file;
521 # explicitly specify LIBFFI_CFLAGS and LIBFFI_LIBS, so the configure
522 # script doesn't try to use pkg-config to get the appropriate
523 # C flags and loader flags.
524 #
525 # And, what's worse, at least with the version of Xcode that comes
526 # with Leopard, /usr/include/ffi/fficonfig.h doesn't define MACOSX,
527 # which causes the build of GLib to fail. If we don't find
528 # "#define.*MACOSX" in /usr/include/ffi/fficonfig.h, explicitly
529 # define it.
530 #
531 # While we're at it, suppress -Wformat-nonliteral to avoid a case
532 # where clang's stricter rules on when not to complain about
533 # non-literal format arguments cause it to complain about code
534 # that's safe but it wasn't told that. See my comment #25 in
535 # GNOME bug 691608:
536 #
537 # https://bugzilla.gnome.org/show_bug.cgi?id=691608#c25
538 #
539 # First, determine where the system include files are. (It's not
540 # necessarily /usr/include.) There's a bit of a greasy hack here;
541 # pre-5.x versions of the developer tools don't support the
542 # --show-sdk-path option, and will produce no output, so includedir
543 # will be set to /usr/include (in those older versions of the
544 # developer tools, there is a /usr/include directory).
545 #
546 includedir=`xcrun --show-sdk-path 2>/dev/null`/usr/include
547 if grep -qs '#define.*MACOSX' $includedir/ffi/fficonfig.h
548 then
549 # It's defined, nothing to do
550 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
551 else
552 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
553 fi
554  
555 #
556 # Apply the fix to GNOME bug 529806:
557 #
558 # https://bugzilla.gnome.org/show_bug.cgi?id=529806
559 #
560 # if we have a version of GLib prior to 2.30.
561 #
562 if [[ $GLIB_MAJOR_VERSION -eq 2 && $GLIB_MINOR_VERSION -le 30 ]]
563 then
564 patch -p0 <../../macosx-support-lib-patches/glib-gconvert.c.patch || exit 1
565 fi
566 make $MAKE_BUILD_OPTS || exit 1
567 $DO_MAKE_INSTALL || exit 1
568 cd ..
569 touch glib-$GLIB_VERSION-done
570 fi
571 }
572  
573 uninstall_glib() {
574 if [ ! -z "$installed_glib_version" ] ; then
575 #
576 # ATK, Pango, and GTK depend on this, so uninstall them.
577 #
578 uninstall_gtk
579 uninstall_pango
580 uninstall_atk
581  
582 echo "Uninstalling GLib:"
583 cd glib-$installed_glib_version
584 $DO_MAKE_UNINSTALL || exit 1
585 make distclean || exit 1
586 cd ..
587 rm glib-$installed_glib_version-done
588  
589 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
590 #
591 # Get rid of the previously downloaded and unpacked version.
592 #
593 rm -rf glib-$installed_glib_version
594 rm -rf glib-$installed_glib_version.tar.xz glib-$installed_glib_version.tar.bz2
595 fi
596  
597 installed_glib_version=""
598 fi
599 }
600  
601 install_qt() {
602 if [ "$QT_VERSION" -a ! -f qt-$QT_VERSION-done ]; then
603 echo "Downloading, building, and installing Qt:"
604 #
605 # What you get for this URL might just be a 302 Found reply, so use
606 # -L so we get redirected.
607 #
608 if [ "$QT_MAJOR_VERSION" -ge 5 ]
609 then
610 QT_VOLUME=qt-opensource-mac-x64-clang-$QT_VERSION
611 else
612 QT_VOLUME=qt-opensource-mac-$QT_VERSION
613 fi
614 [ -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
615 sudo hdiutil attach $QT_VOLUME.dmg || exit 1
616  
617 if [ "$QT_MAJOR_VERSION" -ge 5 ]
618 then
619 #
620 # Run the installer executable directly, so that we wait for
621 # it to finish. Then unmount the volume.
622 #
623 /Volumes/$QT_VOLUME/$QT_VOLUME.app/Contents/MacOS/$QT_VOLUME
624 sudo hdiutil detach /Volumes/$QT_VOLUME
625 else
626 #
627 # Open the installer package; use -W, so that we wait for
628 # the installer to finish. Then unmount the volume.
629 #
630 open -W "/Volumes/Qt $QT_MAJOR_MINOR_DOTDOT_VERSION/Qt.mpkg"
631 sudo hdiutil detach "/Volumes/Qt $QT_MAJOR_MINOR_DOTDOT_VERSION"
632 fi
633  
634 #
635 # Versions 5.3.x through 5.5.0, at least, have bogus .pc files.
636 # See bugs QTBUG-35256 and QTBUG-47162.
637 #
638 # Fix the files.
639 #
640 for i in $HOME/Qt$QT_VERSION/$QT_MAJOR_MINOR_VERSION/clang_64/lib/pkgconfig/*.pc
641 do
642 ed - $i <<EOF
643 H
644 g/Cflags: /s;;Cflags: -F\${libdir} ;
645 g/Cflags: /s;-I\${includedir}/Qt\([a-zA-Z0-9_]*\);-I\${libdir}/Qt\1.framework/Versions/5/Headers;
646 g/Libs: /s;';;g
647 w
648 q
649 EOF
650 done
651 touch qt-$QT_VERSION-done
652 fi
653 }
654  
655 uninstall_qt() {
656 if [ ! -z "$installed_qt_version" ] ; then
657 echo "Uninstalling Qt:"
658 rm -rf $HOME/Qt$installed_qt_version
659 rm qt-$installed_qt_version-done
660  
661 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
662 #
663 # Get rid of the previously downloaded version.
664 #
665 rm -rf qt-opensource-mac-x64-clang-$installed_qt_version.dmg
666 fi
667  
668 installed_qt_version=""
669 fi
670 }
671  
672 install_libpng() {
673 if [ ! -f libpng-$PNG_VERSION-done ] ; then
674 echo "Downloading, building, and installing libpng:"
675 #
676 # The FTP site puts libpng x.y.* into a libpngxy directory.
677 #
678 subdir=`echo $PNG_VERSION | sed 's/\([1-9][0-9]*\)\.\([1-9][0-9]*\).*/libpng\1\2'/`
679 [ -f libpng-$PNG_VERSION.tar.xz ] || curl -O ftp://ftp.simplesystems.org/pub/libpng/png/src/$subdir/libpng-$PNG_VERSION.tar.xz
680 xzcat libpng-$PNG_VERSION.tar.xz | tar xf - || exit 1
681 cd libpng-$PNG_VERSION
682 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
683 make $MAKE_BUILD_OPTS || exit 1
684 $DO_MAKE_INSTALL || exit 1
685 cd ..
686 touch libpng-$PNG_VERSION-done
687 fi
688 }
689  
690 uninstall_libpng() {
691 if [ ! -z "$installed_libpng_version" ] ; then
692 #
693 # Cairo depends on this, so uninstall it.
694 #
695 uninstall_cairo "$@"
696  
697 echo "Uninstalling libpng:"
698 cd libpng-$installed_libpng_version
699 $DO_MAKE_UNINSTALL || exit 1
700 make distclean || exit 1
701 cd ..
702 rm libpng-$installed_libpng_version-done
703  
704 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
705 #
706 # Get rid of the previously downloaded and unpacked version.
707 #
708 rm -rf libpng-$installed_libpng_version
709 rm -rf libpng-$installed_libpng_version.tar.xz
710 fi
711  
712 installed_libpng_version=""
713 fi
714 }
715  
716 install_pixman() {
717 if [ ! -f pixman-$PIXMAN_VERSION-done ] ; then
718 echo "Downloading, building, and installing pixman:"
719 [ -f pixman-$PIXMAN_VERSION.tar.gz ] || curl -O http://www.cairographics.org/releases/pixman-$PIXMAN_VERSION.tar.gz
720 gzcat pixman-$PIXMAN_VERSION.tar.gz | tar xf - || exit 1
721 cd pixman-$PIXMAN_VERSION
722 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
723 make $MAKE_BUILD_OPTS || exit 1
724 $DO_MAKE_INSTALL || exit 1
725 cd ..
726 touch pixman-$PIXMAN_VERSION-done
727 fi
728 }
729  
730 uninstall_pixman() {
731 if [ ! -z "$installed_pixman_version" ] ; then
732 #
733 # Cairo depends on this, so uninstall it.
734 #
735 uninstall_cairo "$@"
736  
737 echo "Uninstalling pixman:"
738 cd pixman-$installed_pixman_version
739 $DO_MAKE_UNINSTALL || exit 1
740 make distclean || exit 1
741 cd ..
742 rm pixman-$installed_pixman_version-done
743  
744 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
745 #
746 # Get rid of the previously downloaded and unpacked version.
747 #
748 rm -rf pixman-$installed_pixman_version
749 rm -rf pixman-$installed_pixman_version.tar.gz
750 fi
751  
752 installed_pixman_version=""
753 fi
754 }
755  
756 install_cairo() {
757 if [ ! -f cairo-$CAIRO_VERSION-done ] ; then
758 echo "Downloading, building, and installing Cairo:"
759 CAIRO_MAJOR_VERSION="`expr $CAIRO_VERSION : '\([0-9][0-9]*\).*'`"
760 CAIRO_MINOR_VERSION="`expr $CAIRO_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
761 CAIRO_DOTDOT_VERSION="`expr $CAIRO_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
762 if [[ $CAIRO_MAJOR_VERSION -gt 1 ||
763 $CAIRO_MINOR_VERSION -gt 12 ||
764 ($CAIRO_MINOR_VERSION -eq 12 && $CAIRO_DOTDOT_VERSION -ge 2) ]]
765 then
766 #
767 # Starting with Cairo 1.12.2, the tarballs are compressed with
768 # xz rather than gzip.
769 #
770 [ -f cairo-$CAIRO_VERSION.tar.xz ] || curl -O http://cairographics.org/releases/cairo-$CAIRO_VERSION.tar.xz || exit 1
771 xzcat cairo-$CAIRO_VERSION.tar.xz | tar xf - || exit 1
772 else
773 [ -f cairo-$CAIRO_VERSION.tar.gz ] || curl -O http://cairographics.org/releases/cairo-$CAIRO_VERSION.tar.gz || exit 1
774 gzcat cairo-$CAIRO_VERSION.tar.gz | tar xf - || exit 1
775 fi
776 cd cairo-$CAIRO_VERSION
777 # CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --enable-quartz=no || exit 1
778 # Maybe follow http://cairographics.org/end_to_end_build_for_mac_os_x/
779 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --enable-quartz=yes || exit 1
780 #
781 # We must avoid the version of libpng that comes with X11; the
782 # only way I've found to force that is to forcibly set INCLUDES
783 # when we do the build, so that this comes before CAIRO_CFLAGS,
784 # which has -I/usr/X11/include added to it before anything
785 # connected to libpng is.
786 #
787 INCLUDES="-I/usr/local/include/libpng15" make $MAKE_BUILD_OPTS || exit 1
788 $DO_MAKE_INSTALL || exit 1
789 cd ..
790 touch cairo-$CAIRO_VERSION-done
791 fi
792 }
793  
794 uninstall_cairo() {
795 if [ ! -z "$installed_cairo_version" ] ; then
796 #
797 # GTK+ depends on this, so uninstall it.
798 #
799 uninstall_gtk "$@"
800  
801 echo "Uninstalling Cairo:"
802 cd cairo-$installed_cairo_version
803 $DO_MAKE_UNINSTALL || exit 1
804 make distclean || exit 1
805 cd ..
806 rm cairo-$installed_cairo_version-done
807  
808 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
809 #
810 # Get rid of the previously downloaded and unpacked version.
811 #
812 rm -rf cairo-$installed_cairo_version
813 rm -rf cairo-$installed_cairo_version.tar.xz cairo-$installed_cairo_version.tar.gz
814 fi
815  
816 installed_cairo_version=""
817 fi
818 }
819  
820 install_atk() {
821 if [ ! -f atk-$ATK_VERSION-done ] ; then
822 echo "Downloading, building, and installing ATK:"
823 atk_dir=`expr $ATK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
824 ATK_MAJOR_VERSION="`expr $ATK_VERSION : '\([0-9][0-9]*\).*'`"
825 ATK_MINOR_VERSION="`expr $ATK_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
826 ATK_DOTDOT_VERSION="`expr $ATK_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
827 if [[ $ATK_MAJOR_VERSION -gt 2 ||
828 ($ATK_MAJOR_VERSION -eq 2 && $ATK_MINOR_VERSION -gt 0) ||
829 ($ATK_MANOR_VERSION -eq 2 && $ATK_MINOR_VERSION -eq 0 && $ATK_DOTDOT_VERSION -ge 1) ]]
830 then
831 #
832 # Starting with ATK 2.0.1, xz-compressed tarballs are available.
833 #
834 [ -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
835 xzcat atk-$ATK_VERSION.tar.xz | tar xf - || exit 1
836 else
837 [ -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
838 bzcat atk-$ATK_VERSION.tar.bz2 | tar xf - || exit 1
839 fi
840 cd atk-$ATK_VERSION
841 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
842 make $MAKE_BUILD_OPTS || exit 1
843 $DO_MAKE_INSTALL || exit 1
844 cd ..
845 touch atk-$ATK_VERSION-done
846 fi
847 }
848  
849 uninstall_atk() {
850 if [ ! -z "$installed_atk_version" ] ; then
851 #
852 # GTK+ depends on this, so uninstall it.
853 #
854 uninstall_gtk "$@"
855  
856 echo "Uninstalling ATK:"
857 cd atk-$installed_atk_version
858 $DO_MAKE_UNINSTALL || exit 1
859 make distclean || exit 1
860 cd ..
861 rm atk-$installed_atk_version-done
862  
863 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
864 #
865 # Get rid of the previously downloaded and unpacked version.
866 #
867 rm -rf atk-$installed_atk_version
868 rm -rf atk-$installed_atk_version.tar.xz atk-$installed_atk_version.tar.bz2
869 fi
870  
871 installed_atk_version=""
872 fi
873 }
874  
875 install_pango() {
876 if [ ! -f pango-$PANGO_VERSION-done ] ; then
877 echo "Downloading, building, and installing Pango:"
878 pango_dir=`expr $PANGO_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
879 PANGO_MAJOR_VERSION="`expr $PANGO_VERSION : '\([0-9][0-9]*\).*'`"
880 PANGO_MINOR_VERSION="`expr $PANGO_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
881 if [[ $PANGO_MAJOR_VERSION -gt 1 ||
882 $PANGO_MINOR_VERSION -ge 29 ]]
883 then
884 #
885 # Starting with Pango 1.29, the tarballs are compressed with
886 # xz rather than bzip2.
887 #
888 [ -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
889 xzcat pango-$PANGO_VERSION.tar.xz | tar xf - || exit 1
890 else
891 [ -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
892 bzcat pango-$PANGO_VERSION.tar.bz2 | tar xf - || exit 1
893 fi
894 cd pango-$PANGO_VERSION
895 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
896 make $MAKE_BUILD_OPTS || exit 1
897 $DO_MAKE_INSTALL || exit 1
898 cd ..
899 touch pango-$PANGO_VERSION-done
900 fi
901 }
902  
903 uninstall_pango() {
904 if [ ! -z "$installed_pango_version" ] ; then
905 #
906 # GTK+ depends on this, so uninstall it.
907 #
908 uninstall_gtk "$@"
909  
910 echo "Uninstalling Pango:"
911 cd pango-$installed_pango_version
912 $DO_MAKE_UNINSTALL || exit 1
913 make distclean || exit 1
914 cd ..
915 rm pango-$installed_pango_version-done
916  
917 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
918 #
919 # Get rid of the previously downloaded and unpacked version.
920 #
921 rm -rf pango-$installed_pango_version
922 rm -rf pango-$installed_pango_version.tar.xz pango-$installed_pango_version.tar.bz2
923 fi
924  
925 installed_pango_version=""
926 fi
927 }
928  
929 install_gdk_pixbuf() {
930 if [ "$GDK_PIXBUF_VERSION" -a ! -f gdk-pixbuf-$GDK_PIXBUF_VERSION-done ] ; then
931 echo "Downloading, building, and installing gdk-pixbuf:"
932 gdk_pixbuf_dir=`expr $GDK_PIXBUF_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
933 [ -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
934 xzcat gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.xz | tar xf - || exit 1
935 cd gdk-pixbuf-$GDK_PIXBUF_VERSION
936 #
937 # If we're building using the 10.6 SDK, force the use of libpng12.
938 #
939 # The OS's X11, and corresponding SDK, didn't introduce libpng15,
940 # or pkg-config files, until 10.7, so, for 10.6 have to explicitly
941 # set LIBPNG to override the configure script, and also force the
942 # CFLAGS to look for the header files for libpng12 (note that
943 # -isysroot doesn't affect the arguments to -I, so we need to
944 # include the SDK path explicitly).
945 #
946 if [[ "$sdk_target" = 10.6 ]]
947 then
948 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
949 else
950 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
951 fi
952 make $MAKE_BUILD_OPTS || exit 1
953 $DO_MAKE_INSTALL || exit 1
954 cd ..
955 touch gdk-pixbuf-$GDK_PIXBUF_VERSION-done
956 fi
957 }
958  
959 uninstall_gdk_pixbuf() {
960 if [ ! -z "$installed_gdk_pixbuf_version" ] ; then
961 #
962 # GTK+ depends on this, so uninstall it.
963 #
964 uninstall_gtk "$@"
965  
966 echo "Uninstalling gdk-pixbuf:"
967 cd gdk-pixbuf-$installed_gdk_pixbuf_version
968 $DO_MAKE_UNINSTALL || exit 1
969 make distclean || exit 1
970 cd ..
971 rm gdk-pixbuf-$installed_gdk_pixbuf_version-done
972  
973 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
974 #
975 # Get rid of the previously downloaded and unpacked version.
976 #
977 rm -rf gdk-pixbuf-$installed_gdk_pixbuf_version
978 rm -rf gdk-pixbuf-$installed_gdk_pixbuf_version.tar.xz
979 fi
980  
981 installed_gdk_pixbuf_version=""
982 fi
983 }
984  
985 install_gtk() {
986 if [ ! -f gtk+-$GTK_VERSION-done ] ; then
987 echo "Downloading, building, and installing GTK+:"
988 gtk_dir=`expr $GTK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
989 if [[ $GTK_MAJOR_VERSION -gt 2 ||
990 $GTK_MINOR_VERSION -gt 24 ||
991 ($GTK_MINOR_VERSION -eq 24 && $GTK_DOTDOT_VERSION -ge 5) ]]
992 then
993 #
994 # Starting with GTK+ 2.24.5, the tarballs are compressed with
995 # xz rather than gzip, in addition to bzip2; use xz, as we've
996 # built and installed it, and as xz compresses better than
997 # bzip2 so the tarballs take less time to download.
998 #
999 [ -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
1000 xzcat gtk+-$GTK_VERSION.tar.xz | tar xf - || exit 1
1001 else
1002 [ -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
1003 bzcat gtk+-$GTK_VERSION.tar.bz2 | tar xf - || exit 1
1004 fi
1005 cd gtk+-$GTK_VERSION
1006 if [ $DARWIN_MAJOR_VERSION -ge "12" ]
1007 then
1008 #
1009 # GTK+ 2.24.10, at least, doesn't build on Mountain Lion with the
1010 # CUPS printing backend - either the CUPS API changed incompatibly
1011 # or the backend was depending on non-API implementation details.
1012 #
1013 # Configure it out, on Mountain Lion and later, for now.
1014 # (12 is the Darwin major version number in Mountain Lion.)
1015 #
1016 # Also, configure out libtiff and libjpeg; configure scripts
1017 # just ignore unknown --enable/--disable and --with/--without
1018 # options (at least they've always do so up to now).
1019 #
1020 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
1021 else
1022 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
1023 fi
1024 make $MAKE_BUILD_OPTS || exit 1
1025 $DO_MAKE_INSTALL || exit 1
1026 cd ..
1027 touch gtk+-$GTK_VERSION-done
1028 fi
1029 }
1030  
1031 uninstall_gtk() {
1032 if [ ! -z "$installed_gtk_version" ] ; then
1033 echo "Uninstalling GTK+:"
1034 cd gtk+-$installed_gtk_version
1035 $DO_MAKE_UNINSTALL || exit 1
1036 make distclean || exit 1
1037 cd ..
1038 rm gtk+-$installed_gtk_version-done
1039  
1040 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1041 #
1042 # Get rid of the previously downloaded and unpacked version.
1043 #
1044 rm -rf gtk+-$installed_gtk_version
1045 rm -rf gtk+-$installed_gtk_version.tar.xz gtk+-$installed_gtk_version.tar.bz2
1046 fi
1047  
1048 installed_gtk_version=""
1049 fi
1050 }
1051  
1052 install_libsmi() {
1053 if [ "$LIBSMI_VERSION" -a ! -f libsmi-$LIBSMI_VERSION-done ] ; then
1054 echo "Downloading, building, and installing libsmi:"
1055 [ -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
1056 gzcat libsmi-$LIBSMI_VERSION.tar.gz | tar xf - || exit 1
1057 cd libsmi-$LIBSMI_VERSION
1058 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
1059 make $MAKE_BUILD_OPTS || exit 1
1060 $DO_MAKE_INSTALL || exit 1
1061 cd ..
1062 touch libsmi-$LIBSMI_VERSION-done
1063 fi
1064 }
1065  
1066 uninstall_libsmi() {
1067 if [ ! -z "$installed_libsmi_version" ] ; then
1068 echo "Uninstalling libsmi:"
1069 cd libsmi-$installed_libsmi_version
1070 $DO_MAKE_UNINSTALL || exit 1
1071 make distclean || exit 1
1072 cd ..
1073 rm libsmi-$installed_libsmi_version-done
1074  
1075 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1076 #
1077 # Get rid of the previously downloaded and unpacked version.
1078 #
1079 rm -rf libsmi-$installed_libsmi_version
1080 rm -rf libsmi-$installed_libsmi_version.tar.gz
1081 fi
1082  
1083 installed_libsmi_version=""
1084 fi
1085 }
1086  
1087 install_libgpg_error() {
1088 if [ "$LIBGPG_ERROR_VERSION" -a ! -f libgpg-error-$LIBGPG_ERROR_VERSION-done ] ; then
1089 echo "Downloading, building, and installing libgpg-error:"
1090 [ -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
1091 bzcat libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 | tar xf - || exit 1
1092 cd libgpg-error-$LIBGPG_ERROR_VERSION
1093 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
1094 make $MAKE_BUILD_OPTS || exit 1
1095 $DO_MAKE_INSTALL || exit 1
1096 cd ..
1097 touch libgpg-error-$LIBGPG_ERROR_VERSION-done
1098 fi
1099 }
1100  
1101 uninstall_libgpg_error() {
1102 if [ ! -z "$installed_libgpg_error_version" ] ; then
1103 #
1104 # libgcrypt depends on this, so uninstall it.
1105 #
1106 uninstall_libgcrypt "$@"
1107  
1108 echo "Uninstalling libgpg-error:"
1109 cd libgpg-error-$installed_libgpg_error_version
1110 $DO_MAKE_UNINSTALL || exit 1
1111 make distclean || exit 1
1112 cd ..
1113 rm libgpg-error-$installed_libgpg_error_version-done
1114  
1115 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1116 #
1117 # Get rid of the previously downloaded and unpacked version.
1118 #
1119 rm -rf libgpg-error-$installed_libgpg_error_version
1120 rm -rf libgpg-error-$installed_libgpg_error_version.tar.bz2
1121 fi
1122  
1123 installed_libgpg_error_version=""
1124 fi
1125 }
1126  
1127 install_libgcrypt() {
1128 if [ "$LIBGCRYPT_VERSION" -a ! -f libgcrypt-$LIBGCRYPT_VERSION-done ] ; then
1129 #
1130 # libgpg-error is required for libgcrypt.
1131 #
1132 if [ -z $LIBGPG_ERROR_VERSION ]
1133 then
1134 echo "libgcrypt requires libgpg-error, but you didn't install libgpg-error." 1>&2
1135 exit 1
1136 fi
1137  
1138 echo "Downloading, building, and installing libgcrypt:"
1139 [ -f libgcrypt-$LIBGCRYPT_VERSION.tar.gz ] || curl -L -O ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-$LIBGCRYPT_VERSION.tar.gz || exit 1
1140 gzcat libgcrypt-$LIBGCRYPT_VERSION.tar.gz | tar xf - || exit 1
1141 cd libgcrypt-$LIBGCRYPT_VERSION
1142 #
1143 # The assembler language code is not compatible with the OS X
1144 # x86 assembler (or is it an x86-64 vs. x86-32 issue?).
1145 #
1146 # libgcrypt expects gnu89, not c99/gnu99, semantics for
1147 # "inline". See, for example:
1148 #
1149 # http://lists.freebsd.org/pipermail/freebsd-ports-bugs/2010-October/198809.html
1150 #
1151 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
1152 make $MAKE_BUILD_OPTS || exit 1
1153 $DO_MAKE_INSTALL || exit 1
1154 cd ..
1155 touch libgcrypt-$LIBGCRYPT_VERSION-done
1156 fi
1157 }
1158  
1159 uninstall_libgcrypt() {
1160 if [ ! -z "$installed_libgcrypt_version" ] ; then
1161 #
1162 # GnuTLS depends on this, so uninstall it.
1163 #
1164 uninstall_gnutls "$@"
1165  
1166 echo "Uninstalling libgcrypt:"
1167 cd libgcrypt-$installed_libgcrypt_version
1168 $DO_MAKE_UNINSTALL || exit 1
1169 make distclean || exit 1
1170 cd ..
1171 rm libgcrypt-$installed_libgcrypt_version-done
1172  
1173 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1174 #
1175 # Get rid of the previously downloaded and unpacked version.
1176 #
1177 rm -rf libgcrypt-$installed_libgcrypt_version
1178 rm -rf libgcrypt-$installed_libgcrypt_version.tar.gz
1179 fi
1180  
1181 installed_libgcrypt_version=""
1182 fi
1183 }
1184  
1185 install_gnutls() {
1186 if [ "$GNUTLS_VERSION" -a ! -f gnutls-$GNUTLS_VERSION-done ] ; then
1187 #
1188 # GnuTLS requires libgcrypt (or nettle, in newer versions).
1189 #
1190 if [ -z $LIBGCRYPT_VERSION ]
1191 then
1192 echo "GnuTLS requires libgcrypt, but you didn't install libgcrypt" 1>&2
1193 exit 1
1194 fi
1195  
1196 echo "Downloading, building, and installing GnuTLS:"
1197 [ -f gnutls-$GNUTLS_VERSION.tar.bz2 ] || curl -L -O http://ftp.gnu.org/gnu/gnutls/gnutls-$GNUTLS_VERSION.tar.bz2 || exit 1
1198 bzcat gnutls-$GNUTLS_VERSION.tar.bz2 | tar xf - || exit 1
1199 cd gnutls-$GNUTLS_VERSION
1200 #
1201 # Use libgcrypt, not nettle.
1202 # XXX - is there some reason to prefer nettle? Or does
1203 # Wireshark directly use libgcrypt routines?
1204 #
1205 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
1206 make $MAKE_BUILD_OPTS || exit 1
1207 #
1208 # The pkgconfig file for GnuTLS says "requires zlib", but OS X,
1209 # while it supplies zlib, doesn't supply a pkgconfig file for
1210 # it.
1211 #
1212 # Patch the GnuTLS pkgconfig file not to require zlib.
1213 # (If the capabilities of GnuTLS that Wireshark uses don't
1214 # depend on building GnuTLS with zlib, an alternative would be
1215 # to configure it not to use zlib.)
1216 #
1217 patch -p0 lib/gnutls.pc.in <../../macosx-support-lib-patches/gnutls-pkgconfig.patch || exit 1
1218 $DO_MAKE_INSTALL || exit 1
1219 cd ..
1220 touch gnutls-$GNUTLS_VERSION-done
1221 fi
1222 }
1223  
1224 uninstall_gnutls() {
1225 if [ ! -z "$installed_gnutls_version" ] ; then
1226 echo "Uninstalling GnuTLS:"
1227 cd gnutls-$installed_gnutls_version
1228 $DO_MAKE_UNINSTALL || exit 1
1229 make distclean || exit 1
1230 cd ..
1231 rm gnutls-$installed_gnutls_version-done
1232  
1233 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1234 #
1235 # Get rid of the previously downloaded and unpacked version.
1236 #
1237 rm -rf gnutls-$installed_gnutls_version
1238 rm -rf gnutls-$installed_gnutls_version.tar.bz2
1239 fi
1240  
1241 installed_gnutls_version=""
1242 fi
1243 }
1244  
1245 install_lua() {
1246 if [ "$LUA_VERSION" -a ! -f lua-$LUA_VERSION-done ] ; then
1247 echo "Downloading, building, and installing Lua:"
1248 [ -f lua-$LUA_VERSION.tar.gz ] || curl -L -O http://www.lua.org/ftp/lua-$LUA_VERSION.tar.gz || exit 1
1249 gzcat lua-$LUA_VERSION.tar.gz | tar xf - || exit 1
1250 cd lua-$LUA_VERSION
1251 make MYCFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" MYLDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" $MAKE_BUILD_OPTS macosx || exit 1
1252 $DO_MAKE_INSTALL || exit 1
1253 cd ..
1254 touch lua-$LUA_VERSION-done
1255 fi
1256 }
1257  
1258 uninstall_lua() {
1259 if [ ! -z "$installed_lua_version" ] ; then
1260 echo "Uninstalling Lua:"
1261 #
1262 # Lua has no "make uninstall", so just remove stuff manually.
1263 # There's no configure script, so there's no need for
1264 # "make distclean", either; just do "make clean".
1265 #
1266 (cd /usr/local/bin; $DO_RM -f lua luac)
1267 (cd /usr/local/include; $DO_RM -f lua.h luaconf.h lualib.h lauxlib.h lua.hpp)
1268 (cd /usr/local/lib; $DO_RM -f liblua.a)
1269 (cd /usr/local/man/man1; $DO_RM -f lua.1 luac.1)
1270 cd lua-$installed_lua_version
1271 make clean || exit 1
1272 cd ..
1273 rm lua-$installed_lua_version-done
1274  
1275 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1276 #
1277 # Get rid of the previously downloaded and unpacked version.
1278 #
1279 rm -rf lua-$installed_lua_version
1280 rm -rf lua-$installed_lua_version.tar.gz
1281 fi
1282  
1283 installed_lua_version=""
1284 fi
1285 }
1286  
1287 install_portaudio() {
1288 #
1289 # Check for both the old versionless portaudio-done and the new
1290 # versioned -done file.
1291 #
1292 if [ "$PORTAUDIO_VERSION" -a ! -f portaudio-$PORTAUDIO_VERSION-done ] ; then
1293 echo "Downloading, building, and installing PortAudio:"
1294 [ -f $PORTAUDIO_VERSION.tgz ] || curl -L -O http://www.portaudio.com/archives/$PORTAUDIO_VERSION.tgz || exit 1
1295 gzcat $PORTAUDIO_VERSION.tgz | tar xf - || exit 1
1296 cd portaudio
1297 #
1298 # Un-comment an include that's required on Lion.
1299 #
1300 patch -p0 include/pa_mac_core.h <../../macosx-support-lib-patches/portaudio-pa_mac_core.h.patch
1301 #
1302 # Fix a bug that showed up with clang (but is a bug with any
1303 # compiler).
1304 #
1305 patch -p0 src/hostapi/coreaudio/pa_mac_core.c <../../macosx-support-lib-patches/portaudio-pa_mac_core.c.patch
1306 #
1307 # Disable fat builds - the configure script doesn't work right
1308 # with Xcode 4 if you leave them enabled, and we don't build
1309 # any other libraries fat (GLib, for example, would be very
1310 # hard to build fat), so there's no advantage to having PortAudio
1311 # built fat.
1312 #
1313 # Set the minimum OS X version to 10.4, to suppress some
1314 # deprecation warnings. (Good luck trying to make any of
1315 # this build on an OS+Xcode with a pre-10.4 SDK; we don't
1316 # worry about the user requesting that.)
1317 #
1318 # Explicitly disable deprecation, so the damn thing will build
1319 # on El Capitan with Xcode 7.
1320 #
1321 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
1322 make $MAKE_BUILD_OPTS || exit 1
1323 $DO_MAKE_INSTALL || exit 1
1324 cd ..
1325 touch portaudio-$PORTAUDIO_VERSION-done
1326 fi
1327 }
1328  
1329 uninstall_portaudio() {
1330 if [ ! -z "$installed_portaudio_version" ] ; then
1331 echo "Uninstalling PortAudio:"
1332 cd portaudio
1333 $DO_MAKE_UNINSTALL || exit 1
1334 make distclean || exit 1
1335 cd ..
1336 rm portaudio-$installed_portaudio_version-done
1337  
1338 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1339 #
1340 # Get rid of the previously downloaded and unpacked version.
1341 #
1342 rm -rf portaudio
1343 rm -rf $installed_portaudio_version.tgz
1344 fi
1345  
1346 installed_portaudio_version=""
1347 fi
1348 }
1349  
1350 install_geoip() {
1351 if [ "$GEOIP_VERSION" -a ! -f geoip-$GEOIP_VERSION-done ] ; then
1352 echo "Downloading, building, and installing GeoIP API:"
1353 [ -f GeoIP-$GEOIP_VERSION.tar.gz ] || curl -L -O http://geolite.maxmind.com/download/geoip/api/c/GeoIP-$GEOIP_VERSION.tar.gz || exit 1
1354 gzcat GeoIP-$GEOIP_VERSION.tar.gz | tar xf - || exit 1
1355 cd GeoIP-$GEOIP_VERSION
1356 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
1357 #
1358 # Grr. Their man pages "helpfully" have an ISO 8859-1
1359 # copyright symbol in the copyright notice, but OS X's
1360 # default character encoding is UTF-8. sed on Mountain
1361 # Lion barfs at the "illegal character sequence" represented
1362 # by an ISO 8859-1 copyright symbol, as it's not a valid
1363 # UTF-8 sequence.
1364 #
1365 # iconv the relevant man pages into UTF-8.
1366 #
1367 for i in geoipupdate.1.in geoiplookup6.1.in geoiplookup.1.in
1368 do
1369 iconv -f iso8859-1 -t utf-8 man/"$i" >man/"$i".tmp &&
1370 mv man/"$i".tmp man/"$i"
1371 done
1372 make $MAKE_BUILD_OPTS || exit 1
1373 $DO_MAKE_INSTALL || exit 1
1374 cd ..
1375 touch geoip-$GEOIP_VERSION-done
1376 fi
1377 }
1378  
1379 uninstall_geoip() {
1380 if [ ! -z "$installed_geoip_version" ] ; then
1381 echo "Uninstalling GeoIP API:"
1382 cd GeoIP-$installed_geoip_version
1383 $DO_MAKE_UNINSTALL || exit 1
1384 make distclean || exit 1
1385 cd ..
1386 rm geoip-$installed_geoip_version-done
1387  
1388 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1389 #
1390 # Get rid of the previously downloaded and unpacked version.
1391 #
1392 rm -rf GeoIP-$installed_geoip_version
1393 rm -rf GeoIP-$installed_geoip_version.tar.gz
1394 fi
1395  
1396 installed_geoip_version=""
1397 fi
1398 }
1399  
1400 install_c_ares() {
1401 if [ "$CARES_VERSION" -a ! -f c-ares-$CARES_VERSION-done ] ; then
1402 echo "Downloading, building, and installing C-Ares API:"
1403 [ -f c-ares-$CARES_VERSION.tar.gz ] || curl -L -O http://c-ares.haxx.se/download/c-ares-$CARES_VERSION.tar.gz || exit 1
1404 gzcat c-ares-$CARES_VERSION.tar.gz | tar xf - || exit 1
1405 cd c-ares-$CARES_VERSION
1406 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
1407 make $MAKE_BUILD_OPTS || exit 1
1408 $DO_MAKE_INSTALL || exit 1
1409 cd ..
1410 touch c-ares-$CARES_VERSION-done
1411 fi
1412 }
1413  
1414 uninstall_c_ares() {
1415 if [ ! -z "$installed_cares_version" ] ; then
1416 echo "Uninstalling C-Ares API:"
1417 cd c-ares-$installed_cares_version
1418 $DO_MAKE_UNINSTALL || exit 1
1419 make distclean || exit 1
1420 cd ..
1421 rm c-ares-$installed_cares_version-done
1422  
1423 if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
1424 #
1425 # Get rid of the previously downloaded and unpacked version.
1426 #
1427 rm -rf c-ares-$installed_cares_version
1428 rm -rf c-ares-$installed_cares_version.tar.gz
1429 fi
1430  
1431 installed_cares_version=""
1432 fi
1433 }
1434  
1435 install_libssh() {
1436 if [ "$LIBSSH_VERSION" -a ! -f libssh-$LIBSSH_VERSION-done ] ; then
1437 echo "Downloading, building, and installing libssh:"
1438 [ -f libssh-$LIBSSH_VERSION.tar.xz ] || curl -L -O https://red.libssh.org/attachments/download/195/libssh-$LIBSSH_VERSION.tar.xz || exit 1
1439 xzcat libssh-$LIBSSH_VERSION.tar.xz | tar xf - || exit 1
1440 cd libssh-$LIBSSH_VERSION
1441 mkdir build
1442 cd build
1443 CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" cmake -DWITH_GCRYPT=1 ../ || exit 1
1444 make $MAKE_BUILD_OPTS || exit 1
1445 $DO_MAKE_INSTALL || exit 1
1446 cd ../..
1447 touch libssh-$LIBSSH_VERSION-done
1448 fi
1449 }
1450  
1451 uninstall_libssh() {
1452 if [ ! -z "$installed_libssh_version" ] ; then
1453 echo "Sadly, libssh uses cmake, and doesn't support uninstall."
1454 fi
1455 }
1456  
1457 install_all() {
1458 #
1459 # Check whether the versions we have installed are the versions
1460 # requested; if not, uninstall the installed versions.
1461 #
1462 if [ ! -z "$installed_libssh_version" -a \
1463 "$installed_libssh_version" != "$LIBSSH_VERSION" ] ; then
1464 echo "Installed libssh version is $installed_libssh_version"
1465 if [ -z "$LIBSSH_VERSION" ] ; then
1466 echo "libssh is not requested"
1467 else
1468 echo "Requested libssh version is $LIBSSH_VERSION"
1469 fi
1470 uninstall_libssh -r
1471 fi
1472  
1473 if [ ! -z "$installed_cares_version" -a \
1474 "$installed_cares_version" != "$CARES_VERSION" ] ; then
1475 echo "Installed C-Ares version is $installed_cares_version"
1476 if [ -z "$CARES_VERSION" ] ; then
1477 echo "C-Ares is not requested"
1478 else
1479 echo "Requested C-Ares version is $CARES_VERSION"
1480 fi
1481 uninstall_c_ares -r
1482 fi
1483  
1484 if [ ! -z "$installed_geoip_version" -a \
1485 "$installed_geoip_version" != "$GEOIP_VERSION" ] ; then
1486 echo "Installed GeoIP API version is $installed_geoip_version"
1487 if [ -z "$GEOIP_VERSION" ] ; then
1488 echo "GeoIP is not requested"
1489 else
1490 echo "Requested GeoIP version is $GEOIP_VERSION"
1491 fi
1492 uninstall_geoip -r
1493 fi
1494  
1495 if [ ! -z "$installed_portaudio_version" -a \
1496 "$installed_portaudio_version" != "$PORTAUDIO_VERSION" ] ; then
1497 echo "Installed PortAudio version is $installed_portaudio_version"
1498 if [ -z "$PORTAUDIO_VERSION" ] ; then
1499 echo "PortAudio is not requested"
1500 else
1501 echo "Requested PortAudio version is $PORTAUDIO_VERSION"
1502 fi
1503 uninstall_portaudio -r
1504 fi
1505  
1506 if [ ! -z "$installed_lua_version" -a \
1507 "$installed_lua_version" != "$LUA_VERSION" ] ; then
1508 echo "Installed Lua version is $installed_lua_version"
1509 if [ -z "$LUA_VERSION" ] ; then
1510 echo "Lua is not requested"
1511 else
1512 echo "Requested Lua version is $LUA_VERSION"
1513 fi
1514 uninstall_lua -r
1515 fi
1516  
1517 if [ ! -z "$installed_gnutls_version" -a \
1518 "$installed_gnutls_version" != "$GNUTLS_VERSION" ] ; then
1519 echo "Installed GnuTLS version is $installed_gnutls_version"
1520 if [ -z "$GNUTLS_VERSION" ] ; then
1521 echo "GnuTLS is not requested"
1522 else
1523 echo "Requested GnuTLS version is $GNUTLS_VERSION"
1524 fi
1525 uninstall_gnutls -r
1526 fi
1527  
1528 if [ ! -z "$installed_libgcrypt_version" -a \
1529 "$installed_libgcrypt_version" != "$LIBGCRYPT_VERSION" ] ; then
1530 echo "Installed libgcrypt version is $installed_libgcrypt_version"
1531 if [ -z "$LIBGCRYPT_VERSION" ] ; then
1532 echo "libgcrypt is not requested"
1533 else
1534 echo "Requested libgcrypt version is $LIBGCRYPT_VERSION"
1535 fi
1536 uninstall_libgcrypt -r
1537 fi
1538  
1539 if [ ! -z "$installed_libgpg_error_version" -a \
1540 "$installed_libgpg_error_version" != "$LIBGPG_ERROR_VERSION" ] ; then
1541 echo "Installed libgpg-error version is $installed_libgpg_error_version"
1542 if [ -z "$LIBGPG_ERROR_VERSION" ] ; then
1543 echo "libgpg-error is not requested"
1544 else
1545 echo "Requested libgpg-error version is $LIBGPG_ERROR_VERSION"
1546 fi
1547 uninstall_libgpg_error -r
1548 fi
1549  
1550 if [ ! -z "$installed_libsmi_version" -a \
1551 "$installed_libsmi_version" != "$LIBSMI_VERSION" ] ; then
1552 echo "Installed libsmi version is $installed_libsmi_version"
1553 if [ -z "$LIBSMI_VERSION" ] ; then
1554 echo "libsmi is not requested"
1555 else
1556 echo "Requested libsmi version is $LIBSMI_VERSION"
1557 fi
1558 uninstall_libsmi -r
1559 fi
1560  
1561 if [ ! -z "$installed_gtk_version" -a \
1562 "$installed_gtk_version" != "$GTK_VERSION" ] ; then
1563 echo "Installed GTK+ version is $installed_gtk_version"
1564 if [ -z "$GTK_VERSION" ] ; then
1565 echo "GTK+ is not requested"
1566 else
1567 echo "Requested GTK+ version is $GTK_VERSION"
1568 fi
1569 uninstall_gtk -r
1570 fi
1571  
1572 if [ ! -z "$installed_gdk_pixbuf_version" -a \
1573 "$installed_gdk_pixbuf_version" != "$GDK_PIXBUF_VERSION" ] ; then
1574 echo "Installed gdk-pixbuf version is $installed_gdk_pixbuf_version"
1575 if [ -z "$GDK_PIXBUF_VERSION" ] ; then
1576 echo "gdk-pixbuf is not requested"
1577 else
1578 echo "Requested gdk-pixbuf version is $GDK_PIXBUF_VERSION"
1579 fi
1580 uninstall_gdk_pixbuf -r
1581 fi
1582  
1583 if [ ! -z "$installed_pango_version" -a \
1584 "$installed_pango_version" != "$PANGO_VERSION" ] ; then
1585 echo "Installed Pango version is $installed_pango_version"
1586 if [ -z "$PANGO_VERSION" ] ; then
1587 echo "Pango is not requested"
1588 else
1589 echo "Requested Pango version is $PANGO_VERSION"
1590 fi
1591 uninstall_pango -r
1592 fi
1593  
1594 if [ ! -z "$installed_atk_version" -a \
1595 "$installed_atk_version" != "$ATK_VERSION" ] ; then
1596 echo "Installed ATK version is $installed_atk_version"
1597 if [ -z "$ATK_VERSION" ] ; then
1598 echo "ATK is not requested"
1599 else
1600 echo "Requested ATK version is $ATK_VERSION"
1601 fi
1602 uninstall_atk -r
1603 fi
1604  
1605 if [ ! -z "$installed_cairo_version" -a \
1606 "$installed_cairo_version" != "$CAIRO_VERSION" ] ; then
1607 echo "Installed Cairo version is $installed_cairo_version"
1608 if [ -z "$CAIRO_VERSION" ] ; then
1609 echo "Cairo is not requested"
1610 else
1611 echo "Requested Cairo version is $CAIRO_VERSION"
1612 fi
1613 uninstall_cairo -r
1614 fi
1615  
1616 if [ ! -z "$installed_pixman_version" -a \
1617 "$installed_pixman_version" != "$PIXMAN_VERSION" ] ; then
1618 echo "Installed pixman version is $installed_pixman_version"
1619 if [ -z "$PIXMAN_VERSION" ] ; then
1620 echo "pixman is not requested"
1621 else
1622 echo "Requested pixman version is $PIXMAN_VERSION"
1623 fi
1624 uninstall_pixman -r
1625 fi
1626  
1627 if [ ! -z "$installed_libpng_version" -a \
1628 "$installed_libpng_version" != "$PNG_VERSION" ] ; then
1629 echo "Installed libpng version is $installed_libpng_version"
1630 if [ -z "$PNG_VERSION" ] ; then
1631 echo "libpng is not requested"
1632 else
1633 echo "Requested libpng version is $PNG_VERSION"
1634 fi
1635 uninstall_libpng -r
1636 fi
1637  
1638 if [ ! -z "$installed_qt_version" -a \
1639 "$installed_qt_version" != "$QT_VERSION" ] ; then
1640 echo "Installed Qt version is $installed_qt_version"
1641 if [ -z "$QT_VERSION" ] ; then
1642 echo "Qt is not requested"
1643 else
1644 echo "Requested Qt version is $QT_VERSION"
1645 fi
1646 uninstall_qt -r
1647 fi
1648  
1649 if [ ! -z "$installed_glib_version" -a \
1650 "$installed_glib_version" != "$GLIB_VERSION" ] ; then
1651 echo "Installed GLib version is $installed_glib_version"
1652 if [ -z "$GLIB_VERSION" ] ; then
1653 echo "GLib is not requested"
1654 else
1655 echo "Requested GLib version is $GLIB_VERSION"
1656 fi
1657 uninstall_glib -r
1658 fi
1659  
1660 if [ ! -z "$installed_pkg_config_version" -a \
1661 "$installed_pkg_config_version" != "$PKG_CONFIG_VERSION" ] ; then
1662 echo "Installed pkg-config version is $installed_pkg_config_version"
1663 if [ -z "$PKG_CONFIG_VERSION" ] ; then
1664 echo "pkg-config is not requested"
1665 else
1666 echo "Requested pkg-config version is $PKG_CONFIG_VERSION"
1667 fi
1668 uninstall_pkg_config -r
1669 fi
1670  
1671 if [ ! -z "$installed_gettext_version" -a \
1672 "$installed_gettext_version" != "$GETTEXT_VERSION" ] ; then
1673 echo "Installed GNU gettext version is $installed_gettext_version"
1674 if [ -z "$GETTEXT_VERSION" ] ; then
1675 echo "GNU gettext is not requested"
1676 else
1677 echo "Requested GNU gettext version is $GETTEXT_VERSION"
1678 fi
1679 uninstall_gettext -r
1680 fi
1681  
1682 if [ ! -z "$installed_cmake_version" -a \
1683 "$installed_cmake_version" != "$CMAKE_VERSION" ] ; then
1684 echo "Installed CMake version is $installed_cmake_version"
1685 if [ -z "$CMAKE_VERSION" ] ; then
1686 echo "CMake is not requested"
1687 else
1688 echo "Requested CMake version is $CMAKE_VERSION"
1689 fi
1690 #
1691 # XXX - really remove this?
1692 # Or should we remember it as installed only if this script
1693 # installed it?
1694 #
1695 uninstall_cmake -r
1696 fi
1697  
1698 if [ ! -z "$installed_libtool_version" -a \
1699 "$installed_libtool_version" != "$LIBTOOL_VERSION" ] ; then
1700 echo "Installed GNU libtool version is $installed_libtool_version"
1701 if [ -z "$LIBTOOL_VERSION" ] ; then
1702 echo "GNU libtool is not requested"
1703 else
1704 echo "Requested GNU libtool version is $LIBTOOL_VERSION"
1705 fi
1706 uninstall_libtool -r
1707 fi
1708  
1709 if [ ! -z "$installed_automake_version" -a \
1710 "$installed_automake_version" != "$AUTOMAKE_VERSION" ] ; then
1711 echo "Installed GNU automake version is $installed_automake_version"
1712 if [ -z "$AUTOMAKE_VERSION" ] ; then
1713 echo "GNU automake is not requested"
1714 else
1715 echo "Requested GNU automake version is $AUTOMAKE_VERSION"
1716 fi
1717 uninstall_automake -r
1718 fi
1719  
1720 if [ ! -z "$installed_autoconf_version" -a \
1721 "$installed_autoconf_version" != "$AUTOCONF_VERSION" ] ; then
1722 echo "Installed GNU autoconf version is $installed_autoconf_version"
1723 if [ -z "$AUTOCONF_VERSION" ] ; then
1724 echo "GNU autoconf is not requested"
1725 else
1726 echo "Requested GNU autoconf version is $AUTOCONF_VERSION"
1727 fi
1728 uninstall_autoconf -r
1729 fi
1730  
1731 if [ ! -z "$installed_xz_version" -a \
1732 "$installed_xz_version" != "$XZ_VERSION" ] ; then
1733 echo "Installed xz version is $installed_xz_version"
1734 if [ -z "$XZ_VERSION" ] ; then
1735 echo "xz is not requested"
1736 else
1737 echo "Requested xz version is $XZ_VERSION"
1738 fi
1739 uninstall_xz -r
1740 fi
1741  
1742 #
1743 # Start with xz: It is the sole download format of glib later than 2.31.2
1744 #
1745 install_xz
1746  
1747 install_autoconf
1748  
1749 install_automake
1750  
1751 install_libtool
1752  
1753 install_cmake
1754  
1755 #
1756 # Start with GNU gettext; GLib requires it, and OS X doesn't have it
1757 # or a BSD-licensed replacement.
1758 #
1759 # At least on Lion with Xcode 4, _FORTIFY_SOURCE gets defined as 2
1760 # by default, which causes, for example, stpncpy to be defined as
1761 # a hairy macro that collides with the GNU gettext configure script's
1762 # attempts to workaround AIX's lack of a declaration for stpncpy,
1763 # with the result being a huge train wreck. Define _FORTIFY_SOURCE
1764 # as 0 in an attempt to keep the trains on separate tracks.
1765 #
1766 install_gettext
1767  
1768 #
1769 # GLib depends on pkg-config.
1770 # By default, pkg-config depends on GLib; we break the dependency cycle
1771 # by configuring pkg-config to use its own internal version of GLib.
1772 #
1773 install_pkg_config
1774  
1775 install_glib
1776  
1777 #
1778 # Now we have reached a point where we can build everything but
1779 # the GUI (Wireshark).
1780 #
1781 install_qt
1782  
1783 if [ "$GTK_VERSION" ]; then
1784 #
1785 # GTK+ 3 requires a newer Cairo build than the one that comes with
1786 # 10.6, so we build Cairo if we are using GTK+ 3.
1787 #
1788 # In 10.6 and 10.7, it's an X11 library; if we build with "native" GTK+
1789 # rather than X11 GTK+, we might have to build and install Cairo.
1790 # In 10.8 and later, there is no X11, but it's included in Xquartz;
1791 # again, if we build with "native" GTK+, we'd have to build and install
1792 # it.
1793 #
1794 if [[ "$GTK_MAJOR_VERSION" -eq 3 || "$cairo_not_in_the_os" = yes ]]; then
1795 #
1796 # Requirements for Cairo first
1797 #
1798 # The libpng that comes with the X11 for Leopard has a bogus
1799 # pkg-config file that lies about where the header files are,
1800 # which causes other packages not to be able to find its
1801 # headers.
1802 #
1803 # The libpng in later versions is not what the version of
1804 # libpixman we build below wants - it wants libpng15.
1805 #
1806 install_libpng
1807  
1808 #
1809 # The libpixman versions that come with the X11s for Leopard,
1810 # Snow Leopard, and Lion is too old to support Cairo's image
1811 # surface backend feature (which requires pixman-1 >= 0.22.0).
1812 #
1813 # XXX - what about the one that comes with the latest version
1814 # of Xquartz?
1815 #
1816 install_pixman
1817  
1818 #
1819 # And now Cairo itself.
1820 # XXX - with the libxcb that comes with 10.6,
1821 # xcb_discard_reply() is missing, and the build fails.
1822 #
1823 install_cairo
1824 fi
1825  
1826 install_atk
1827  
1828 install_pango
1829  
1830 install_gdk_pixbuf
1831  
1832 install_gtk
1833 fi
1834  
1835 #
1836 # Now we have reached a point where we can build everything including
1837 # the GUI (Wireshark), but not with any optional features such as
1838 # SNMP OID resolution, some forms of decryption, Lua scripting, playback
1839 # of audio, or GeoIP mapping of IP addresses.
1840 #
1841 # We now conditionally download optional libraries to support them;
1842 # the default is to download them all.
1843 #
1844  
1845 install_libsmi
1846  
1847 install_libgpg_error
1848  
1849 install_libgcrypt
1850  
1851 install_gnutls
1852  
1853 install_lua
1854  
1855 install_portaudio
1856  
1857 install_geoip
1858  
1859 install_c_ares
1860  
1861 install_libssh
1862 }
1863  
1864 uninstall_all() {
1865 if [ -d macosx-support-libs ]
1866 then
1867 cd macosx-support-libs
1868  
1869 #
1870 # Uninstall items in the reverse order from the order in which they're
1871 # installed. Only uninstall if the download/build/install process
1872 # completed; uninstall the version that appears in the name of
1873 # the -done file.
1874 #
1875 # We also do a "make distclean", so that we don't have leftovers from
1876 # old configurations.
1877 #
1878 uninstall_libssh
1879  
1880 uninstall_c_ares
1881  
1882 uninstall_geoip
1883  
1884 uninstall_portaudio
1885  
1886 uninstall_lua
1887  
1888 uninstall_gnutls
1889  
1890 uninstall_libgcrypt
1891  
1892 uninstall_libgpg_error
1893  
1894 uninstall_libsmi
1895  
1896 uninstall_gtk
1897  
1898 uninstall_gdk_pixbuf
1899  
1900 uninstall_pango
1901  
1902 uninstall_atk
1903  
1904 uninstall_cairo
1905  
1906 uninstall_pixman
1907  
1908 uninstall_libpng
1909  
1910 uninstall_qt
1911  
1912 uninstall_glib
1913  
1914 uninstall_pkg_config
1915  
1916 uninstall_gettext
1917  
1918 #
1919 # XXX - really remove this?
1920 # Or should we remember it as installed only if this script
1921 # installed it?
1922 #
1923 uninstall_cmake
1924  
1925 uninstall_libtool
1926  
1927 uninstall_automake
1928  
1929 uninstall_autoconf
1930  
1931 uninstall_xz
1932 fi
1933 }
1934  
1935 #
1936 # Do we have permission to write in /usr/local?
1937 #
1938 # If so, assume we have permission to write in its subdirectories.
1939 # (If that's not the case, this test needs to check the subdirectories
1940 # as well.)
1941 #
1942 # If not, do "make install", "make uninstall", the removes for Lua,
1943 # and the renames of [g]libtool* with sudo.
1944 #
1945 if [ -w /usr/local ]
1946 then
1947 DO_MAKE_INSTALL="make install"
1948 DO_MAKE_UNINSTALL="make uninstall"
1949 DO_RM="rm"
1950 DO_MV="mv"
1951 else
1952 DO_MAKE_INSTALL="sudo make install"
1953 DO_MAKE_UNINSTALL="sudo make uninstall"
1954 DO_RM="sudo rm"
1955 DO_MV="sudo mv"
1956 fi
1957  
1958 #
1959 # If we have SDKs available, the default target OS is the major version
1960 # of the one we're running; get that and strip off the third component
1961 # if present.
1962 #
1963 for i in /Developer/SDKs \
1964 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \
1965 /Library/Developer/CommandLineTools/SDKs
1966 do
1967 if [ -d "$i" ]
1968 then
1969 min_osx_target=`sw_vers -productVersion | sed 's/\([0-9]*\)\.\([0-9]*\)\.[0-9]*/\1.\2/'`
1970  
1971 #
1972 # That's also the OS whose SDK we'd be using.
1973 #
1974 sdk_target=$min_osx_target
1975 break
1976 fi
1977 done
1978  
1979 #
1980 # Parse command-line flags:
1981 #
1982 # -h - print help.
1983 # -t <target> - build libraries so that they'll work on the specified
1984 # version of OS X and later versions.
1985 # -u - do an uninstall.
1986 #
1987 while getopts ht:u name
1988 do
1989 case $name in
1990 u)
1991 do_uninstall=yes
1992 ;;
1993 t)
1994 min_osx_target="$OPTARG"
1995 ;;
1996 h|?)
1997 echo "Usage: macosx-setup.sh [ -t <target> ] [ -u ]" 1>&1
1998 exit 0
1999 ;;
2000 esac
2001 done
2002  
2003 #
2004 # Get the version numbers of installed packages, if any.
2005 #
2006 if [ -d macosx-support-libs ]
2007 then
2008 cd macosx-support-libs
2009  
2010 installed_xz_version=`ls xz-*-done 2>/dev/null | sed 's/xz-\(.*\)-done/\1/'`
2011 installed_autoconf_version=`ls autoconf-*-done 2>/dev/null | sed 's/autoconf-\(.*\)-done/\1/'`
2012 installed_automake_version=`ls automake-*-done 2>/dev/null | sed 's/automake-\(.*\)-done/\1/'`
2013 installed_libtool_version=`ls libtool-*-done 2>/dev/null | sed 's/libtool-\(.*\)-done/\1/'`
2014 installed_cmake_version=`ls cmake-*-done 2>/dev/null | sed 's/cmake-\(.*\)-done/\1/'`
2015 installed_gettext_version=`ls gettext-*-done 2>/dev/null | sed 's/gettext-\(.*\)-done/\1/'`
2016 installed_pkg_config_version=`ls pkg-config-*-done 2>/dev/null | sed 's/pkg-config-\(.*\)-done/\1/'`
2017 installed_glib_version=`ls glib-*-done 2>/dev/null | sed 's/glib-\(.*\)-done/\1/'`
2018 installed_qt_version=`ls qt-*-done 2>/dev/null | sed 's/qt-\(.*\)-done/\1/'`
2019 installed_libpng_version=`ls libpng-*-done 2>/dev/null | sed 's/libpng-\(.*\)-done/\1/'`
2020 installed_pixman_version=`ls pixman-*-done 2>/dev/null | sed 's/pixman-\(.*\)-done/\1/'`
2021 installed_cairo_version=`ls cairo-*-done 2>/dev/null | sed 's/cairo-\(.*\)-done/\1/'`
2022 installed_atk_version=`ls atk-*-done 2>/dev/null | sed 's/atk-\(.*\)-done/\1/'`
2023 installed_pango_version=`ls pango-*-done 2>/dev/null | sed 's/pango-\(.*\)-done/\1/'`
2024 installed_gdk_pixbuf_version=`ls gdk-pixbuf-*-done 2>/dev/null | sed 's/gdk-pixbuf-\(.*\)-done/\1/'`
2025 installed_gtk_version=`ls gtk+-*-done 2>/dev/null | sed 's/gtk+-\(.*\)-done/\1/'`
2026 installed_libsmi_version=`ls libsmi-*-done 2>/dev/null | sed 's/libsmi-\(.*\)-done/\1/'`
2027 installed_libgpg_error_version=`ls libgpg-error-*-done 2>/dev/null | sed 's/libgpg-error-\(.*\)-done/\1/'`
2028 installed_libgcrypt_version=`ls libgcrypt-*-done 2>/dev/null | sed 's/libgcrypt-\(.*\)-done/\1/'`
2029 installed_gnutls_version=`ls gnutls-*-done 2>/dev/null | sed 's/gnutls-\(.*\)-done/\1/'`
2030 installed_lua_version=`ls lua-*-done 2>/dev/null | sed 's/lua-\(.*\)-done/\1/'`
2031 installed_portaudio_version=`ls portaudio-*-done 2>/dev/null | sed 's/portaudio-\(.*\)-done/\1/'`
2032 installed_geoip_version=`ls geoip-*-done 2>/dev/null | sed 's/geoip-\(.*\)-done/\1/'`
2033 installed_cares_version=`ls c-ares-*-done 2>/dev/null | sed 's/c-ares-\(.*\)-done/\1/'`
2034 installed_libssh_version=`ls libssh-*-done 2>/dev/null | sed 's/libssh-\(.*\)-done/\1/'`
2035  
2036 #
2037 # If we don't have a versioned -done file for portaudio, but do have
2038 # an unversioned -done file for it, assume the installed version is the
2039 # requested version, and rename the -done file to include that version.
2040 #
2041 if [ -z "$installed_portaudio_version" -a -f portaudio-done ] ; then
2042 mv portaudio-done portaudio-$PORTAUDIO_VERSION-done
2043 installed_portaudio_version=`ls portaudio-*-done 2>/dev/null | sed 's/portaudio-\(.*\)-done/\1/'`
2044 fi
2045  
2046 cd ..
2047 fi
2048  
2049 if [ "$do_uninstall" = "yes" ]
2050 then
2051 uninstall_all
2052 exit 0
2053 fi
2054  
2055 #
2056 # Configure scripts tend to set CFLAGS and CXXFLAGS to "-g -O2" if
2057 # invoked without CFLAGS or CXXFLAGS being set in the environment.
2058 #
2059 # However, we *are* setting them in the environment, for our own
2060 # nefarious purposes, so start them out as "-g -O2".
2061 #
2062 CFLAGS="-g -O2"
2063 CXXFLAGS="-g -O2"
2064  
2065 #
2066 # To make this work on Leopard (rather than working *on* Snow Leopard
2067 # when building *for* Leopard) will take more work.
2068 #
2069 # For one thing, Leopard's /usr/X11/lib/libXdamage.la claims, at least
2070 # with all software updates applied, that the Xdamage shared library
2071 # is libXdamage.1.0.0.dylib, but it is, in fact, libXdamage.1.1.0.dylib.
2072 # This causes problems when building GTK+, so the script would have to
2073 # fix that file.
2074 #
2075 if [[ $DARWIN_MAJOR_VERSION -le 9 ]]; then
2076 echo "This script does not support any versions of OS X before Snow Leopard" 1>&2
2077 exit 1
2078 fi
2079  
2080 # if no make options are present, set default options
2081 if [ -z "$MAKE_BUILD_OPTS" ] ; then
2082 # by default use 1.5x number of cores for parallel build
2083 MAKE_BUILD_OPTS="-j $(( $(sysctl -n hw.logicalcpu) * 3 / 2))"
2084 fi
2085  
2086 #
2087 # If we have a target release, look for the oldest SDK that's for an
2088 # OS equal to or later than that one, and build libraries against it
2089 # rather than against the headers and, more importantly, libraries
2090 # that come with the OS, so that we don't end up with support libraries
2091 # that only work on the OS version on which we built them, not earlier
2092 # versions of the same release, or earlier releases if the minimum is
2093 # earlier.
2094 #
2095 if [ ! -z "$min_osx_target" ]
2096 then
2097 #
2098 # Get the real version - strip off the "10.".
2099 # We'll worry about that if, as, and when there's ever
2100 # an OS XI.
2101 #
2102 deploy_real_version=`echo "$min_osx_target" | sed -n 's/10\.\(.*\)/\1/p'`
2103  
2104 #
2105 # Search each directory that might contain SDKs.
2106 #
2107 sdkpath=""
2108 for sdksdir in /Developer/SDKs \
2109 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \
2110 /Library/Developer/CommandLineTools/SDKs
2111 do
2112 #
2113 # Get a list of all the SDKs.
2114 #
2115 if ! test -d "$sdksdir"
2116 then
2117 #
2118 # There is no directory with that name.
2119 # Move on to the next one in the list, if any.
2120 #
2121 continue
2122 fi
2123  
2124 #
2125 # Get a list of all the SDKs in that directory, if any.
2126 #
2127 sdklist=`(cd "$sdksdir"; ls -d MacOSX10.[0-9]*.sdk 2>/dev/null)`
2128  
2129 for sdk in $sdklist
2130 do
2131 #
2132 # Get the real version for this SDK.
2133 #
2134 sdk_real_version=`echo "$sdk" | sed -n 's/MacOSX10\.\(.*\)\.sdk/\1/p'`
2135  
2136 #
2137 # Is it for the deployment target or some later release?
2138 #
2139 if test "$sdk_real_version" -ge "$deploy_real_version"
2140 then
2141 #
2142 # Yes, use it.
2143 #
2144 sdkpath="$sdksdir/$sdk"
2145 qt_sdk_arg="-sdk $sdk"
2146 break 2
2147 fi
2148 done
2149 done
2150  
2151 if [ -z "$sdkpath" ]
2152 then
2153 echo "macosx-setup.sh: Couldn't find an SDK for OS X $min_osx_target or later" 1>&2
2154 exit 1
2155 fi
2156  
2157 SDKPATH="$sdkpath"
2158 sdk_target=10.$sdk_real_version
2159 echo "Using the 10.$sdk_real_version SDK"
2160  
2161 #
2162 # Make sure there are links to /usr/local/include and /usr/local/lib
2163 # in the SDK's usr/local.
2164 #
2165 if [ ! -e $SDKPATH/usr/local/include ]
2166 then
2167 if [ ! -d $SDKPATH/usr/local ]
2168 then
2169 sudo mkdir $SDKPATH/usr/local
2170 fi
2171 sudo ln -s /usr/local/include $SDKPATH/usr/local/include
2172 fi
2173 if [ ! -e $SDKPATH/usr/local/lib ]
2174 then
2175 if [ ! -d $SDKPATH/usr/local ]
2176 then
2177 sudo mkdir $SDKPATH/usr/local
2178 fi
2179 sudo ln -s /usr/local/lib $SDKPATH/usr/local/lib
2180 fi
2181  
2182 #
2183 # Set the minimum OS version for which to build to the specified
2184 # minimum target OS version, so we don't, for example, end up using
2185 # linker features supported by the OS verson on which we're building
2186 # but not by the target version.
2187 #
2188 VERSION_MIN_FLAGS="-mmacosx-version-min=$min_osx_target"
2189  
2190 #
2191 # Compile and link against the SDK.
2192 #
2193 SDKFLAGS="-isysroot $SDKPATH"
2194  
2195 if [[ "$min_osx_target" == "10.5" ]]
2196 then
2197 #
2198 # Cairo is part of Mac OS X 10.6 and later.
2199 # The *headers* are supplied by 10.5, but the *libraries*
2200 # aren't, so we have to build it if we're building for 10.5.
2201 #
2202 cairo_not_in_the_os=yes
2203  
2204 #
2205 # Build with older versions of the support libraries, as
2206 # were used on the Wireshark Leopard buildbot at one
2207 # point. (Most of these versions come from the About page
2208 # from Wireshark 1.8.6, the last build done on that buildbot;
2209 # the ATK version isn't reported, so this is a guess.)
2210 #
2211 # If you want to try building with newer versions of
2212 # the libraries, note that:
2213 #
2214 # The version of fontconfig that comes with Leopard doesn't
2215 # support FC_WEIGHT_EXTRABLACK, so we can't use any version
2216 # of Pango newer than 1.22.4.
2217 #
2218 # However, Pango 1.22.4 doesn't work with versions of GLib
2219 # after 2.29.6, because Pango 1.22.4 uses G_CONST_RETURN and
2220 # GLib 2.29.8 and later deprecate it (there doesn't appear to
2221 # be a GLib 2.29.7). That means we'd either have to patch
2222 # Pango not to use it (just use "const"; G_CONST_RETURN was
2223 # there to allow code to choose whether to use "const" or not),
2224 # or use GLib 2.29.6 or earlier.
2225 #
2226 # GLib 2.29.6 includes an implementation of g_bit_lock() that,
2227 # on x86 (32-bit and 64-bit), uses asms in a fashion
2228 # ("asm volatile goto") that requires GCC 4.5 or later, which
2229 # is later than the compilers that come with Leopard and Snow
2230 # Leopard. Recent versions of GLib check for that, but 2.29.6
2231 # doesn't, so, if you want to build GLib 2.29.6 on Leopard or
2232 # Snow Leopard, you would have to patch glib/gbitlock.c to do
2233 # what the newer versions of GLib do:
2234 #
2235 # define a USE_ASM_GOTO macro that indicates whether "asm goto"
2236 # can be used:
2237 # #if (defined (i386) || defined (__amd64__))
2238 # #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
2239 # #define USE_ASM_GOTO 1
2240 # #endif
2241 # #endif
2242 #
2243 # replace all occurrences of
2244 #
2245 # #if defined (__GNUC__) && (defined (i386) || defined (__amd64__))
2246 #
2247 # with
2248 #
2249 # #ifdef USE_ASM_GOTO
2250 #
2251 # Using GLib 2.29.6 or earlier, however, means that we can't
2252 # use a version of ATK later than 2.3.93, as those versions
2253 # don't work with GLib 2.29.6. The same applies to gdk-pixbuf;
2254 # versions of gdk-pixbuf after 2.24.1 won't work with GLib
2255 # 2.29.6.
2256 #
2257 # Then you have to make sure that what you've build doesn't
2258 # cause the X server that comes with Leopard to crash; at
2259 # least one attempt at building for Leopard did.
2260 #
2261 # At least if building on Leopard, you might also find
2262 # that, with various older versions of Cairo, including
2263 # 1.6.4 and at least some 1.8.x versions, when you try to
2264 # build it, the build fails because it can't find
2265 # png_set_longjmp_fn(). I vaguely remember dealing with that,
2266 # ages ago, but don't remember what I did.
2267 #
2268 GLIB_VERSION=2.16.3
2269 if [ "$CAIRO_VERSION" ]
2270 then
2271 CAIRO_VERSION=1.6.4
2272 fi
2273 if [ "$ATK_VERSION" ]
2274 then
2275 ATK_VERSION=1.24.0
2276 fi
2277 if [ "$PANGO_VERSION" ]
2278 then
2279 PANGO_VERSION=1.20.2
2280 fi
2281 if [ "$GTK_VERSION" ]
2282 then
2283 GTK_VERSION=2.12.9
2284 fi
2285  
2286 #
2287 # That version of GTK+ includes gdk-pixbuf.
2288 # XXX - base this on the version of GTK+ requested.
2289 #
2290 GDK_PIXBUF_VERSION=
2291  
2292 #
2293 # Libgcrypt 1.5.0 fails to compile due to some problem with an
2294 # asm in rijndael.c, at least with i686-apple-darwin10-gcc-4.2.1
2295 # (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3) when building
2296 # 32-bit.
2297 #
2298 # We try libgcrypt 1.4.3 instead, as that's what shows up in
2299 # the version from the Leopard buildbot.
2300 LIBGCRYPT_VERSION=1.4.3
2301  
2302 #
2303 # Build 32-bit while we're at it; Leopard has a bug that
2304 # causes some BPF functions not to work with 64-bit userland
2305 # code, so capturing won't work.
2306 #
2307 CFLAGS="$CFLAGS -arch i386"
2308 CXXFLAGS="$CXXFLAGS -arch i386"
2309 export LDFLAGS="$LDFLAGS -arch i386"
2310 fi
2311 fi
2312  
2313 export CFLAGS
2314 export CXXFLAGS
2315  
2316 #
2317 # You need Xcode or the command-line tools installed to get the compilers.
2318 #
2319 if [ ! -x /usr/bin/xcodebuild ]; then
2320 echo "Please install Xcode first (should be available on DVD or from the Mac App Store)."
2321 exit 1
2322 fi
2323  
2324 if [ "$QT_VERSION" ]; then
2325 #
2326 # We need Xcode, not just the command-line tools, installed to build
2327 # Qt.
2328 #
2329 # At least with Xcode 8, /usr/bin/xcodebuild --help fails if only
2330 # the command-line tools are installed and succeeds if Xcode is
2331 # installed. Unfortunately, it fails *with* Xcode 3, but
2332 # /usr/bin/xcodebuild -version works with that and with Xcode 8.
2333 # Hopefully it fails with only the command-line tools installed.
2334 #
2335 if /usr/bin/xcodebuild -version >/dev/null 2>&1; then
2336 :
2337 else
2338 echo "Please install Xcode first (should be available on DVD or from the Mac App Store)."
2339 echo "The command-line build tools are not sufficient to build Qt."
2340 exit 1
2341 fi
2342 fi
2343 if [ "$GTK_VERSION" ]; then
2344 #
2345 # If we're building with GTK+, you also need the X11 SDK; with at least
2346 # some versions of OS X and Xcode, that is, I think, an optional install.
2347 # (Or it might be installed with X11, but I think *that* is an optional
2348 # install on at least some versions of OS X.)
2349 #
2350 if [ ! -d /usr/X11/include ]; then
2351 echo "Please install X11 and the X11 SDK first."
2352 echo " You can either download the latest package from"
2353 echo " http://www.xquartz.org/ and install it or install"
2354 echo " the native Apple package if you are on Lion or below."
2355 exit 1
2356 fi
2357 fi
2358  
2359 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig
2360  
2361 #
2362 # Do all the downloads and untarring in a subdirectory, so all that
2363 # stuff can be removed once we've installed the support libraries.
2364 #
2365 if [ ! -d macosx-support-libs ]
2366 then
2367 mkdir macosx-support-libs || exit 1
2368 fi
2369 cd macosx-support-libs
2370  
2371 install_all
2372  
2373 echo ""
2374  
2375 #
2376 # Indicate what paths to use for pkg-config and cmake.
2377 #
2378 pkg_config_path=/usr/local/lib/pkgconfig
2379 if [ "$QT_VERSION" ]; then
2380 qt_base_path=$HOME/Qt$QT_VERSION/$QT_MAJOR_MINOR_VERSION/clang_64
2381 pkg_config_path="$pkg_config_path":"$qt_base_path/lib/pkgconfig"
2382 CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH":"$qt_base_path/lib/cmake"
2383 fi
2384 pkg_config_path="$pkg_config_path":/usr/X11/lib/pkgconfig
2385  
2386 echo "You are now prepared to build Wireshark."
2387 echo
2388 if [[ $CMAKE ]]; then
2389 echo "To build with CMAKE:"
2390 echo
2391 echo "export PKG_CONFIG_PATH=$pkg_config_path"
2392 echo "export CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH"
2393 echo "export PATH=$PATH:$qt_base_path/bin"
2394 echo
2395 echo "mkdir build; cd build"
2396 echo "cmake .."
2397 echo "make $MAKE_BUILD_OPTS app_bundle"
2398 echo "make install/strip"
2399 echo
2400 fi
2401 if [[ $AUTOTOOLS ]]; then
2402 echo "To build with AUTOTOOLS:"
2403 echo
2404 echo "export PKG_CONFIG_PATH=$pkg_config_path"
2405 echo
2406 echo "./autogen.sh"
2407 echo "mkdir build; cd build"
2408 echo "../configure"
2409 echo "make $MAKE_BUILD_OPTS"
2410 echo "make install"
2411 echo
2412 fi
2413 echo "Make sure you are allowed capture access to the network devices"
2414 echo "See: https://wiki.wireshark.org/CaptureSetup/CapturePrivileges"
2415 echo
2416  
2417 exit 0