forked from wireshark/wireshark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacos-setup.sh
executable file
·2323 lines (2052 loc) · 78.6 KB
/
macos-setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Setup development environment on macOS (tested with 10.6.8 and Xcode
# 3.2.6 and with 10.12.4 and Xcode 8.3).
#
# Copyright 2011 Michael Tuexen, Joerg Mayer, Guy Harris (see AUTHORS file)
#
# Wireshark - Network traffic analyzer
# By Gerald Combs <gerald@wireshark.org>
# Copyright 1998 Gerald Combs
#
# SPDX-License-Identifier: GPL-2.0-or-later
shopt -s extglob
#
# To install cmake
#
CMAKE=1
#
# To install autotools
#
AUTOTOOLS=1
#
# To build all libraries as 32-bit libraries uncomment the following three lines.
#
# export CFLAGS="$CFLAGS -arch i386"
# export CXXFLAGS="$CXXFLAGS -arch i386"
# export LDFLAGS="$LDFLAGS -arch i386"
#
# and change "macx-clang" to "macx-clang-32" in the line below.
#
# Note: when building against the 10.6 SDK, clang fails, because there's
# a missing libstdc++.dylib in the SDK; this does not bother g++, however.
#
#TARGET_PLATFORM=macx-g++
TARGET_PLATFORM=macx-clang
#
# Versions of packages to download and install.
#
#
# Some packages need xz to unpack their current source.
# While tar, in newer versions of macOS, can uncompress xz'ed tarballs,
# it can't do so in older versions, and xz isn't provided with macOS.
#
XZ_VERSION=5.2.3
#
# Some packages need lzip to unpack their current source.
#
LZIP_VERSION=1.19
#
# In case we want to build with cmake.
#
CMAKE_VERSION=${CMAKE_VERSION-3.11.0}
#
# The following libraries and tools are required even to build only TShark.
#
GETTEXT_VERSION=0.19.8.1
GLIB_VERSION=2.36.0
PKG_CONFIG_VERSION=0.29.2
#
# libgpg-error is required for libgcrypt.
#
LIBGPG_ERROR_VERSION=1.27
#
# libgcrypt is required.
#
LIBGCRYPT_VERSION=1.7.7
#
# One or more of the following libraries are required to build Wireshark.
#
# To override the version of Qt call the script with some of the variables
# set to the new values. Setting the variable to empty will disable building
# the toolkit and will uninstall # any version previously installed by the
# script, e.g.
# "QT_VERSION=5.10.1 ./macos-setup.sh"
# will build and install with QT 5.10.1.
#
# Note that Qt 5, prior to 5.5.0, mishandles context menus in ways that,
# for example, cause them not to work reliably in the packet detail or
# packet data pane; see, for example, Qt bugs QTBUG-31937, QTBUG-41017,
# and QTBUG-43464, all of which seem to be the same bug.
#
QT_VERSION=${QT_VERSION-5.9.5}
if [ "$QT_VERSION" ]; then
QT_MAJOR_VERSION="`expr $QT_VERSION : '\([0-9][0-9]*\).*'`"
QT_MINOR_VERSION="`expr $QT_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
QT_DOTDOT_VERSION="`expr $QT_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
QT_MAJOR_MINOR_VERSION=$QT_MAJOR_VERSION.$QT_MINOR_VERSION
QT_MAJOR_MINOR_DOTDOT_VERSION=$QT_MAJOR_VERSION.$QT_MINOR_VERSION.$QT_DOTDOT_VERSION
fi
#
# The following libraries are optional.
# Comment them out if you don't want them, but note that some of
# the optional libraries are required by other optional libraries.
#
LIBSMI_VERSION=0.4.8
GNUTLS_VERSION=3.4.17
if [ "$GNUTLS_VERSION" ]; then
#
# We'll be building GnuTLS, so we may need some additional libraries.
# We assume GnuTLS can work with Nettle; newer versions *only* use
# Nettle, not libgcrypt.
#
GNUTLS_MAJOR_VERSION="`expr $GNUTLS_VERSION : '\([0-9][0-9]*\).*'`"
GNUTLS_MINOR_VERSION="`expr $GNUTLS_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
GNUTLS_DOTDOT_VERSION="`expr $GNUTLS_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
NETTLE_VERSION=3.3
#
# And, in turn, Nettle requires GMP.
#
GMP_VERSION=6.1.2
fi
# Use 5.2.4, not 5.3, for now; lua_bitop.c hasn't been ported to 5.3
# yet, and we need to check for compatibility issues (we'd want Lua
# scripts to work with 5.1, 5.2, and 5.3, as long as they only use Lua
# features present in all three versions)
LUA_VERSION=5.2.4
SNAPPY_VERSION=1.1.4
LIBXML2_VERSION=2.9.4
LZ4_VERSION=1.7.5
SBC_VERSION=1.3
CARES_VERSION=1.12.0
# Redmine used by libssh.org numbers the files available for download,
# so using version only isn't enough
LIBSSH_VERSION=0.7.4
LIBSSH_FILENUM=210
# mmdbresolve
MAXMINDDB_VERSION=1.3.2
NGHTTP2_VERSION=1.21.0
SPANDSP_VERSION=0.0.6
if [ "$SPANDSP_VERSION" ]; then
#
# SpanDSP depends on libtiff.
#
LIBTIFF_VERSION=3.8.1
fi
BCG729_VERSION=1.0.2
DARWIN_MAJOR_VERSION=`uname -r | sed 's/\([0-9]*\).*/\1/'`
#
# GNU autotools; they're provided with releases up to Snow Leopard, but
# not in later releases, and the Snow Leopard version is too old for
# current Wireshark, so we install them unconditionally.
#
AUTOCONF_VERSION=2.69
AUTOMAKE_VERSION=1.15
LIBTOOL_VERSION=2.4.6
install_xz() {
if [ "$XZ_VERSION" -a ! -f xz-$XZ_VERSION-done ] ; then
echo "Downloading, building, and installing xz:"
[ -f xz-$XZ_VERSION.tar.bz2 ] || curl -L -O http://tukaani.org/xz/xz-$XZ_VERSION.tar.bz2 || exit 1
$no_build && echo "Skipping installation" && return
bzcat xz-$XZ_VERSION.tar.bz2 | tar xf - || exit 1
cd xz-$XZ_VERSION
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0" ./configure || exit 1
make $MAKE_BUILD_OPTS || exit 1
$DO_MAKE_INSTALL || exit 1
cd ..
touch xz-$XZ_VERSION-done
fi
}
uninstall_xz() {
if [ ! -z "$installed_xz_version" ] ; then
echo "Uninstalling xz:"
cd xz-$installed_xz_version
$DO_MAKE_UNINSTALL || exit 1
make distclean || exit 1
cd ..
rm xz-$installed_xz_version-done
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded and unpacked version.
#
rm -rf xz-$installed_xz_version
rm -rf xz-$installed_xz_version.tar.bz2
fi
installed_xz_version=""
fi
}
install_lzip() {
if [ "$LZIP_VERSION" -a ! -f lzip-$LZIP_VERSION-done ] ; then
echo "Downloading, building, and installing lzip:"
[ -f lzip-$LZIP_VERSION.tar.gz ] || curl -L -O http://download.savannah.gnu.org/releases/lzip/lzip-$LZIP_VERSION.tar.gz || exit 1
$no_build && echo "Skipping installation" && return
gzcat lzip-$LZIP_VERSION.tar.gz | tar xf - || exit 1
cd lzip-$LZIP_VERSION
./configure || exit 1
make $MAKE_BUILD_OPTS || exit 1
$DO_MAKE_INSTALL || exit 1
cd ..
touch lzip-$LZIP_VERSION-done
fi
}
uninstall_lzip() {
if [ ! -z "$installed_lzip_version" ] ; then
echo "Uninstalling lzip:"
cd lzip-$installed_lzip_version
$DO_MAKE_UNINSTALL || exit 1
make distclean || exit 1
cd ..
rm lzip-$installed_lzip_version-done
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded and unpacked version.
#
rm -rf lzip-$installed_lzip_version
rm -rf lzip-$installed_lzip_version.tar.gz
fi
installed_lzip_version=""
fi
}
install_autoconf() {
if [ "$AUTOCONF_VERSION" -a ! -f autoconf-$AUTOCONF_VERSION-done ] ; then
echo "Downloading, building and installing GNU autoconf..."
[ -f autoconf-$AUTOCONF_VERSION.tar.xz ] || curl -L -O ftp://ftp.gnu.org/gnu/autoconf/autoconf-$AUTOCONF_VERSION.tar.xz || exit 1
$no_build && echo "Skipping installation" && return
xzcat autoconf-$AUTOCONF_VERSION.tar.xz | tar xf - || exit 1
cd autoconf-$AUTOCONF_VERSION
./configure || exit 1
make $MAKE_BUILD_OPTS || exit 1
$DO_MAKE_INSTALL || exit 1
cd ..
touch autoconf-$AUTOCONF_VERSION-done
fi
}
uninstall_autoconf() {
if [ ! -z "$installed_autoconf_version" ] ; then
#
# automake and libtool depend on this, so uninstall them.
#
uninstall_libtool
uninstall_automake
echo "Uninstalling GNU autoconf:"
cd autoconf-$installed_autoconf_version
$DO_MAKE_UNINSTALL || exit 1
make distclean || exit 1
cd ..
rm autoconf-$installed_autoconf_version-done
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded and unpacked version.
#
rm -rf autoconf-$installed_autoconf_version
rm -rf autoconf-$installed_autoconf_version.tar.xz
fi
installed_autoconf_version=""
fi
}
install_automake() {
if [ "$AUTOMAKE_VERSION" -a ! -f automake-$AUTOMAKE_VERSION-done ] ; then
echo "Downloading, building and installing GNU automake..."
[ -f automake-$AUTOMAKE_VERSION.tar.xz ] || curl -L -O ftp://ftp.gnu.org/gnu/automake/automake-$AUTOMAKE_VERSION.tar.xz || exit 1
$no_build && echo "Skipping installation" && return
xzcat automake-$AUTOMAKE_VERSION.tar.xz | tar xf - || exit 1
cd automake-$AUTOMAKE_VERSION
./configure || exit 1
make $MAKE_BUILD_OPTS || exit 1
$DO_MAKE_INSTALL || exit 1
cd ..
touch automake-$AUTOMAKE_VERSION-done
fi
}
uninstall_automake() {
if [ ! -z "$installed_automake_version" ] ; then
#
# libtool depends on this(?), so uninstall it.
#
uninstall_libtool "$@"
echo "Uninstalling GNU automake:"
cd automake-$installed_automake_version
$DO_MAKE_UNINSTALL || exit 1
make distclean || exit 1
cd ..
rm automake-$installed_automake_version-done
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded and unpacked version.
#
rm -rf automake-$installed_automake_version
rm -rf automake-$installed_automake_version.tar.xz
fi
installed_automake_version=""
fi
}
install_libtool() {
if [ "$LIBTOOL_VERSION" -a ! -f libtool-$LIBTOOL_VERSION-done ] ; then
echo "Downloading, building and installing GNU libtool..."
[ -f libtool-$LIBTOOL_VERSION.tar.xz ] || curl -L -O ftp://ftp.gnu.org/gnu/libtool/libtool-$LIBTOOL_VERSION.tar.xz || exit 1
$no_build && echo "Skipping installation" && return
xzcat libtool-$LIBTOOL_VERSION.tar.xz | tar xf - || exit 1
cd libtool-$LIBTOOL_VERSION
./configure || exit 1
make $MAKE_BUILD_OPTS || exit 1
$DO_MAKE_INSTALL || exit 1
$DO_MV /usr/local/bin/libtool /usr/local/bin/glibtool
$DO_MV /usr/local/bin/libtoolize /usr/local/bin/glibtoolize
cd ..
touch libtool-$LIBTOOL_VERSION-done
fi
}
uninstall_libtool() {
if [ ! -z "$installed_libtool_version" ] ; then
echo "Uninstalling GNU libtool:"
cd libtool-$installed_libtool_version
$DO_MV /usr/local/bin/glibtool /usr/local/bin/libtool
$DO_MV /usr/local/bin/glibtoolize /usr/local/bin/libtoolize
$DO_MAKE_UNINSTALL || exit 1
make distclean || exit 1
cd ..
rm libtool-$installed_libtool_version-done
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded and unpacked version.
#
rm -rf libtool-$installed_libtool_version
rm -rf libtool-$installed_libtool_version.tar.xz
fi
installed_libtool_version=""
fi
}
install_cmake() {
if [ -n "$CMAKE" -a ! -f cmake-$CMAKE_VERSION-done ]; then
echo "Downloading and installing CMake:"
CMAKE_MAJOR_VERSION="`expr $CMAKE_VERSION : '\([0-9][0-9]*\).*'`"
CMAKE_MINOR_VERSION="`expr $CMAKE_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
CMAKE_DOTDOT_VERSION="`expr $CMAKE_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
CMAKE_MAJOR_MINOR_VERSION=$CMAKE_MAJOR_VERSION.$CMAKE_MINOR_VERSION
#
# NOTE: the "64" in "Darwin64" doesn't mean "64-bit-only"; the
# package in question supports both 32-bit and 64-bit x86.
#
case "$CMAKE_MAJOR_VERSION" in
0|1)
echo "CMake $CMAKE_VERSION" is too old 1>&2
;;
2)
#
# Download the DMG, run the installer.
#
[ -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
$no_build && echo "Skipping installation" && return
sudo hdiutil attach cmake-$CMAKE_VERSION-Darwin64-universal.dmg || exit 1
sudo installer -target / -pkg /Volumes/cmake-$CMAKE_VERSION-Darwin64-universal/cmake-$CMAKE_VERSION-Darwin64-universal.pkg || exit 1
sudo hdiutil detach /Volumes/cmake-$CMAKE_VERSION-Darwin64-universal
;;
3)
#
# Download the DMG and do a drag install, where "drag" means
# "mv".
#
# 3.0.* and 3.1.0 have a Darwin64-universal DMG.
# 3.1.1 and later have a Darwin-x86_64 DMG.
# Probably not many people are still developing on 32-bit
# Macs, so we don't worry about them.
#
if [ "$CMAKE_MINOR_VERSION" = 0 -o \
"$CMAKE_VERSION" = 3.1.0 ]; then
type="Darwin64-universal"
else
type="Darwin-x86_64"
fi
[ -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
$no_build && echo "Skipping installation" && return
sudo hdiutil attach cmake-$CMAKE_VERSION-$type.dmg || exit 1
sudo ditto /Volumes/cmake-$CMAKE_VERSION-$type/CMake.app /Applications/CMake.app || exit 1
#
# Plant the appropriate symbolic links in /usr/local/bin.
# It's a drag-install, so there's no installer to make them,
# and the CMake code to put them in place is lame, as
#
# 1) it defaults to /usr/bin, not /usr/local/bin;
# 2) it doesn't request the necessary root privileges;
# 3) it can't be run from the command line;
#
# so we do it ourselves.
#
for i in ccmake cmake cmake-gui cmakexbuild cpack ctest
do
sudo ln -s /Applications/CMake.app/Contents/bin/$i /usr/local/bin/$i
done
sudo hdiutil detach /Volumes/cmake-$CMAKE_VERSION-$type
;;
*)
;;
esac
touch cmake-$CMAKE_VERSION-done
fi
}
uninstall_cmake() {
if [ ! -z "$installed_cmake_version" ]; then
echo "Uninstalling CMake:"
installed_cmake_major_version="`expr $installed_cmake_version : '\([0-9][0-9]*\).*'`"
case "$installed_cmake_major_version" in
0|1)
echo "CMake $installed_cmake_version" is too old 1>&2
;;
2)
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
for i in ccmake cmake cmake-gui cmakexbuild cpack ctest
do
sudo rm -f /usr/bin/$i /usr/local/bin/$i
done
sudo pkgutil --forget com.Kitware.CMake
rm cmake-$installed_cmake_version-done
;;
3)
sudo rm -rf /Applications/CMake.app
for i in ccmake cmake cmake-gui cmakexbuild cpack ctest
do
sudo rm -f /usr/local/bin/$i
done
rm cmake-$installed_cmake_version-done
;;
esac
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded and unpacked version,
# whatever it might happen to be called.
#
rm -f cmake-$installed_cmake_version-Darwin64-universal.dmg
rm -f cmake-$installed_cmake_version-Darwin-x86_64.dmg
fi
installed_cmake_version=""
fi
}
install_gettext() {
if [ ! -f gettext-$GETTEXT_VERSION-done ] ; then
echo "Downloading, building, and installing GNU gettext:"
[ -f gettext-$GETTEXT_VERSION.tar.gz ] || curl -L -O http://ftp.gnu.org/pub/gnu/gettext/gettext-$GETTEXT_VERSION.tar.gz || exit 1
$no_build && echo "Skipping installation" && return
gzcat gettext-$GETTEXT_VERSION.tar.gz | tar xf - || exit 1
cd gettext-$GETTEXT_VERSION
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
make $MAKE_BUILD_OPTS || exit 1
$DO_MAKE_INSTALL || exit 1
cd ..
touch gettext-$GETTEXT_VERSION-done
fi
}
uninstall_gettext() {
if [ ! -z "$installed_gettext_version" ] ; then
#
# GLib depends on this, so uninstall it.
#
uninstall_glib "$@"
echo "Uninstalling GNU gettext:"
cd gettext-$installed_gettext_version
$DO_MAKE_UNINSTALL || exit 1
make distclean || exit 1
cd ..
rm gettext-$installed_gettext_version-done
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded and unpacked version.
#
rm -rf gettext-$installed_gettext_version
rm -rf gettext-$installed_gettext_version.tar.gz
fi
installed_gettext_version=""
fi
}
install_pkg_config() {
if [ ! -f pkg-config-$PKG_CONFIG_VERSION-done ] ; then
echo "Downloading, building, and installing pkg-config:"
[ -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
$no_build && echo "Skipping installation" && return
gzcat pkg-config-$PKG_CONFIG_VERSION.tar.gz | tar xf - || exit 1
cd pkg-config-$PKG_CONFIG_VERSION
./configure --with-internal-glib || exit 1
make $MAKE_BUILD_OPTS || exit 1
$DO_MAKE_INSTALL || exit 1
cd ..
touch pkg-config-$PKG_CONFIG_VERSION-done
fi
}
uninstall_pkg_config() {
if [ ! -z "$installed_pkg_config_version" ] ; then
echo "Uninstalling pkg-config:"
cd pkg-config-$installed_pkg_config_version
$DO_MAKE_UNINSTALL || exit 1
make distclean || exit 1
cd ..
rm pkg-config-$installed_pkg_config_version-done
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded and unpacked version.
#
rm -rf pkg-config-$installed_pkg_config_version
rm -rf pkg-config-$installed_pkg_config_version.tar.gz
fi
installed_pkg_config_version=""
fi
}
install_glib() {
if [ ! -f glib-$GLIB_VERSION-done ] ; then
echo "Downloading, building, and installing GLib:"
glib_dir=`expr $GLIB_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
GLIB_MAJOR_VERSION="`expr $GLIB_VERSION : '\([0-9][0-9]*\).*'`"
GLIB_MINOR_VERSION="`expr $GLIB_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
GLIB_DOTDOT_VERSION="`expr $GLIB_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`"
#
# Starting with GLib 2.28.8, xz-compressed tarballs are available.
#
[ -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
$no_build && echo "Skipping installation" && return
xzcat glib-$GLIB_VERSION.tar.xz | tar xf - || exit 1
cd glib-$GLIB_VERSION
#
# macOS ships with libffi, but doesn't provide its pkg-config file;
# explicitly specify LIBFFI_CFLAGS and LIBFFI_LIBS, so the configure
# script doesn't try to use pkg-config to get the appropriate
# C flags and loader flags.
#
# And, what's worse, at least with the version of Xcode that comes
# with Leopard, /usr/include/ffi/fficonfig.h doesn't define MACOSX,
# which causes the build of GLib to fail. If we don't find
# "#define.*MACOSX" in /usr/include/ffi/fficonfig.h, explicitly
# define it.
#
# While we're at it, suppress -Wformat-nonliteral to avoid a case
# where clang's stricter rules on when not to complain about
# non-literal format arguments cause it to complain about code
# that's safe but it wasn't told that. See my comment #25 in
# GNOME bug 691608:
#
# https://bugzilla.gnome.org/show_bug.cgi?id=691608#c25
#
# First, determine where the system include files are. (It's not
# necessarily /usr/include.) There's a bit of a greasy hack here;
# pre-5.x versions of the developer tools don't support the
# --show-sdk-path option, and will produce no output, so includedir
# will be set to /usr/include (in those older versions of the
# developer tools, there is a /usr/include directory).
#
includedir=`xcrun --show-sdk-path 2>/dev/null`/usr/include
if grep -qs '#define.*MACOSX' $includedir/ffi/fficonfig.h
then
# It's defined, nothing to do
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
else
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
fi
make $MAKE_BUILD_OPTS || exit 1
$DO_MAKE_INSTALL || exit 1
cd ..
touch glib-$GLIB_VERSION-done
fi
}
uninstall_glib() {
if [ ! -z "$installed_glib_version" ] ; then
echo "Uninstalling GLib:"
cd glib-$installed_glib_version
$DO_MAKE_UNINSTALL || exit 1
make distclean || exit 1
cd ..
rm glib-$installed_glib_version-done
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded and unpacked version.
#
rm -rf glib-$installed_glib_version
rm -rf glib-$installed_glib_version.tar.xz
fi
installed_glib_version=""
fi
}
install_qt() {
if [ "$QT_VERSION" -a ! -f qt-$QT_VERSION-done ]; then
echo "Downloading, building, and installing Qt:"
#
# What you get for this URL might just be a 302 Found reply, so use
# -L so we get redirected.
#
# 5.0 - 5.1: qt-mac-opensource-5.0.2-clang-offline.dmg
# 5.2 - 5.8: qt-opensource-mac-x64-clang-5.2.1.dmg
# 5.9 - : qt-opensource-mac-x64-5.10.1.dmg
QT_VOLUME=qt-opensource-mac-x64-$QT_VERSION
[ -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
$no_build && echo "Skipping installation" && return
sudo hdiutil attach $QT_VOLUME.dmg || exit 1
#
# Run the installer executable directly, so that we wait for
# it to finish. Then unmount the volume.
#
/Volumes/$QT_VOLUME/$QT_VOLUME.app/Contents/MacOS/$QT_VOLUME
sudo hdiutil detach /Volumes/$QT_VOLUME
#
# Versions 5.3.x through 5.5.0, at least, have bogus .pc files.
# See bugs QTBUG-35256 and QTBUG-47162.
#
# Fix the files.
#
for i in $HOME/Qt$QT_VERSION/$QT_MAJOR_MINOR_VERSION/clang_64/lib/pkgconfig/*.pc
do
ed - $i <<EOF
H
g/Cflags: /s;;Cflags: -F\${libdir} ;
g/Cflags: /s;-I\${includedir}/Qt\([a-zA-Z0-9_]*\);-I\${libdir}/Qt\1.framework/Versions/5/Headers;
g/Libs: /s;';;g
w
q
EOF
done
touch qt-$QT_VERSION-done
fi
}
uninstall_qt() {
if [ ! -z "$installed_qt_version" ] ; then
echo "Uninstalling Qt:"
rm -rf $HOME/Qt$installed_qt_version
rm qt-$installed_qt_version-done
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded version.
#
rm -rf qt-opensource-mac-x64-?(clang-)$installed_qt_version.dmg
fi
installed_qt_version=""
fi
}
install_libsmi() {
if [ "$LIBSMI_VERSION" -a ! -f libsmi-$LIBSMI_VERSION-done ] ; then
echo "Downloading, building, and installing libsmi:"
[ -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
$no_build && echo "Skipping installation" && return
gzcat libsmi-$LIBSMI_VERSION.tar.gz | tar xf - || exit 1
cd libsmi-$LIBSMI_VERSION
CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
make $MAKE_BUILD_OPTS || exit 1
$DO_MAKE_INSTALL || exit 1
cd ..
touch libsmi-$LIBSMI_VERSION-done
fi
}
uninstall_libsmi() {
if [ ! -z "$installed_libsmi_version" ] ; then
echo "Uninstalling libsmi:"
cd libsmi-$installed_libsmi_version
$DO_MAKE_UNINSTALL || exit 1
make distclean || exit 1
cd ..
rm libsmi-$installed_libsmi_version-done
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded and unpacked version.
#
rm -rf libsmi-$installed_libsmi_version
rm -rf libsmi-$installed_libsmi_version.tar.gz
fi
installed_libsmi_version=""
fi
}
install_libgpg_error() {
if [ "$LIBGPG_ERROR_VERSION" -a ! -f libgpg-error-$LIBGPG_ERROR_VERSION-done ] ; then
echo "Downloading, building, and installing libgpg-error:"
[ -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
$no_build && echo "Skipping installation" && return
bzcat libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 | tar xf - || exit 1
cd libgpg-error-$LIBGPG_ERROR_VERSION
CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1
make $MAKE_BUILD_OPTS || exit 1
$DO_MAKE_INSTALL || exit 1
cd ..
touch libgpg-error-$LIBGPG_ERROR_VERSION-done
fi
}
uninstall_libgpg_error() {
if [ ! -z "$installed_libgpg_error_version" ] ; then
#
# libgcrypt depends on this, so uninstall it.
#
uninstall_libgcrypt "$@"
echo "Uninstalling libgpg-error:"
cd libgpg-error-$installed_libgpg_error_version
$DO_MAKE_UNINSTALL || exit 1
make distclean || exit 1
cd ..
rm libgpg-error-$installed_libgpg_error_version-done
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded and unpacked version.
#
rm -rf libgpg-error-$installed_libgpg_error_version
rm -rf libgpg-error-$installed_libgpg_error_version.tar.bz2
fi
installed_libgpg_error_version=""
fi
}
install_libgcrypt() {
if [ "$LIBGCRYPT_VERSION" -a ! -f libgcrypt-$LIBGCRYPT_VERSION-done ] ; then
#
# libgpg-error is required for libgcrypt.
#
if [ -z $LIBGPG_ERROR_VERSION ]
then
echo "libgcrypt requires libgpg-error, but you didn't install libgpg-error." 1>&2
exit 1
fi
echo "Downloading, building, and installing libgcrypt:"
[ -f libgcrypt-$LIBGCRYPT_VERSION.tar.gz ] || curl -L -O ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-$LIBGCRYPT_VERSION.tar.gz || exit 1
$no_build && echo "Skipping installation" && return
gzcat libgcrypt-$LIBGCRYPT_VERSION.tar.gz | tar xf - || exit 1
cd libgcrypt-$LIBGCRYPT_VERSION
#
# The assembler language code is not compatible with the macOS
# x86 assembler (or is it an x86-64 vs. x86-32 issue?).
#
# libgcrypt expects gnu89, not c99/gnu99, semantics for
# "inline". See, for example:
#
# http://lists.freebsd.org/pipermail/freebsd-ports-bugs/2010-October/198809.html
#
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
make $MAKE_BUILD_OPTS || exit 1
$DO_MAKE_INSTALL || exit 1
cd ..
touch libgcrypt-$LIBGCRYPT_VERSION-done
fi
}
uninstall_libgcrypt() {
if [ ! -z "$installed_libgcrypt_version" ] ; then
echo "Uninstalling libgcrypt:"
cd libgcrypt-$installed_libgcrypt_version
$DO_MAKE_UNINSTALL || exit 1
make distclean || exit 1
cd ..
rm libgcrypt-$installed_libgcrypt_version-done
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded and unpacked version.
#
rm -rf libgcrypt-$installed_libgcrypt_version
rm -rf libgcrypt-$installed_libgcrypt_version.tar.gz
fi
installed_libgcrypt_version=""
fi
}
install_gmp() {
if [ "$GMP_VERSION" -a ! -f gmp-$GMP_VERSION-done ] ; then
echo "Downloading, building, and installing GMP:"
[ -f gmp-$GMP_VERSION.tar.lz ] || curl -L -O https://gmplib.org/download/gmp/gmp-$GMP_VERSION.tar.lz || exit 1
$no_build && echo "Skipping installation" && return
lzip -c -d gmp-$GMP_VERSION.tar.lz | tar xf - || exit 1
cd gmp-$GMP_VERSION
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
make $MAKE_BUILD_OPTS || exit 1
$DO_MAKE_INSTALL || exit 1
cd ..
touch gmp-$GMP_VERSION-done
fi
}
uninstall_gmp() {
if [ ! -z "$installed_gmp_version" ] ; then
#
# Nettle depends on this, so uninstall it.
#
uninstall_nettle "$@"
echo "Uninstalling GMP:"
cd gmp-$installed_gmp_version
$DO_MAKE_UNINSTALL || exit 1
make distclean || exit 1
cd ..
rm gmp-$installed_gmp_version-done
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded and unpacked version.
#
rm -rf gmp-$installed_gmp_version
rm -rf gmp-$installed_gmp_version.tar.lz
fi
installed_gmp_version=""
fi
}
install_nettle() {
if [ "$NETTLE_VERSION" -a ! -f nettle-$NETTLE_VERSION-done ] ; then
echo "Downloading, building, and installing Nettle:"
[ -f nettle-$NETTLE_VERSION.tar.gz ] || curl -L -O https://ftp.gnu.org/gnu/nettle/nettle-$NETTLE_VERSION.tar.gz || exit 1
$no_build && echo "Skipping installation" && return
gzcat nettle-$NETTLE_VERSION.tar.gz | tar xf - || exit 1
cd nettle-$NETTLE_VERSION
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
make $MAKE_BUILD_OPTS || exit 1
$DO_MAKE_INSTALL || exit 1
cd ..
touch nettle-$NETTLE_VERSION-done
fi
}
uninstall_nettle() {
if [ ! -z "$installed_nettle_version" ] ; then
#
# GnuTLS depends on this, so uninstall it.
#
uninstall_gnutls "$@"
echo "Uninstalling Nettle:"
cd nettle-$installed_nettle_version
$DO_MAKE_UNINSTALL || exit 1
make distclean || exit 1
cd ..
rm nettle-$installed_nettle_version-done
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded and unpacked version.
#
rm -rf nettle-$installed_nettle_version
rm -rf nettle-$installed_nettle_version.tar.gz
fi
installed_nettle_version=""
fi
}
install_gnutls() {
if [ "$GNUTLS_VERSION" -a ! -f gnutls-$GNUTLS_VERSION-done ] ; then
#
# GnuTLS requires Nettle.
#
if [ -z $NETTLE_VERSION ]
then
echo "GnuTLS requires Nettle, but you didn't install Nettle" 1>&2
exit 1
fi
echo "Downloading, building, and installing GnuTLS:"
if [[ $GNUTLS_MAJOR_VERSION -ge 3 ]]
then
#
# Starting with GnuTLS 3.x, the tarballs are compressed with
# xz rather than bzip2.
#
[ -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
$no_build && echo "Skipping installation" && return
xzcat gnutls-$GNUTLS_VERSION.tar.xz | tar xf - || exit 1
else
[ -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
$no_build && echo "Skipping installation" && return
bzcat gnutls-$GNUTLS_VERSION.tar.bz2 | tar xf - || exit 1
fi
cd gnutls-$GNUTLS_VERSION
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
make $MAKE_BUILD_OPTS || exit 1
$DO_MAKE_INSTALL || exit 1
cd ..
touch gnutls-$GNUTLS_VERSION-done
fi
}
uninstall_gnutls() {
if [ ! -z "$installed_gnutls_version" ] ; then
echo "Uninstalling GnuTLS:"
cd gnutls-$installed_gnutls_version
$DO_MAKE_UNINSTALL || exit 1
make distclean || exit 1
cd ..
rm gnutls-$installed_gnutls_version-done
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded and unpacked version.
#
rm -rf gnutls-$installed_gnutls_version
rm -rf gnutls-$installed_gnutls_version.tar.bz2
fi
installed_gnutls_version=""
fi
}
install_lua() {
if [ "$LUA_VERSION" -a ! -f lua-$LUA_VERSION-done ] ; then
echo "Downloading, building, and installing Lua:"
[ -f lua-$LUA_VERSION.tar.gz ] || curl -L -O http://www.lua.org/ftp/lua-$LUA_VERSION.tar.gz || exit 1
$no_build && echo "Skipping installation" && return
gzcat lua-$LUA_VERSION.tar.gz | tar xf - || exit 1
cd lua-$LUA_VERSION
make MYCFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" MYLDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" $MAKE_BUILD_OPTS macosx || exit 1
$DO_MAKE_INSTALL || exit 1
cd ..
touch lua-$LUA_VERSION-done
fi
}
uninstall_lua() {
if [ ! -z "$installed_lua_version" ] ; then
echo "Uninstalling Lua:"
#
# Lua has no "make uninstall", so just remove stuff manually.
# There's no configure script, so there's no need for
# "make distclean", either; just do "make clean".
#
(cd /usr/local/bin; $DO_RM -f lua luac)
(cd /usr/local/include; $DO_RM -f lua.h luaconf.h lualib.h lauxlib.h lua.hpp)
(cd /usr/local/lib; $DO_RM -f liblua.a)
(cd /usr/local/man/man1; $DO_RM -f lua.1 luac.1)
cd lua-$installed_lua_version
make clean || exit 1
cd ..
rm lua-$installed_lua_version-done
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded and unpacked version.
#
rm -rf lua-$installed_lua_version
rm -rf lua-$installed_lua_version.tar.gz
fi
installed_lua_version=""
fi
}
install_snappy() {
if [ "$SNAPPY_VERSION" -a ! -f snappy-$SNAPPY_VERSION-done ] ; then