-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathbuildme.sh
executable file
·1608 lines (1393 loc) · 49.9 KB
/
buildme.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
#!/usr/bin/env bash
#
# $Id$
#
# This script builds all binary Perl modules required by Squeezebox Server.
#
# Supported OSes:
#
# Linux (Perl 5.8.8, 5.10.0, 5.12.4, 5.14.1, 5.16.3)
# i386/x86_64 Linux
# ARM Linux
# PowerPC Linux
# Sparc Linux (ReadyNAS)
# Mac OSX
# Under 10.5, builds Universal Binaries for i386/ppc Perl 5.8.8
# Under 10.6, builds Universal Binaries for i386/x86_64 Perl 5.10.0
# Under 10.7, builds for x86_64 Perl 5.12.3 (Lion does not support 32-bit CPUs)
# Under 10.9, builds for x86_64 Perl 5.16
# Under 10.10, builds for x86_64 Perl 5.18
# FreeBSD 7.2 (Perl 5.8.9)
# FreeBSD 8.X,9.X (Perl 5.12.4)
# Solaris
# builds are best done with custom compiled perl and gcc
# using the following PATH=/opt/gcc-5.1.0/bin:/usr/gnu/bin:$PATH
# plus a path to a version of yasm and nasm
#
# Tested versions (to be extended)
# OmniOSCE 151022 LTS (Perl 5.24.1)
#
# Perl 5.12.4/5.14.1 note:
# You should build 5.12.4 using perlbrew and the following command. GCC's stack protector must be disabled
# so the binaries will not be dynamically linked to libssp.so which is not available on some distros.
# NOTE: On 32-bit systems for 5.12 and higher, -D use64bitint should be used. Debian Wheezy (the next release) will
# use Perl 5.12.4 with use64bitint enabled, and hopefully other major distros will follow suit.
#
# perlbrew install perl-5.12.4 -D usethreads -D use64bitint -A ccflags=-fno-stack-protector -A ldflags=-fno-stack-protector
#
# For 64-bit native systems, use:
#
# perlbrew install perl-5.12.4 -D usethreads -A ccflags=-fno-stack-protector -A ldflags=-fno-stack-protector
#
# Require modules to pass tests
RUN_TESTS=1
USE_HINTS=1
CLEAN=1
FLAGS="-fPIC"
# Default is to rename every x86 to i386
RENAME_x86=1
function usage {
cat <<EOF
$0 [args] [target]
-h this help
-c do not run make clean
-i <lmsbase> install modules in lmsbase directory
-p <perlbin > set custom perl binary
-r do not rename all x86 archs to "i386"
-t do not run tests
target: make target - if not specified all will be built
EOF
}
while getopts hci:p:t opt; do
case $opt in
c)
CLEAN=0
;;
i)
LMSBASEDIR=$OPTARG
;;
p)
CUSTOM_PERL=$OPTARG
;;
r)
RENAME_x86=0
;;
t)
RUN_TESTS=0
;;
h)
usage
exit
;;
*)
echo "invalid argument"
usage
exit 1
;;
esac
done
shift $((OPTIND - 1))
echo "RUN_TESTS:$RUN_TESTS CLEAN:$CLEAN USE_HINTS:$USE_HINTS RENAME_x86:$RENAME_x86 target ${1-all}"
OS=`uname`
MACHINE=`uname -m`
if [ "$OS" != "Linux" -a "$OS" != "Darwin" -a "$OS" != "FreeBSD" -a "$OS" != "SunOS" ]; then
echo "Unsupported platform: $OS, please submit a patch or provide us with access to a development system."
exit
fi
# Set default values prior to potential overwrite
# Check to see if CC and CXX are already defined
if [[ ! -z "$CC" ]]; then
GCC="$CC"
else
# Take a guess
GCC=gcc
fi
if [[ ! -z "$CXX" ]]; then
GXX="$CXX"
else
GXX=g++
fi
# This script uses the following precedence for FreeBSD:
# 1. Environment values for CC/CXX/CPP (checks if $CC is already defined)
# 2. Values defined in /etc/make.conf, or
# 3. Stock build chain
if [ "$OS" = "FreeBSD" ]; then
BSD_MAJOR_VER=`uname -r | sed 's/\..*//g'`
BSD_MINOR_VER=`uname -r | sed 's/.*\.//g'`
if [ -f "/etc/make.conf" ]; then
MAKE_CC=`grep ^CC= /etc/make.conf | grep -v CCACHE | grep -v \# | sed 's#CC=##g'`
MAKE_CXX=`grep ^CXX= /etc/make.conf | grep -v CCACHE | grep -v \# | sed 's#CXX=##g'`
MAKE_CPP=`grep ^CPP= /etc/make.conf | grep -v CCACHE | grep -v \# | sed 's#CPP=##g'`
fi
if [[ ! -z "$CC" ]]; then
GCC="$CC"
elif [[ ! -z "$MAKE_CC" ]]; then
GCC="$MAKE_CC"
elif [ $BSD_MAJOR_VER -ge 10 ]; then
# FreeBSD started using clang as the default compiler starting with 10.
GCC=cc
else
GCC=gcc
fi
if [[ ! -z "$CXX" ]]; then
GXX="$CXX"
elif [[ ! -z "$MAKE_CXX" ]]; then
GXX="$MAKE_CXX"
elif [ $BSD_MAJOR_VER -ge 10 ]; then
# FreeBSD started using clang++ as the default compiler starting with 10.
GXX=c++
else
GXX=g++
fi
if [[ ! -z "$CPP" ]]; then
GPP="$CPP"
elif [[ ! -z "$MAKE_CPP" ]]; then
GPP="$MAKE_CPP"
else
GPP=cpp
fi
# Ensure the environment makes use of the desired/specified compilers and
# pre-processor
export CC=$GCC
export CXX=$GXX
export CPP=$GPP
fi
for i in $GCC $GXX rsync make ; do
which $i > /dev/null
if [ $? -ne 0 ] ; then
echo "$i not found - please install it"
exit 1
fi
done
echo "Looks like your compiler is $GCC"
$GCC --version
# This method works for FreeBSD, with "normal" installs of GCC and clang.
CC_TYPE=`$GCC --version | head -1`
# Determine compiler type and version
CC_IS_CLANG=false
CC_IS_GCC=false
# Heavy wizardry begins here
# This uses bash globbing for the If statement
if [[ "$CC_TYPE" =~ "clang" ]]; then
CLANG_MAJOR=`echo "#include <iostream>" | "$GXX" -xc++ -dM -E - | grep '#define __clang_major' | sed 's/.*__\ //g'`
CLANG_MINOR=`echo "#include <iostream>" | "$GXX" -xc++ -dM -E - | grep '#define __clang_minor' | sed 's/.*__\ //g'`
CLANG_PATCH=`echo "#include <iostream>" | "$GXX" -xc++ -dM -E - | grep '#define __clang_patchlevel' | sed 's/.*__\ //g'`
CC_VERSION=`echo "$CLANG_MAJOR"."$CLANG_MINOR"."$CLANG_PATCH" | sed "s#\ *)\ *##g" | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$/&00/'`
CC_IS_CLANG=true
elif [[ "$CC_TYPE" =~ "gcc" || "$CC_TYPE" =~ "GCC" ]]; then
CC_IS_GCC=true
CC_VERSION=`$GCC -dumpfullversion -dumpversion | sed "s#\ *)\ *##g" | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$/&00/'`
else
echo "********************************************** ERROR ***************************************"
echo "*"
echo "* You're not using GCC or clang. Somebody's playing a prank on me."
echo "* Cowardly choosing to abandon build."
echo "*"
echo "********************************************************************************************"
exit 1
fi
if [[ "$CC_IS_GCC" == true && "$CC_VERSION" -lt 40200 ]]; then
echo "********************************************** ERROR ****************************************"
echo "*"
echo "* It looks like you're using GCC earlier than 4.2,"
echo "* Cowardly choosing to abandon build."
echo "* This is because modern ICU requires -std=c99"
echo "*"
echo "********************************************************************************************"
exit 1
fi
if [[ "$CC_IS_CLANG" == true && "$CC_VERSION" -lt 30000 ]]; then
echo "********************************************** ERROR ****************************************"
echo "*"
echo "* It looks like you're using clang earlier than 3.0,"
echo "* Cowardly choosing to abandon build."
echo "* This is because modern ICU requires -std=c99"
echo "*"
echo "********************************************************************************************"
exit 1
fi
if [[ ! -z `echo "#include <iostream>" | "$GXX" -xc++ -dM -E - | grep LIBCPP_VERSION` ]]; then
GCC_LIBCPP=true
elif [[ ! -z `echo "#include <iostream>" | "$GXX" -xc++ -dM -E - | grep __GLIBCXX__` ]]; then
GCC_LIBCPP=false
else
echo "********************************************** NOTICE **************************************"
echo "*"
echo "* Doesn't seem you're using libc++ or lc++ as your c++ library."
echo "* I will assume you're using the GCC stack, and that DBD needs -lstdc++."
echo "*"
echo "********************************************************************************************"
GCC_LIBCPP=false
fi
which yasm > /dev/null
if [ $? -ne 0 ] ; then
which nasm > /dev/null
if [ $? -ne 0 ] ; then
echo "please install either yasm or nasm."
exit 1
fi
fi
if [ "$OS" = "Linux" ]; then
#for i in libgif libz libgd ; do
for i in libz ; do
ldconfig -p | grep "${i}.so" > /dev/null
if [ $? -ne 0 ] ; then
echo "$i not found - please install it"
exit 1
fi
done
for hdr in "zlib.h"; do
hdr_found=$(find /usr/include -name "$hdr");
if [ ! "$hdr_found" ]; then
echo "$hdr not found - please install appropriate development package"
exit 1
fi
done
fi
if [ "$OS" = "FreeBSD" ]; then
#for i in libgif libz libgd ; do
for i in libz ; do
ldconfig -r | grep "${i}.so" > /dev/null #On FreeBSD flag -r should be used, there is no -p
if [ $? -ne 0 ] ; then
echo "$i not found - please install it"
exit 1
fi
done
for hdr in "zlib.h"; do
hdr_found=$(find /usr/include/ -name "$hdr");
if [ ! "$hdr_found" ]; then
echo "$hdr not found - please install appropriate development package"
exit 1
fi
done
fi
find /usr/lib/ -maxdepth 1 | grep libungif
if [ $? -eq 0 ] ; then
echo "ON SOME PLATFORMS (Ubuntu/Debian at least) THE ABOVE LIBRARIES MAY NEED TO BE TEMPORARILY REMOVED TO ALLOW THE BUILD TO WORK"
fi
# figure out OSX version and customize SDK options
OSX_VER=
OSX_FLAGS=
OSX_ARCH=
if [ "$OS" = "Darwin" ]; then
OSX_VER=`/usr/sbin/system_profiler SPSoftwareDataType`
REGEX=' OS X.* (10\.[5-9])'
REGEX2=' OS X.* (10\.1[0-9])'
REGEX3=' macOS (10\.1[0-9])'
if [[ $OSX_VER =~ $REGEX3 ]]; then
OSX_VER=${BASH_REMATCH[1]}
elif [[ $OSX_VER =~ $REGEX ]]; then
OSX_VER=${BASH_REMATCH[1]}
elif [[ $OSX_VER =~ $REGEX2 ]]; then
OSX_VER=${BASH_REMATCH[1]}
else
echo "Unable to determine OSX version"
exit 0
fi
if [ "$OSX_VER" = "10.5" ]; then
# Leopard, build for i386/ppc with support back to 10.4
OSX_ARCH="-arch i386 -arch ppc"
OSX_FLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4"
elif [ "$OSX_VER" = "10.6" ]; then
# Snow Leopard, build for x86_64/i386 with support back to 10.5
OSX_ARCH="-arch x86_64 -arch i386"
OSX_FLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5"
elif [ "$OSX_VER" = "10.7" ]; then
# Lion, build for x86_64 with support back to 10.6
OSX_ARCH="-arch x86_64"
OSX_FLAGS="-isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6"
elif [ "$OSX_VER" = "10.9" ]; then
# Mavericks, build for x86_64 with support back to 10.9
OSX_ARCH="-arch x86_64"
OSX_FLAGS="-mmacosx-version-min=10.9"
elif [ "$OSX_VER" = "10.10" ]; then
# Yosemite, build for x86_64 with support back to 10.10
OSX_ARCH="-arch x86_64"
OSX_FLAGS="-mmacosx-version-min=10.10"
else
OSX_ARCH="-arch x86_64"
OSX_FLAGS="-mmacosx-version-min=$OSX_VER"
fi
fi
# Build dir
BUILD=$PWD/build
PERL_BASE=$BUILD/perl5x
PERL_ARCH=$BUILD/arch/perl5x
# Path to Perl 5.8.8
if [ -x "/usr/bin/perl5.8.8" ]; then
PERL_58=/usr/bin/perl5.8.8
elif [ -x "/usr/local/bin/perl5.8.8" ]; then
PERL_58=/usr/local/bin/perl5.8.8
elif [ -x "$HOME/perl5/perlbrew/perls/perl-5.8.9/bin/perl5.8.9" ]; then
PERL_58=$HOME/perl5/perlbrew/perls/perl-5.8.9/bin/perl5.8.9
elif [ -x "/usr/local/bin/perl5.8.9" ]; then # FreeBSD 7.2
PERL_58=/usr/local/bin/perl5.8.9
fi
if [ $PERL_58 ]; then
PERL_BIN=$PERL_58
PERL_MINOR_VER=8
fi
# Path to Perl 5.10.0
if [ -x "/usr/bin/perl5.10.0" ]; then
PERL_510=/usr/bin/perl5.10.0
elif [ -x "/usr/local/bin/perl5.10.0" ]; then
PERL_510=/usr/local/bin/perl5.10.0
elif [ -x "/usr/local/bin/perl5.10.1" ]; then # FreeBSD 8.2
PERL_510=/usr/local/bin/perl5.10.1
fi
if [ $PERL_510 ]; then
PERL_BIN=$PERL_510
PERL_MINOR_VER=10
fi
# Path to Perl 5.12
if [ "$OSX_VER" = "10.9" ]; then
echo "Ignoring Perl 5.12 - we want 5.16 on Mavericks"
elif [ -x "/usr/bin/perl5.12.4" ]; then
PERL_512=/usr/bin/perl5.12.4
elif [ -x "/usr/local/bin/perl5.12.4" ]; then
PERL_512=/usr/local/bin/perl5.12.4
elif [ -x "/usr/local/bin/perl5.12.4" ]; then # Also FreeBSD 8.2
PERL_512=/usr/local/bin/perl5.12.4
elif [ -x "$HOME/perl5/perlbrew/perls/perl-5.12.4/bin/perl5.12.4" ]; then
PERL_512=$HOME/perl5/perlbrew/perls/perl-5.12.4/bin/perl5.12.4
elif [ -x "/usr/bin/perl5.12" ]; then
# OSX Lion uses this path
PERL_512=/usr/bin/perl5.12
fi
if [ $PERL_512 ]; then
PERL_BIN=$PERL_512
PERL_MINOR_VER=12
fi
# Path to Perl 5.14.1
if [ -x "$HOME/perl5/perlbrew/perls/perl-5.14.1/bin/perl5.14.1" ]; then
PERL_514=$HOME/perl5/perlbrew/perls/perl-5.14.1/bin/perl5.14.1
fi
if [ $PERL_514 ]; then
PERL_BIN=$PERL_514
PERL_MINOR_VER=14
fi
# Path to Perl 5.16
if [ "$OSX_VER" = "10.10" ]; then
echo "Ignoring Perl 5.16 - we want 5.18 on Yosemite"
elif [ -x "/usr/bin/perl5.16" ]; then
PERL_516=/usr/bin/perl5.16
elif [ -x "/usr/bin/perl5.16.3" ]; then
PERL_516=/usr/bin/perl5.16.3
fi
if [ $PERL_516 ]; then
PERL_BIN=$PERL_516
PERL_MINOR_VER=16
fi
# Path to Perl 5.18
if [ -x "/usr/bin/perl5.18" ]; then
PERL_518=/usr/bin/perl5.18
fi
# defined on the command line - no detection yet
if [ $PERL_518 ]; then
PERL_BIN=$PERL_518
PERL_MINOR_VER=18
fi
# defined on the command line - no detection yet
if [ $PERL_520 ]; then
PERL_BIN=$PERL_520
PERL_MINOR_VER=20
fi
# Path to Perl 5.22
if [ -x "/usr/bin/perl5.22.1" ]; then
PERL_522=/usr/bin/perl5.22.1
fi
if [ $PERL_522 ]; then
PERL_BIN=$PERL_522
PERL_MINOR_VER=22
fi
# Path to Perl 5.24
if [ -x "/usr/bin/perl5.24.1" ]; then
PERL_524=/usr/bin/perl5.24.1
fi
if [ $PERL_524 ]; then
PERL_BIN=$PERL_524
PERL_MINOR_VER=24
fi
# Path to Perl 5.26
if [ -x "/usr/bin/perl5.26.0" ]; then
PERL_526=/usr/bin/perl5.26.0
fi
if [ $PERL_526 ]; then
PERL_BIN=$PERL_526
PERL_MINOR_VER=26
fi
# try to use default perl version
if [ "$PERL_BIN" = "" -o "$CUSTOM_PERL" != "" ]; then
if [ "$CUSTOM_PERL" = "" ]; then
PERL_BIN=`which perl`
PERL_VERSION=`perl -MConfig -le '$Config{version} =~ /(\d+.\d+)\./; print $1'`
else
PERL_BIN=$CUSTOM_PERL
PERL_VERSION=`$CUSTOM_PERL -MConfig -le '$Config{version} =~ /(\d+.\d+)\./; print $1'`
fi
if [[ "$PERL_VERSION" =~ "5." ]]; then
PERL_MINOR_VER=`echo "$PERL_VERSION" | sed 's/.*\.//g'`
else
echo "Failed to find supported Perl version for '$PERL_BIN'"
exit
fi
fi
# We have found Perl, so get system arch, according to Perl
RAW_ARCH=`$PERL_BIN -MConfig -le 'print $Config{archname}'`
# Strip out extra -gnu on Linux for use within this build script
ARCH=`echo $RAW_ARCH | sed 's/gnu-//' | sed 's/armv.*?-/arm-/' `
# Default behavior is to rename all x86 architectures to i386
if [ $RENAME_x86 -eq 1 ]; then
ARCH=`echo "$ARCH" | sed 's/^i[3456]86-/i386-/'`
fi
echo "Building for $OS / $ARCH"
echo "Building with Perl 5.$PERL_MINOR_VER at $PERL_BIN"
PERL_BASE=$BUILD/5.$PERL_MINOR_VER
PERL_ARCH=$BUILD/arch/5.$PERL_MINOR_VER
# FreeBSD's make sucks
if [ "$OS" = "FreeBSD" ]; then
if [ ! -x /usr/local/bin/gmake ]; then
echo "ERROR: Please install GNU make (gmake)"
exit
fi
export MAKE=/usr/local/bin/gmake
elif [ "$OS" = "SunOS" ]; then
if [ ! -x /usr/bin/gmake ]; then
echo "ERROR: Please install GNU make (gmake)"
exit
fi
export MAKE=/usr/bin/gmake
else
# Support a newer make if available, needed on ReadyNAS
if [ -x /usr/local/bin/make ]; then
export MAKE=/usr/local/bin/make
else
export MAKE=/usr/bin/make
fi
fi
# Clean up
if [ $CLEAN -eq 1 ]; then
rm -rf $BUILD/arch
fi
mkdir -p $PERL_ARCH
# $1 = args
# $2 = file
function tar_wrapper {
echo "tar $1 $2"
tar $1 "$2"
echo "tar done"
}
# $1 = module to build
# $2 = Makefile.PL arg(s)
# $3 = run tests if 1 - default to $RUN_TESTS
# $4 = make clean if 1 - default to $CLEAN
# $5 = use hints if 1 - default to $USE_HINTS
function build_module {
module=$1
makefile_args=$2
local_run_tests=${3-$RUN_TESTS}
local_clean=${4-$CLEAN}
local_use_hints=${5-$USE_HINTS}
echo "build_module run tests:$local_run_tests clean:$local_clean hints $local_use_hints $module $makefile_args"
if [ ! -d $module ]; then
if [ ! -f "${module}.tar.gz" ]; then
echo "ERROR: cannot find source code archive ${module}.tar.gz"
echo "Please download all source files from https://github.com/Logitech/slimserver-vendor"
exit
fi
tar_wrapper zxf "${module}.tar.gz"
fi
cd "${module}"
if [ $local_use_hints -eq 1 ]; then
# Always copy in our custom hints for OSX
cp -R ../hints .
fi
if [ $PERL_BIN ]; then
export PERL5LIB=$PERL_BASE/lib/perl5
$PERL_BIN Makefile.PL INSTALL_BASE=$PERL_BASE $makefile_args
if [ $local_run_tests -eq 1 ]; then
$MAKE test
else
$MAKE
fi
if [ $? != 0 ]; then
if [ $local_run_tests -eq 1 ]; then
echo "make test failed, aborting"
else
echo "make failed, aborting"
fi
exit $?
fi
$MAKE install
if [ $local_clean -eq 1 ]; then
$MAKE clean
fi
fi
cd ..
rm -rf $module
}
function build_all {
build Audio::Scan
build Class::C3::XS
build Class::XSAccessor
build Compress::Raw::Zlib
# DBD::SQLite builds DBI, so don't need it here as well.
# build DBI
# build DBD::mysql
build DBD::SQLite
build Digest::SHA1
build EV
build Encode::Detect
build HTML::Parser
# XXX - Image::Scale requires libjpeg-turbo - which requires nasm 2.07 or later (install from http://www.macports.org/)
build Image::Scale
build IO::AIO
build IO::Interface
# build IO::Socket::SSL
build JSON::XS
build Linux::Inotify2
build Mac::FSEvents
build Media::Scan
build MP3::Cut::Gapless
build Sub::Name
build Template
build XML::Parser
build YAML::LibYAML
# build Font::FreeType
# build Locale::Hebrew
}
function build {
case "$1" in
Class::C3::XS)
if [ $PERL_MINOR_VER -eq 8 ]; then
tar_wrapper zxf Class-C3-XS-0.11.tar.gz
cd Class-C3-XS-0.11
patch -p0 < ../Class-C3-XS-no-ckWARN.patch
cp -R ../hints .
export PERL5LIB=$PERL_BASE/lib/perl5
$PERL_BIN Makefile.PL INSTALL_BASE=$PERL_BASE $2
if [ $RUN_TESTS -eq 1 ]; then
$MAKE test
else
$MAKE
fi
if [ $? != 0 ]; then
if [ $RUN_TESTS -eq 1 ]; then
echo "make test failed, aborting"
else
echo "make failed, aborting"
fi
exit $?
fi
$MAKE install
if [ $CLEAN -eq 1 ]; then
$MAKE clean
fi
cd ..
rm -rf Class-C3-XS-0.11
fi
;;
Class::XSAccessor)
if [ $PERL_MINOR_VER -ge 16 ]; then
build_module Class-XSAccessor-1.18
else
if [[ "$CC_IS_CLANG" == true ]]; then
build_module Class-XSAccessor-1.18
else
build_module Class-XSAccessor-1.05
fi
fi
;;
Compress::Raw::Zlib)
if [ $PERL_MINOR_VER -eq 8 -o $PERL_MINOR_VER -eq 10 ]; then
build_module Compress-Raw-Zlib-2.033
fi
;;
DBI)
if [ $PERL_MINOR_VER -ge 18 ]; then
build_module DBI-1.628
elif [ $PERL_MINOR_VER -eq 8 ]; then
build_module DBI-1.616 "" 0
else
build_module DBI-1.616
fi
;;
DBD::SQLite)
# Build DBI before DBD::SQLite so that DBD::SQLite is built
# against _our_ DBI, not one already present on the system.
build DBI
# build ICU, but only if it doesn't exist in the build dir,
# because it takes so damn long on slow platforms
if [ ! -f build/lib/libicudata_s.a ]; then
tar_wrapper zxf icu4c-58_2-src.tgz
cd icu/source
# Need to patch ICU to adapt to removal of xlocale.h on some platforms.
patch -p0 < ../../icu58_patches/digitlst.cpp.patch
. ../../update-config.sh
if [ "$OS" = 'Darwin' ]; then
ICUFLAGS="$FLAGS $OSX_ARCH $OSX_FLAGS -DU_USING_ICU_NAMESPACE=0 -DU_CHARSET_IS_UTF8=1" # faster code for native UTF-8 systems
ICUOS="MacOSX"
elif [ "$OS" = 'Linux' ]; then
ICUFLAGS="$FLAGS -DU_USING_ICU_NAMESPACE=0"
ICUOS="Linux"
elif [ "$OS" = 'SunOS' ]; then
ICUFLAGS="$FLAGS -D_XPG6 -DU_USING_ICU_NAMESPACE=0"
ICUOS="Solaris/GCC"
elif [ "$OS" = 'FreeBSD' ]; then
ICUFLAGS="$FLAGS -DU_USING_ICU_NAMESPACE=0"
ICUOS="FreeBSD"
for i in ../../icu58_patches/freebsd/patch-*;
do patch -p0 < $i; done
fi
CFLAGS="$ICUFLAGS" CXXFLAGS="$ICUFLAGS" LDFLAGS="$FLAGS $OSX_ARCH $OSX_FLAGS" \
./runConfigureICU $ICUOS --prefix=$BUILD --enable-static --with-data-packaging=archive
$MAKE
if [ $? != 0 ]; then
echo "make failed"
exit $?
fi
$MAKE install
cd ../..
rm -rf icu
# Symlink static versions of libraries
cd build/lib
ln -sf libicudata.a libicudata_s.a
ln -sf libicui18n.a libicui18n_s.a
ln -sf libicuuc.a libicuuc_s.a
cd ../..
fi
# Point to data directory for test suite
export ICU_DATA=$BUILD/share/icu/58.2
# Replace huge data file with smaller one containing only our collations
rm -f $BUILD/share/icu/58.2/icudt58*.dat
cp icudt58*.dat $BUILD/share/icu/58.2
# Custom build for ICU support
tar_wrapper zxf DBD-SQLite-1.58.tar.gz
cd DBD-SQLite-1.58
if [[ "$GCC_LIBCPP" == true ]] ; then
# Need this because GLIBCXX uses -lstdc++, but LIBCPP uses -lc++
patch -p0 < ../DBD-SQLite-ICU-libcpp.patch
else
patch -p0 < ../DBD-SQLite-ICU.patch
fi
if [ "$OS" = 'SunOS' ]; then
patch -p0 < ../DBD-SQLite-XOPEN.patch
fi
cp -R ../hints .
if [ $PERL_MINOR_VER -eq 8 ]; then
# Running 5.8
export PERL5LIB=$PERL_BASE/lib/perl5
$PERL_BIN Makefile.PL INSTALL_BASE=$PERL_BASE $2
if [ "$OS" = 'Darwin' ]; then
# OSX does not seem to properly find -lstdc++, so we need to hack the Makefile to add it
$PERL_BIN -p -i -e "s{^LDLOADLIBS =.+}{LDLOADLIBS = -L$PWD/../build/lib -licudata_s -licui18n_s -licuuc_s -lstdc++}" Makefile
fi
$MAKE test
if [ $? != 0 ]; then
echo "make test failed, aborting"
exit $?
fi
$MAKE install
if [ $CLEAN -eq 1 ]; then
$MAKE clean
fi
cd ..
rm -rf DBD-SQLite-1.58
else
cd ..
build_module DBD-SQLite-1.58
fi
;;
Digest::SHA1)
build_module Digest-SHA1-2.13
;;
EV)
build_module common-sense-2.0
# custom build to apply pthread patch
export PERL_MM_USE_DEFAULT=1
tar_wrapper zxf EV-4.03.tar.gz
cd EV-4.03
patch -p0 < ../EV-llvm-workaround.patch # patch to avoid LLVM bug 9891
if [ "$OS" = "Darwin" ]; then
if [ $PERL_58 ]; then
patch -p0 < ../EV-fixes.patch # patch to disable pthreads and one call to SvREADONLY
fi
fi
cp -R ../hints .
cd ..
build_module EV-4.03
export PERL_MM_USE_DEFAULT=
;;
Encode::Detect)
if [[ "$OS" == "FreeBSD" && `sysctl -n security.jail.jailed` == 1 && $PERL_MINOR_VER -le 10 ]]; then
# Tests fail in jails with old Perl
build_module Data-Dump-1.19 "" 0
else
build_module Data-Dump-1.19
fi
build_module ExtUtils-CBuilder-0.260301
build_module Module-Build-0.35 "" 0
build_module Encode-Detect-1.00
;;
HTML::Parser)
build_module HTML-Tagset-3.20
build_module HTML-Parser-3.68
;;
Image::Scale)
build_libjpeg
build_libpng
build_giflib
build_module Test-NoWarnings-1.02 "" 0
build_module Image-Scale-0.14 "--with-jpeg-includes="$BUILD/include" --with-jpeg-static \
--with-png-includes="$BUILD/include" --with-png-static \
--with-gif-includes="$BUILD/include" --with-gif-static"
;;
IO::AIO)
if [ "$OS" != "FreeBSD" ]; then
build_module common-sense-2.0
# Don't use the darwin hints file, it breaks if compiled on Snow Leopard with 10.5 (!?)
build_module IO-AIO-3.71 "" 0 $CLEAN 0
fi
;;
IO::Interface)
# The IO::Interface tests erroneously require that lo0 be 127.0.0.1. This can be tough in jails.
if [[ "$OS" == "FreeBSD" && `sysctl -n security.jail.jailed` == 1 ]]; then
build_module IO-Interface-1.06 "" 0
else
build_module IO-Interface-1.06
fi
;;
IO::Socket::SSL)
build_module Test-NoWarnings-1.02 "" 0
build_module Net-IDN-Encode-2.400
tar_wrapper zxf Net-SSLeay-1.82.tar.gz
cd Net-SSLeay-1.82
patch -p0 < ../NetSSLeay-SunOS-NoPrompt.patch
cd ..
build_module Net-SSLeay-1.82
tar_wrapper zxf IO-Socket-SSL-2.067.tar.gz
cd IO-Socket-SSL-2.067
patch -p0 < ../IOSocketSSL-NoPrompt-SunOS.patch
cd ..
build_module IO-Socket-SSL-2.067
;;
JSON::XS)
build_module common-sense-2.0
if [ $PERL_MINOR_VER -ge 18 ]; then
build_module JSON-XS-2.34
else
build_module JSON-XS-2.3
fi
;;
Linux::Inotify2)
if [ "$OS" = "Linux" ]; then
build_module common-sense-2.0
build_module Linux-Inotify2-1.21
fi
;;
Locale::Hebrew)
build_module Locale-Hebrew-1.04
;;
Mac::FSEvents)
if [ "$OS" = 'Darwin' ]; then
build_module Mac-FSEvents-0.04 "" 0
fi
;;
Sub::Name)
build_module Sub-Name-0.05
;;
YAML::LibYAML)
# Needed because LibYAML 0.35 used . in @INC (not permitted in Perl 5.26)
# Needed for Debian's Perl 5.24 as well, for the same reason
if [ $PERL_MINOR_VER -ge 24 ]; then
build_module YAML-LibYAML-0.65
elif [ $PERL_MINOR_VER -ge 16 ]; then
build_module YAML-LibYAML-0.35 "" 0
else
build_module YAML-LibYAML-0.35
fi
;;
Audio::Scan)
build_module Sub-Uplevel-0.22 "" 0
build_module Tree-DAG_Node-1.06 "" 0
build_module Test-Warn-0.23 "" 0
build_module Audio-Scan-1.02
;;
MP3::Cut::Gapless)
build_module Audio-Cuefile-Parser-0.02
build_module MP3-Cut-Gapless-0.03
;;
Template)
# Template, custom build due to 2 Makefile.PL's
tar_wrapper zxf Template-Toolkit-2.21.tar.gz
cd Template-Toolkit-2.21
cp -R ../hints .
cp -R ../hints ./xs
cd ..
# minor test failure, so don't test
build_module Template-Toolkit-2.21 "TT_ACCEPT=y TT_EXAMPLES=n TT_EXTRAS=n" 0
;;
DBD::mysql)
# Build libmysqlclient
tar_wrapper jxf mysql-5.1.37.tar.bz2
cd mysql-5.1.37
. ../update-config.sh
CC=gcc CXX=gcc \
CFLAGS="-O3 -fno-omit-frame-pointer $FLAGS $OSX_ARCH $OSX_FLAGS" \
CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti $FLAGS $OSX_ARCH $OSX_FLAGS" \
./configure --prefix=$BUILD \
--disable-dependency-tracking \
--enable-thread-safe-client \
--without-server --disable-shared --without-docs --without-man
make
if [ $? != 0 ]; then
echo "make failed"
exit $?
fi
make install
cd ..
rm -rf mysql-5.1.37
# DBD::mysql custom, statically linked with libmysqlclient
tar_wrapper zxf DBD-mysql-3.0002.tar.gz
cd DBD-mysql-3.0002
cp -R ../hints .
mkdir mysql-static
cp $BUILD/lib/mysql/libmysqlclient.a mysql-static
cd ..
build_module DBD-mysql-3.0002 "--mysql_config=$BUILD/bin/mysql_config --libs=\"-Lmysql-static -lmysqlclient -lz -lm\""
;;
XML::Parser)
# build expat
tar_wrapper zxf expat-2.0.1.tar.gz
cd expat-2.0.1/conftools
. ../../update-config.sh
cd ..
CFLAGS="$FLAGS $OSX_ARCH $OSX_FLAGS" \
LDFLAGS="$FLAGS $OSX_ARCH $OSX_FLAGS" \
./configure --prefix=$BUILD \
--disable-dependency-tracking
$MAKE
if [ $? != 0 ]; then
echo "make failed"
exit $?
fi
$MAKE install
cd ..
# Symlink static versions of libraries to avoid OSX linker choosing dynamic versions
cd build/lib
ln -sf libexpat.a libexpat_s.a
cd ../..