-
Notifications
You must be signed in to change notification settings - Fork 12
/
configure
executable file
·1371 lines (1225 loc) · 53.9 KB
/
configure
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/sh
# Autoconf is ugly and complex. This is still ugly, but at least it's
# simple, and should be good enough for most plausible build cases.
# (Trying to build on Solaris crushed that belief -- it works now, but
# this gets uglier for every platform. I will probably be forced to
# adopt autoconf in the end, sadly.)
# ---------- Utility definitions ----------
# Moderately portable echo
case "`echo 'x\c'`" in
'x\c') echo_n="echo -n"; nobr= ;;
*) echo_n="echo"; nobr="\c" ;;
esac
# Portable replacement for !
not() {
if $1; then false; else true; fi
}
# ---------- Program begins here ----------
srcdir=$(cd $(dirname "$0"); pwd)
builddir=${srcdir}
# Default options
PREFIX=/usr/local
if [ -z "$MAKE" ]; then MAKE=make; fi
if [ -z "$AR" ]; then AR=ar; fi
if [ -z "$RANLIB" ]; then RANLIB=ranlib; fi
UNSUPPORTED_COMPILER=false
USE_CPU_GFX=true
VECTORIZE=false
VECTORIZE_LEVEL=0
FASTMATH=-ffast-math
WERROR=""
CXXSTD="-std=c++98"
STRICT=
INTERNAL_LIBS=false
INTERNAL_SDL=false
INTERNAL_SDL_IMAGE=false
INTERNAL_SDL_MIXER=false
INTERNAL_SDL_TTF=false
INTERNAL_BZIP2=false
INTERNAL_SMPEG=false
INTERNAL_FREETYPE=false
INTERNAL_LIBPNG=false
INTERNAL_LIBJPEG=false
INTERNAL_OGGLIBS=false
EXPLICIT_OGGLIBS=false
SDL_CONFIG=sdl-config
SMPEG_CONFIG=smpeg-config
FREETYPE_CONFIG=freetype-config
VERSION=`awk '/define VER_NUMBER/ {print $3}' version.h | sed s/-en$//`
DISTCLEAN_OTHER=
CMAKE=false
# Parse options
prev=
for opt
do
if test -n "$prev"; then
eval "$prev=\$opt"
prev=
continue
fi
arg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
case $opt in
--cmake | -cmake)
CMAKE=true ;;
--cmake=* | -cmake=*)
CMAKE=$arg ;;
--cmake-config | -cmake-config)
CMAKE=config
;;
--prefix=* | -prefix=*)
PREFIX=$arg ;;
--prefix | -prefix)
prev=PREFIX
;;
--platform=* | -platform=*)
PLATFORM=$arg ;;
--platform | -platform)
prev=PLATFORM
;;
--make=* | -make=*)
MAKE=$arg ;;
--make | -make)
prev=MAKE
;;
--std=* | -std=*)
CXXSTD=-std=$arg ;;
--strict | -strict)
STRICT="-Wall -Wextra -Wno-unused-parameter -Wvla" ;;
--pedantic | -pedantic)
STRICT+=" -pedantic" ;;
--werror | -werror)
WERROR="-Werror"
;;
--no-werror | -no-werror)
WERROR=""
;;
--unsupported-compiler | -unsupported-compiler)
UNSUPPORTED_COMPILER=true ;;
--unsupported-compiler=* | -unsupported-compiler=*)
UNSUPPORTED_COMPILER=$arg
;;
--no-cpu-gfx | -no-cpu-gfx)
USE_CPU_GFX=false ;;
--novectorize | -novectorize)
VECTORIZE=false ;;
--vectorize | -vectorize)
VECTORIZE=true ;;
--vectorize-verbose | -vectorize-verbose)
VECTORIZE_LEVEL=3 ;;
--vectorize-verbose=* | -vectorize-verbose=*)
VECTORIZE_LEVEL=$arg
;;
--sanitizer=*)
SANITIZER=$arg
;;
--enable-internal-libs | -enable-internal-libs | --with-internal-libs | -with-internal-libs)
INTERNAL_LIBS=true ;;
--disable-internal-libs | -disable-internal-libs | --without-internal-libs | -without-internal-libs | --no-internal-libs | -no-internal-libs)
INTERNAL_LIBS=false ;;
--internal-libs=* | -internal-libs=*)
INTERNAL_LIBS=$arg ;;
--internal-libs | -internal-libs)
prev=INTERNAL_LIBS
;;
--enable-internal-sdl | -enable-internal-sdl | --with-internal-sdl | -with-internal-sdl)
INTERNAL_SDL=true ;;
--disable-internal-sdl | -disable-internal-sdl | --without-internal-sdl | -without-internal-sdl | --no-internal-sdl | -no-internal-sdl)
INTERNAL_SDL=false ;;
--internal-sdl=* | -internal-sdl=*)
INTERNAL_SDL=$arg ;;
--internal-sdl | -internal-sdl)
prev=INTERNAL_SDL
;;
--enable-internal-sdl?image | -enable-internal-sdl?image | --with-internal-sdl?image | -with-internal-sdl?image | --enable-internal-sdlimage | -enable-internal-sdlimage | --with-internal-sdlimage | -with-internal-sdlimage)
INTERNAL_SDL_IMAGE=true ;;
--disable-internal-sdl?image | -disable-internal-sdl?image | --without-internal-sdl?image | -without-internal-sdl?image | --no-internal-sdl?image | -no-internal-sdl?image | --disable-internal-sdlimage | -disable-internal-sdlimage | --without-internal-sdlimage | -without-internal-sdlimage | --no-internal-sdlimage | -no-internal-sdlimage)
INTERNAL_SDL_IMAGE=false ;;
--internal-sdl?image=* | -internal-sdl?image=* | --internal-sdlimage=* | -internal-sdlimage=*)
INTERNAL_SDL_IMAGE=$arg ;;
--internal-sdl?image | -internal-sdl?image | --internal-sdlimage | -internal-sdlimage)
prev=INTERNAL_SDL_IMAGE
;;
--internal-all-images)
INTERNAL_SDL_IMAGE=true
INTERNAL_LIBPNG=true
INTERNAL_LIBJPEG=true
;;
--enable-internal-sdl?mixer | -enable-internal-sdl?mixer | --with-internal-sdl?mixer | -with-internal-sdl?mixer | --enable-internal-sdlmixer | -enable-internal-sdlmixer | --with-internal-sdlmixer | -with-internal-sdlmixer)
INTERNAL_SDL_MIXER=true ;;
--disable-internal-sdl?mixer | -disable-internal-sdl?mixer | --without-internal-sdl?mixer | -without-internal-sdl?mixer | --no-internal-sdl?mixer | -no-internal-sdl?mixer | --disable-internal-sdlmixer | -disable-internal-sdlmixer | --without-internal-sdlmixer | -without-internal-sdlmixer | --no-internal-sdlmixer | -no-internal-sdlmixer)
INTERNAL_SDL_MIXER=false ;;
--internal-sdl?mixer=* | -internal-sdl?mixer=* | --internal-sdlmixer=* | -internal-sdlmixer=*)
INTERNAL_SDL_MIXER=$arg ;;
--internal-sdl?mixer | -internal-sdl?mixer | --internal-sdlmixer | -internal-sdlmixer)
prev=INTERNAL_SDL_MIXER
;;
--internal-all-mixers)
INTERNAL_SDL_MIXER=true
INTERNAL_OGGLIBS=true
;;
--enable-internal-bz* | -enable-internal-bz* | --with-internal-bz* | -with-internal-bz*)
INTERNAL_BZIP2=true ;;
--disable-internal-bz* | -disable-internal-bz* | --without-internal-bz* | -without-internal-bz* | --no-internal-bz* | -no-internal-bz*)
INTERNAL_BZIP2=false ;;
--internal-bz*=* | -internal-bz*=*)
INTERNAL_BZIP2=$arg ;;
--internal-bz* | -internal-bz*)
prev=INTERNAL_BZIP2
;;
--enable-internal-smpeg | -enable-internal-smpeg | --with-internal-smpeg | -with-internal-smpeg)
INTERNAL_SMPEG=true ;;
--disable-internal-smpeg | -disable-internal-smpeg | --without-internal-smpeg | -without-internal-smpeg | --no-internal-smpeg | -no-internal-smpeg)
INTERNAL_SMPEG=false ;;
--internal-smpeg=* | -internal-smpeg=*)
INTERNAL_SMPEG=$arg ;;
--internal-smpeg | -internal-smpeg)
prev=INTERNAL_SMPEG
;;
--enable-internal-freetype | -enable-internal-freetype | --with-internal-freetype | -with-internal-freetype)
INTERNAL_FREETYPE=true ;;
--disable-internal-freetype | -disable-internal-freetype | --without-internal-freetype | -without-internal-freetype | --no-internal-freetype | -no-internal-freetype)
INTERNAL_FREETYPE=false ;;
--internal-freetype=* | -internal-freetype=*)
INTERNAL_FREETYPE=$arg ;;
--internal-freetype | -internal-freetype)
prev=INTERNAL_FREETYPE
;;
--enable-internal-sdl?ttf | -enable-internal-sdl?ttf | --with-internal-sdl?ttf | -with-internal-sdl?ttf | --enable-internal-sdlttf | -enable-internal-sdlttf | --with-internal-sdlttf | -with-internal-sdlttf)
INTERNAL_SDL_TTF=true ;;
--disable-internal-sdl?ttf | -disable-internal-sdl?ttf | --without-internal-sdl?ttf | -without-internal-sdl?ttf | --no-internal-sdl?ttf | -no-internal-sdl?ttf | --disable-internal-sdlttf | -disable-internal-sdlttf | --without-internal-sdlttf | -without-internal-sdlttf | --no-internal-sdlttf | -no-internal-sdlttf)
INTERNAL_SDL_TTF=false ;;
--internal-sdl?ttf=* | -internal-sdl?ttf=* | --internal-sdlttf=* | -internal-sdlttf=*)
INTERNAL_SDL_TTF=$arg ;;
--internal-sdl?ttf | -internal-sdl?ttf | --internal-sdlttf | -internal-sdlttf)
prev=INTERNAL_SDL_TTF
;;
-\? | -h | -help | --help)
cat <<-__ENDHELP
Usage: $0 <options>
Options:
--help display this message
--prefix=DIR install in prefix DIR (default is /usr/local)
--make=NAME use GNU make executable with the given name
--std=STD c++ compiles with -std=STD (default is c++98)
--strict compile with -Wall -Wextra -Wvla
(note: g++ already uses -Wall)
--pedantic compile with -pedantic
--unsupported-compiler don't check for known compilers
--no-werror don't compile with -Werror
--no-cpu-gfx don't compile with custom intrinsic graphics
routines (normally compiled for x86/PPC if GCC 4.3+)
--vectorize try to use compiler vectorization (requires GCC 4+)
--novectorize don't use compiler vectorization (default)
--vectorize-verbose[=(1-5)] set vectorization verbosity level (def 0)
--sanitizer=(undefined|address|leak) compile with sanitization enabled
Library options (force compilation of included dependencies):
--with-internal-libs don't check for any system libraries
--with-internal-sdl skip check for system libSDL
--with-internal-sdl-image skip check for system libSDL_image
--with-internal-sdl-mixer skip check for system libSDL_mixer
--with-internal-sdl-ttf skip check for system libSDL_ttf
--with-internal-bzip2 skip check for system libbz2
--with-internal-smpeg skip check for system libsmpeg
--with-internal-freetype skip check for system libfreetype
__ENDHELP
exit 0
;;
*)
echo "Ignoring unknown option $opt"
;;
esac
done
if test -n "$prev"; then
opt=--`echo $prev | tr '[A-Z]_' '[a-z]-'`
echo "Error: missing argument to $opt" >&2
exit 2
fi
fetch_EPS() {
echo "Downloading EPS content..."
if ./fetch-eps-content.sh >/dev/null 2>&1; then
:
else
echo "EPS content download failed"
exit 1
fi
# If we got here, we are going to give control to the EPS config script. So, if it returns an error, please exit.
# NOT TESTED
set -e
}
# 3 ways to signal we want to use cmake
# The first way simply allows cmake to do its thing assuming the same target as the host. NOTE Should be static.
# The second way runs a script within the EPS repo which presents the current target options and allows the user to choose.
# The third way allows the user to pass a specific value (the same as presented in the second way) if he knows what he wants (or is a robot. beep boop.)
$echo_n "Checking for requested cmake usage... ${nobr}"
case "$CMAKE" in
false) echo "False" ;;
# true) echo "True - auto-detect" ; fetch_EPS ; eps/config.sh auto ;;
# config) echo "True - begin config" ; fetch_EPS ; eps/config.sh config ;;
*) echo "True" ; fetch_EPS ; eps/config.sh "$CMAKE" ; exit 0 ;; # We'll just handle "true" and "config" from within config.sh
esac
internalise_SDL() {
INTERNAL_SDL=true
INTERNAL_SDL_IMAGE=true
INTERNAL_SDL_MIXER=true
INTERNAL_SDL_TTF=true
INTERNAL_SMPEG=true
SDL_CONFIG=./extlib/bin/sdl-config
SDLOTHERCONFIG=--disable-rpath
SMPEG_CONFIG=./extlib/bin/smpeg-config
}
if $INTERNAL_LIBS
then
internalise_SDL
INTERNAL_BZIP2=true
INTERNAL_FREETYPE=true
INTERNAL_LIBPNG=true
INTERNAL_LIBJPEG=true
INTERNAL_OGGLIBS=true
elif $INTERNAL_SDL
then
# If the main SDL is internal, the subsidiary libraries must be
# too.
internalise_SDL
fi
if $INTERNAL_FREETYPE
then
# If Freetype is internal, SDL_ttf must be too.
INTERNAL_SDL_TTF=true
fi
echo "Configuring ONScripter-EN $VERSION"
# Platform
$echo_n "Checking platform type... ${nobr}"
if [ -n "$PLATFORM" ]
then
PLATFORM=`$echo_n "$PLATFORM${nobr}" | tr '[:upper:]' '[:lower:]'`
if ./config.sub $PLATFORM >/dev/null 2>&1; then PLATFORM=`./config.sub $PLATFORM`; fi
else
PLATFORM=`./config.guess`
fi
SYS=Posix
POSIX=Vanilla
case "$PLATFORM" in
*mingw*) echo "MinGW"; SYS=MinGW ;;
*darwin*) echo "Mac OS X"; SYS=MacOSX ;;
*linux*) echo "Linux"; POSIX=Linux ;;
*solaris*) echo "Solaris"; POSIX=Solaris ;;
*freebsd*) echo "FreeBSD"; POSIX=FreeBSD ;;
*netbsd*) echo "NetBSD"; POSIX=NetBSD ;;
*openbsd*) echo "OpenBSD"; POSIX=OpenBSD ;;
*) echo "$PLATFORM (unsupported; using vanilla Posix build instructions)" ;;
esac
$echo_n " cpu type... ${nobr}"
ARCH=
case "$PLATFORM" in
*86_64*|amd64*) echo "x86_64"; ARCH=x86_64;;
*86*) ARCH=`expr "x$PLATFORM" : 'x\(.*86\).*'`; \
echo "$ARCH";;
*powerpc*) echo "PowerPC"; ARCH=ppc;;
*) echo "unknown";;
esac
# Compiler (gcc, g++, icpc)
compilerver() {
compiler=$1
__COMPILERVER=
rm -rf .vertest
mkdir .vertest
cd .vertest
cat > ver.c <<-_EOF
#include <stdio.h>
int main(int argc, char** argv) {
int ret = 0;
const char* version;
#if defined(__clang__)
version = __clang_version__;
#elif defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER) || defined(__GNUC__)
version = __VERSION__;
#else
version = "unknown";
ret = -1;
#endif
fprintf(stdout, "%s", version);
return ret;
}
_EOF
$compiler ver.c -o ver >/dev/null 2>&1
__COMPILERVER=`./ver | tr -d '\r\n'`
cd ..
rm -rf .vertest
unset compiler
}
# Make the script detect clang as a supported
# compiler on OpenBSD and FreeBSD (untested
# on FreeBSD, but it ought to work).
# onscripter-en compiles without fail with clang. -grodzio1
case "$POSIX" in
OpenBSD) CC=clang ;;
FreeBSD) CC=clang ;;
esac
if [ -z "$CC" ]; then CC=gcc; fi
if $UNSUPPORTED_COMPILER
then
echo "Unsupported compiler requested; please don't complain if anything doesn't work!"
else
$echo_n "Checking C compiler... ${nobr}"
rm -rf .configtest
mkdir .configtest
cd .configtest
cat > test.c <<-_EOF
#include <stdio.h>
int main(int argc, char** argv) {
int ret = 0;
#if defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER)
fprintf(stdout, "intel");
#elif defined(__clang__)
fprintf(stdout, "clang");
#elif defined(__GNUC__)
fprintf(stdout, "gcc");
#else
fprintf(stdout, "unsupported");
ret = -1;
#endif
return ret;
}
_EOF
$CC test.c -o ctest >/dev/null 2>&1
case $? in
0) CC_TYPE=`./ctest`
compilerver "$CC"
CC_VER=$__COMPILERVER
echo "$CC_TYPE $CC_VER"
;;
*) echo "error" >&2
cat >&2 <<-_ERR
Compiler not recognised, or no compiler found.
Please install a supported C compiler (e.g. gcc). If you already have one installed, try setting the environment variable CC appropriately.
If you want to use an unsupported compiler, set CC appropriately and run configure with the --unsupported-compiler option; you will be on your own if anything doesn't work.
_ERR
exit 1 ;;
esac
cd ..
rm -rf .configtest
fi
if [ -z "$CXX" ]
then case "x$CC_TYPE" in
xgcc | x) CXX=g++ ;;
xclang) CXX=clang++ ;; # same story as with C compiler. -grodzio1
xintel)
if command -v icpx >/dev/null
then
CXX=icpx
else
CXX=icpc
fi
;;
*) CXX=$CC ;;
esac
fi
if not $UNSUPPORTED_COMPILER
then
$echo_n "Checking C++ compiler... ${nobr}"
rm -rf .configtest
mkdir .configtest
cd .configtest
cat > test.cc <<-_EOF
#include <iostream>
int main(int argc, char** argv) {
int ret = 0;
#if defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER)
std::cout << "intel++";
#elif defined(__clang__)
std::cout << "clang++";
#elif defined(__GNUC__)
std::cout << "g++";
#else
std::cout << "unsupported";
ret = -1;
#endif
return ret;
}
_EOF
$CXX test.cc -o cxxtest >/dev/null 2>&1
case $? in
0) CXX_TYPE=`./cxxtest`
compilerver "$CXX"
CXX_VER=$__COMPILERVER
echo "$CXX_TYPE $CXX_VER"
;;
*) echo "error" >&2
cat >&2 <<-_ERR
Compiler not recognised, or no compiler found.
Please install a supported C++ compiler (e.g. g++). If you already have one installed, try setting the environment variable CXX appropriately.
If you want to use an unsupported compiler, set CXX appropriately and run configure with the --unsupported-compiler option; you will be on your own if anything doesn't work.
_ERR
exit 1 ;;
esac
cd ..
rm -rf .configtest
fi
case "$CXX_TYPE" in
g++) CFLAGSEXTRA=-Wall ;;
esac
# compiler sanitization support
SANFLAGS=
if [ -n "$SANITIZER" ]
then
case "$SANITIZER" in
address|leak|undefined)
$echo_n "Using compiler support for '$SANITIZER' sanitizer"
SANFLAGS="-fsanitize=$SANITIZER -fno-sanitize-recover=$SANITIZER"
;;
*) echo "ERROR: unknown sanitizer '$SANITIZER'" >&2
exit 1 ;;
esac
fi
# Auto-vectorization
VECFLAGS=
if $VECTORIZE
then
case "x$ARCH" in
xx86_64) VECFLAGS="-msse2 -mfpmath=sse";;
x*86) VECFLAGS="-msse -mfpmath=sse";;
xppc) VECFLAGS=-maltivec ;;
esac
case "x$CC_TYPE$CC_VER" in
xgcc4.*) VECFLAGS="$FASTMATH -ftree-vectorize $VECFLAGS"
if [ $VECTORIZE_LEVEL != 0 ]
then
VECFLAGS="$VECFLAGS -ftree-vectorizer-verbose=$VECTORIZE_LEVEL"
fi
echo " Auto-vectorization, verbosity level $VECTORIZE_LEVEL"
;;
*) echo " Not GCC 4+, won't try auto-vectorization"
esac
fi
CFLAGSEXTRA="$CFLAGSEXTRA $VECFLAGS"
# determine availability of localtime_r()
rm -rf .configtest
mkdir .configtest
cd .configtest
cat > test.cc <<-_EOF
#include <time.h>
int main(int argc, char**argv){struct tm tm; time_t t = time(NULL); localtime_r( &t, &tm );}
_EOF
$CXX test.cc -o ctest >/dev/null 2>&1
case $? in
0) CFLAGSEXTRA="$CFLAGSEXTRA -DHAVE_LOCALTIME_R"
;;
esac
cd ..
rm -rf .configtest
# Custom graphics using intrinsics (most likely requires GCC 4.3+)
rm -rf .configtest
mkdir .configtest
cd .configtest
if $USE_CPU_GFX
then
case "x$ARCH" in
xx86_64|x*86)
$echo_n "Checking for compiler cpuid support... ${nobr}"
cat > test.cc <<-_EOF
#include <cpuid.h>
unsigned int eax, ebx, ecx, edx; int main(int argc, char**argv){return __get_cpuid(1, &eax, &ebx, &ecx, &edx);}
_EOF
$CXX test.cc -o ctest >/dev/null 2>&1
case $? in
0) echo "yes" ;;
*) echo "no"; USE_CPU_GFX=false ;;
esac
if not $USE_CPU_GFX
then
echo " Won't compile custom graphics routines"
fi
;;
esac
fi
if $USE_CPU_GFX
then
USE_X86_GFX=false;
USE_PPC_GFX=false;
case "x$ARCH" in
xx86_64) USE_X86_GFX=true ;;
x*86) USE_X86_GFX=true ;;
xppc) USE_PPC_GFX=true ;;
*) GFX_EXT_OBJS=
USE_CPU_GFX=false
echo " No custom graphics routines available for the given architecture"
;;
esac
fi
if $USE_CPU_GFX
then
if $USE_X86_GFX
then
$echo_n "Checking for compiler x86 MMX & SSE2 intrinsics support... ${nobr}"
cat > test.cc <<-_EOF
#include <mmintrin.h>
#include <emmintrin.h>
int main(int argc, char**argv){__m64 mmxchk = _mm_set1_pi8(0); __m128i sse2chk = _mm_set1_epi8(0); return 0;}
_EOF
$CXX -msse2 -mmmx test.cc -o gtest >/dev/null 2>&1
case $? in
0) echo "yes"
GFX_MMX_FLAGS="-mmmx -DUSE_X86_GFX"
GFX_SSE2_FLAGS="-msse2 -DUSE_X86_GFX"
GFX_EXT_OBJS="graphics_mmx.o graphics_sse2.o"
CFLAGSEXTRA="$CFLAGSEXTRA -DUSE_X86_GFX"
echo " Compiling with x86 MMX/SSE2 custom graphics routines"
;;
*) echo "no"; USE_X86_GFX=false; USE_CPU_GFX=false ;;
esac
elif $USE_PPC_GFX
then
$echo_n "Checking for compiler PPC Altivec intrinsics support... ${nobr}"
cat > test.cc <<-_EOF
#include <altivec.h>
int main(int argc, char**argv){vector unsigned char altichk = vec_splat_u8(0);}
_EOF
$CXX -maltivec test.cc -o gtest >/dev/null 2>&1
case $? in
0) echo "yes"
GFX_MALTIVEC_FLAGS="-maltivec -DUSE_PPC_GFX"
GFX_EXT_OBJS="graphics_maltivec.o"
CFLAGSEXTRA="$CFLAGSEXTRA -DUSE_PPC_GFX"
echo " Compiling with PPC custom graphics routines"
;;
*) echo "no"; USE_PPC_GFX=false; USE_CPU_GFX=false ;;
esac
fi
if not $USE_CPU_GFX
then
echo " Won't compile custom graphics routines"
fi
fi
cd ..
rm -rf .configtest
# Make (must be GNU)
$echo_n "Checking for GNU make... ${nobr}"
case "`($MAKE -v) 2>/dev/null | head -1`" in
GNU?Make*)
echo "$MAKE" ;;
*)
case "`(gmake -v) 2>/dev/null | head -1`" in
GNU?Make*)
MAKE=gmake
echo "gmake" ;;
*) echo "no"
cat <<-_ERR
Unable to locate GNU make.
Please install GNU make. If it's installed, try setting the environment variable MAKE appropriately, or use the --make option to configure.
_ERR
exit 1 ;;
esac ;;
esac
# ar, ranlib (for simplicity's sake we assume that these are ar and
# ranlib if make is make)
if [ "x$MAKE" != "xmake" ]
then
$echo_n "Checking for ar... ${nobr}"
if ($AR -V >/dev/null) 2>/dev/null
then
echo $AR
else
AR=gar
if ($AR -V >/dev/null) 2>/dev/null
then echo $AR
else echo "not found"
echo "Unable to locate ar. If it's installed, try setting the environment variable AR appropriately."
exit 1
fi
fi
$echo_n "Checking for ranlib... ${nobr}"
if ($RANLIB -v >/dev/null) 2>/dev/null
then
echo $RANLIB
else
RANLIB=granlib
if ($RANLIB -v >/dev/null) 2>/dev/null
then echo $RANLIB
else echo "not found"
echo "Unable to locate ranlib. If it's installed, try setting the environment variable RANLIB appropriately. (If your platform does not need ranlib, just set RANLIB=true.)"
exit 1
fi
fi
fi
# Libraries
if $INTERNAL_SDL
then
SDL_CONFIG=./extlib/bin/sdl-config
else
$echo_n "Checking for system SDL... ${nobr}"
case "$SYS" in
MinGW) SDL_CONFIG=`pwd`/extlib
cd win_dll; make prefix=$SDL_CONFIG > /dev/null 2>&1; cd ..
SDL_CONFIG=`pwd`/extlib/bin/sdl-config
DISTCLEAN_OTHER=SDL.dll $DISTCLEAN_OTHER
cp -p ./win_dll/SDL.dll `pwd`;;
esac
VER=`($SDL_CONFIG --version) 2>/dev/null`
if [ -n "$VER" ]
then
eval `echo $VER | awk -F. '{ print "MAJ=" $1 "; MIN=" $2 "; REL=" $3; }'`
if [ $MAJ -gt 1 -o $MAJ -eq 1 -a $MIN -gt 2 -o $MAJ -eq 1 -a $MIN -eq 2 -a $REL -ge 8 ]
then echo "yes"
else echo "too old"
internalise_SDL
fi
else
echo "no"
internalise_SDL
fi
fi
if $INTERNAL_SDL
then
case "$SYS" in
MinGW) echo "Using internal SDL - might not work with DirectX" ;;
esac
fi
rm -rf .configtest
mkdir .configtest
cd .configtest
if not $INTERNAL_SDL_IMAGE
then
$echo_n "Checking for system SDL_image... ${nobr}"
cat > test.cc <<-_EOF
#include "SDL.h"
#include "SDL_image.h"
unsigned char jpeg[]={255,216,255,224,0,16,74,70,73,70,0,1,1,1,0,72,0,72,0,0,255,225,0,22,69,120,105,102,0,0,77,77,0,42,0,0,0,8,0,0,0,0,0,0,255,219,0,67,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,255,219,0,67,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,255,192,0,17,8,0,1,0,1,3,1,34,0,2,17,1,
3,17,1,255,196,0,21,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,255,196,0,20,16,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,196,0,20,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,196,0,20,17,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,218,0,12,3,1,0,2,17,3,17,0,63,0,191,128,1,255,217};unsigned char png[]={137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130};
int main(int argc, char**argv){bool j=IMG_Load_RW(SDL_RWFromConstMem(jpeg,309),1),p=IMG_Load_RW(SDL_RWFromConstMem(png,69),1);return j&&p?0:(j?1:(p?2:3));}
_EOF
INTERNAL_SDL_IMAGE=true
$CXX `$SDL_CONFIG --cflags` `$SDL_CONFIG --libs` -lSDL_image test.cc -o itest >/dev/null 2>&1
./itest 2>/dev/null
case $? in
0) echo "yes"; INTERNAL_SDL_IMAGE=false ;;
1) echo "no PNG" ;; 2) echo "no JPEG" ;; 3) echo "no PNG or JPEG" ;;
*) echo "no" ;;
esac
fi
if $INTERNAL_SDL_IMAGE && not $INTERNAL_LIBPNG
then
$echo_n "Checking for system libpng... ${nobr}"
cat > test.cc <<-_EOF
#include <png.h>
unsigned char png[]={137,80,78,71,13,10,26,10};int main(int argc, char**argv){return png_sig_cmp(png,0,8);}
_EOF
INTERNAL_LIBPNG=true
$CXX -lpng -lz test.cc -o ptest >/dev/null 2>&1
./ptest 2>/dev/null
case $? in
0) echo "yes"; INTERNAL_LIBPNG=false ;;
1) echo "broken" ;;
*) echo "no" ;;
esac
fi
if $INTERNAL_SDL_IMAGE && not $INTERNAL_LIBJPEG
then
$echo_n "Checking for system libjpeg... ${nobr}"
cat > test.cc <<-_EOF
#include <stdio.h>
#include <jpeglib.h>
int main(int argc, char**argv){struct jpeg_decompress_struct cinfo;struct jpeg_error_mgr jerr;cinfo.err=jpeg_std_error(&jerr);jpeg_create_decompress(&cinfo);return 0;}
_EOF
INTERNAL_LIBJPEG=true
$CXX -ljpeg test.cc -o jtest >/dev/null 2>&1
./jtest 2>/dev/null
case $? in
0) echo "yes"; INTERNAL_LIBJPEG=false ;;
1) echo "broken" ;;
*) echo "no" ;;
esac
fi
write_ogg() {
cat > test.cc <<-_EOF
unsigned char o[]={79,103,103,83,0,2,0,0,0,0,0,0,0,0,137,109,229,31,0,0,0,0,255,229,22,156,1,30,1,118,111,114,98,105,115,0,0,0,0,2,68,172,0,0,0,0,0,0,128,181,1,0,0,0,0,0,184,1,79,103,103,83,0,0,0,0,0,0,0,0,0,0,137,109,229,31,1,0,0,0,232,117,220,177,17,45,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,7,3,118,111,114,98,105,115,29,0,0,0,88,105,112,104,46,79,114,103,32,108,105,98,86,111,114,98,105,115,32,73,32,50,48,48,53,48,51,48,52,0,0,0,0,1,5,118,111,114,98,105,
115,37,66,67,86,1,0,64,0,0,36,115,24,42,70,165,115,22,132,16,26,66,80,25,227,28,66,206,107,236,25,66,76,17,130,28,50,76,91,203,37,115,144,33,164,160,66,136,91,40,129,208,144,85,0,0,64,0,0,135,65,120,20,132,138,65,8,33,132,37,61,88,146,131,39,61,8,33,132,136,57,120,20,132,105,65,8,33,132,16,66,8,33,132,16,66,8,33,132,69,57,104,146,131,39,65,8,29,132,227,48,56,12,131,229,56,248,28,132,69,57,88,16,131,39,65,232,32,132,15,66,184,154,131,172,57,8,33,132,36,53,72,80,131,6,57,232,
28,132,194,44,40,138,130,196,48,184,22,132,4,53,40,140,130,228,48,200,212,131,11,66,136,154,131,73,53,248,26,132,103,65,120,22,132,105,65,8,33,132,36,65,72,144,131,6,65,200,24,132,70,65,88,146,131,6,57,184,20,132,203,65,168,26,132,42,57,8,31,132,32,52,100,21,0,144,0,0,160,162,40,138,162,40,10,16,26,178,10,0,200,0,0,16,64,81,20,199,113,28,201,145,28,201,177,28,11,8,13,89,5,0,0,1,0,8,0,0,160,72,138,164,72,142,228,72,146,36,89,146,37,89,146,37,89,146,230,137,170,44,203,178,44,
203,178,44,203,50,16,26,178,10,0,72,0,0,80,81,12,69,113,20,7,8,13,89,5,0,100,0,0,8,160,56,138,165,88,138,165,104,138,231,136,142,8,132,134,172,2,0,128,0,0,4,0,0,16,52,67,83,60,71,148,68,207,84,85,215,182,109,219,182,109,219,182,109,219,182,109,219,182,109,91,150,101,25,8,13,89,5,0,64,0,0,16,210,105,102,169,6,136,48,3,25,6,66,67,86,1,0,8,0,0,128,17,138,48,196,128,208,144,85,0,0,64,0,0,128,24,74,14,162,9,173,57,223,156,227,160,89,14,154,74,177,57,29,156,72,181,121,146,155,138,185,
57,231,156,115,206,201,230,156,49,206,57,231,156,162,156,89,12,154,9,173,57,231,156,196,160,89,10,154,9,173,57,231,156,39,177,121,208,154,42,173,57,231,156,113,206,233,96,156,17,198,57,231,156,38,173,121,144,154,141,181,57,231,156,5,173,105,142,154,75,177,57,231,156,72,185,121,82,155,75,181,57,231,156,115,206,57,231,156,115,206,57,231,156,234,197,233,28,156,19,206,57,231,156,168,189,185,150,155,208,197,57,231,156,79,198,233,222,156,16,206,57,231,156,115,206,57,231,156,115,
206,57,231,156,32,52,100,21,0,0,4,0,64,16,134,141,97,220,41,8,210,231,104,32,70,17,98,26,50,233,65,247,232,48,9,26,131,156,66,234,209,232,104,164,148,58,8,37,149,113,82,74,39,8,13,89,5,0,0,2,0,64,8,33,133,20,82,72,33,133,20,82,72,33,133,20,98,136,33,134,24,114,202,41,167,160,130,74,42,169,168,162,140,50,203,44,179,204,50,203,44,179,204,58,236,172,179,14,59,12,49,196,16,67,43,173,196,82,83,109,53,214,88,107,238,57,231,154,131,180,86,90,107,173,181,82,74,41,165,148,82,10,66,
67,86,1,0,32,0,0,4,66,6,25,100,144,81,72,33,133,20,98,136,41,167,156,114,10,42,168,128,208,144,85,0,0,32,0,128,0,0,0,0,79,242,28,209,17,29,209,17,29,209,17,29,209,17,29,209,241,28,207,17,37,81,18,37,81,18,45,211,50,53,211,83,69,85,117,101,215,150,117,89,183,125,91,216,133,93,247,125,221,247,125,221,248,117,97,88,150,101,89,150,101,89,150,101,89,150,101,89,150,101,89,150,32,52,100,21,0,0,2,0,0,32,132,16,66,72,33,133,20,82,72,41,198,24,115,204,57,232,36,148,16,8,13,89,5,0,0,2,
0,8,0,0,0,112,20,71,113,28,201,145,28,73,178,36,75,210,36,205,210,44,79,243,52,79,19,61,81,20,69,211,52,85,209,21,93,81,55,109,81,54,101,211,53,93,83,54,93,85,86,109,87,150,109,91,182,117,219,151,101,219,247,125,223,247,125,223,247,125,223,247,125,223,247,125,93,7,66,67,86,1,0,18,0,0,58,146,35,41,146,34,41,146,227,56,142,36,73,64,104,200,42,0,64,6,0,64,0,0,138,226,40,142,227,56,146,36,73,146,37,105,146,103,121,150,168,153,154,233,153,158,42,170,64,104,200,42,0,0,16,0,64,0,0,
0,0,0,0,138,166,120,138,169,120,138,168,120,142,232,136,146,104,153,150,168,169,154,43,202,166,236,186,174,235,186,174,235,186,174,235,186,174,235,186,174,235,186,174,235,186,174,235,186,174,235,186,174,235,186,174,235,186,174,235,186,174,11,132,134,172,2,0,36,0,0,116,36,71,114,36,71,82,36,69,82,36,71,114,128,208,144,85,0,128,12,0,128,0,0,28,195,49,36,69,114,44,203,210,52,79,243,52,79,19,61,209,19,61,211,83,69,87,116,129,208,144,85,0,0,32,0,128,0,0,0,0,0,0,12,201,176,20,203,
209,28,77,18,37,213,82,45,85,83,45,213,82,69,213,83,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,77,211,52,77,19,8,13,89,9,0,144,1,0,144,16,83,45,45,198,154,9,139,36,98,210,106,171,160,99,12,82,236,165,177,72,42,103,181,183,202,49,133,24,181,94,26,135,148,81,16,123,169,36,99,138,65,204,45,164,208,41,38,173,214,84,66,133,20,164,152,99,42,21,82,14,82,32,52,100,133,0,16,154,1,224,112,28,64,178,44,64,178,44,0,0,0,0,0,0,0,144,
52,13,208,60,15,176,52,15,0,0,0,0,0,0,0,36,77,3,44,79,3,52,207,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,210,52,64,243,60,64,243,60,0,0,0,0,0,0,0,208,60,15,240,60,17,240,68,17,0,0,0,0,0,0,0,44,207,3,52,209,3,60,81,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,210,52,64,243,60,64,243,60,0,0,
0,0,0,0,0,176,60,15,240,68,17,208,60,17,0,0,0,0,0,0,0,44,207,3,60,81,4,60,209,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,16,224,0,0,16,96,33,20,26,178,34,0,136,19,0,112,72,18,36,9,146,4,205,3,72,150,5,77,131,166,193,52,1,146,101,65,211,160,105,48,
77,0,0,0,0,0,0,0,0,0,0,36,77,131,166,65,211,32,138,0,73,211,160,105,208,52,136,34,0,0,0,0,0,0,0,0,0,0,146,166,65,211,160,105,16,69,128,164,105,208,52,104,26,68,17,0,0,0,0,0,0,0,0,0,0,207,52,33,138,16,69,152,38,192,51,77,136,34,68,17,166,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,24,112,0,0,8,48,161,12,20,26,178,34,0,136,19,0,112,56,138,101,1,0,128,227,56,150,5,0,0,142,227,88,22,0,0,88,150,37,138,0,0,96,89,154,40,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,24,112,0,0,8,48,161,12,20,26,178,18,0,136,2,0,112,40,138,101,1,199,177,44,224,56,150,5,36,201,178,0,150,5,208,60,128,166,1,68,17,0,8,0,0,40,112,0,0,8,176,65,83,98,113,128,66,67,86,2,0,81,0,0,6,197,177,44,77,19,69,146,164,105,154,39,138,36,73,211,60,79,20,105,154,231,121,158,105,194,243,60,207,52,33,138,162,104,154,16,69,81,52,77,152,166,105,170,42,48,77,85,21,0,0,80,224,0,0,16,96,131,166,196,226,
0,133,134,172,4,0,66,2,0,28,138,98,89,154,230,121,158,39,138,166,169,154,36,73,211,60,79,20,69,209,52,77,83,85,73,146,166,121,158,40,138,162,105,154,166,170,178,44,77,243,60,81,20,69,211,84,85,85,133,166,121,158,40,138,162,105,170,170,234,194,243,60,79,20,69,209,52,85,213,117,225,121,158,39,138,162,104,154,170,234,186,16,69,81,52,77,211,84,77,85,117,93,32,138,166,105,154,170,170,170,174,11,68,79,20,77,83,85,93,215,117,129,231,137,162,105,170,170,171,186,46,16,77,211,84,85,85,
117,93,89,6,152,166,105,170,170,235,202,50,64,85,85,213,117,93,87,150,1,170,170,170,174,235,186,178,12,80,85,215,117,93,89,150,101,0,174,235,186,178,44,203,2,0,0,14,28,0,0,2,140,160,147,140,42,139,176,209,132,11,15,64,161,33,43,2,128,40,0,0,192,24,166,20,83,202,48,38,33,164,16,26,198,36,132,20,66,38,37,165,210,82,170,32,164,82,82,41,21,132,84,74,42,37,163,148,82,106,41,85,16,82,41,169,148,10,66,42,37,149,82,0,0,216,129,3,0,216,129,133,80,104,200,74,0,32,15,0,128,48,70,41,198,
24,115,78,34,164,20,99,206,57,39,17,82,138,49,231,156,147,74,49,230,156,115,206,73,41,25,115,204,57,231,164,148,206,57,231,156,115,82,74,230,156,115,206,57,41,165,115,206,57,231,156,148,82,74,231,156,115,78,74,41,37,132,206,65,39,165,148,210,57,231,156,19,0,0,84,224,0,0,16,96,163,200,230,4,35,65,133,134,172,4,0,82,1,0,12,142,99,89,154,230,121,162,104,154,150,36,105,154,231,121,158,40,154,166,38,73,154,230,121,158,39,138,170,201,243,60,79,20,69,209,52,85,149,231,121,158,40,138,
162,105,170,42,215,21,69,211,52,77,85,85,93,178,44,138,166,105,154,170,234,186,48,77,211,84,85,215,117,93,152,166,105,170,170,235,186,46,108,91,85,85,213,117,101,25,182,173,170,170,234,186,178,12,92,215,117,101,217,150,129,44,187,174,236,218,178,0,0,240,4,7,0,160,2,27,86,71,56,41,26,11,44,52,100,37,0,144,1,0,64,24,131,144,66,8,33,101,16,66,10,33,132,148,82,8,9,0,0,24,112,0,0,8,48,161,12,20,26,178,18,0,72,5,0,0,140,177,214,90,107,173,181,214,64,103,173,181,214,90,107,173,
128,204,90,107,173,181,214,90,107,173,181,214,90,107,173,181,214,82,107,173,181,214,90,107,173,181,214,90,107,173,181,214,90,107,173,181,214,90,107,173,181,214,90,107,173,181,214,90,107,173,181,214,90,107,173,181,214,90,107,173,181,214,90,107,173,181,214,90,107,45,165,148,82,74,41,165,148,82,74,41,165,148,82,74,41,165,148,82,74,5,0,250,85,56,0,248,63,216,176,58,194,73,209,88,96,161,33,43,1,128,112,0,0,192,24,165,24,115,12,66,41,165,84,8,49,230,156,116,84,90,139,177,66,136,49,
231,36,164,212,90,108,197,115,206,65,40,33,149,214,98,44,158,115,14,66,41,41,197,86,99,81,41,132,82,82,74,45,182,88,139,74,161,163,146,82,74,173,213,88,140,49,169,164,214,90,139,173,198,98,140,73,41,180,212,90,139,49,22,35,108,77,169,181,216,106,171,177,24,99,107,42,45,180,24,99,140,197,8,95,100,108,45,166,218,106,13,198,8,35,91,44,45,213,90,107,48,198,24,221,91,139,165,182,154,139,49,62,248,218,82,44,49,214,92,0,0,119,131,3,0,68,130,141,51,172,36,157,21,142,6,23,26,178,18,0,
8,9,0,32,16,82,138,49,198,24,115,206,57,231,164,82,140,57,230,156,115,14,66,8,161,84,138,49,198,156,115,14,66,8,33,148,140,49,230,156,115,16,66,8,33,132,82,74,198,156,115,16,66,8,33,132,144,82,234,156,115,16,66,8,33,132,16,74,41,157,115,14,66,8,33,132,16,66,41,165,131,16,66,8,33,132,16,74,40,165,164,20,66,8,33,132,16,66,8,169,164,148,66,8,33,132,82,66,40,33,149,148,82,8,33,132,16,66,41,37,164,148,82,10,33,132,82,66,8,161,132,148,82,74,41,133,16,66,8,165,148,146,82,74,41,165,
18,74,9,37,132,18,82,41,41,165,20,74,8,33,148,82,74,74,41,165,84,74,9,161,132,18,74,41,37,165,148,82,74,33,132,16,74,41,5,0,0,28,56,0,0,4,24,65,39,25,85,22,97,163,9,23,30,128,66,67,86,2,0,100,0,0,144,162,148,82,41,45,69,130,34,165,24,164,24,75,70,21,115,80,90,138,168,114,12,82,205,169,82,206,32,230,36,150,136,49,132,148,147,84,50,230,20,66,12,66,234,28,117,76,41,6,45,149,24,66,198,24,164,216,114,75,161,115,14,0,0,0,65,0,128,128,144,0,0,3,4,5,51,0,192,224,0,225,115,16,116,2,
4,71,27,0,128,32,68,102,136,68,195,66,112,120,80,9,16,17,83,1,64,98,130,66,46,0,84,88,92,164,93,92,64,151,1,46,232,226,174,3,33,4,33,8,65,44,14,160,128,4,28,156,112,195,19,111,120,194,13,78,208,41,42,117,32,0,0,0,0,0,13,0,240,0,0,144,92,0,17,17,209,204,97,100,104,108,112,116,120,124,128,132,136,140,144,8,0,0,0,0,0,25,0,124,0,0,36,37,64,68,68,52,115,24,25,26,27,28,29,30,31,32,33,34,35,36,1,0,128,0,2,0,0,0,0,32,128,0,4,4,4,0,0,0,0,0,2,0,0,0,4,4,79,103,103,83,0,4,0,0,0,0,0,0,0,0,
137,109,229,31,2,0,0,0,123,25,191,226,1,1,0};
_EOF
}
if not $INTERNAL_SDL_MIXER
then
$echo_n "Checking for system SDL_mixer... ${nobr}"
write_ogg
cat >> test.cc <<-_EOF
#include <cstdio>
#include "SDL.h"
#include "SDL_mixer.h"
unsigned char m[]={255,251,80,196,0,3,192,0,1,164,0,0,0,32,0,0,52,128,0,0,4,76,65,77,69,51,46,57,54,46,49,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,255,251,82,196,93,131,192,0,1,164,0,0,0,32,0,0,52,128,0,0,4,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85};const int ol=4008,ml=417;
int main(int argc, char**argv){using namespace std;FILE*f=fopen("o.ogg","wb");if(!f||fwrite(o,1,ol,f)!=ol)return 127;fclose(f);f=fopen("o.mp3","wb");if(!f||fwrite(m,1,ml,f)!=ml)return 127;fclose(f);
Mix_Music*m;bool ogg=m=Mix_LoadMUS("o.ogg");if(m)Mix_FreeMusic(m);bool mp3=m=Mix_LoadMUS("o.mp3");if(m)Mix_FreeMusic(m);return ogg&&mp3?0:(ogg?1:(mp3?2:3));}
_EOF
INTERNAL_SDL_MIXER=true
$CXX `$SDL_CONFIG --cflags` `$SDL_CONFIG --libs` -lSDL_mixer test.cc -o mtest >/dev/null 2>&1
./mtest 2>/dev/null
case $? in
0) echo "yes"; INTERNAL_SDL_MIXER=false ;;
1) echo "no MP3" ;; 2) echo "no Ogg" ;; 3) echo "no Ogg or MP3" ;;
*) echo "no" ;;
esac
fi
if $INTERNAL_SDL_MIXER && not $INTERNAL_OGGLIBS
then
$echo_n "Checking for system Ogg Vorbis libs... ${nobr}"
write_ogg
cat >> test.cc <<-_EOF
#include <cstdio>
#include <vorbis/codec.h>
#include <vorbis/vorbisfile.h>
const int ol=4008;
int main(int argc, char**argv){using namespace std;FILE*f=fopen("o.ogg","wb");if(!f||fwrite(o,1,ol,f)!=ol)return 127;fclose(f);
OggVorbis_File vf;f=fopen("o.ogg","rb");int n=ov_open(f,&vf,0,0)<0;fclose(f);return n;}
_EOF
INTERNAL_OGGLIBS=true
$CXX -logg -lvorbis -lvorbisfile test.cc -o otest >/dev/null 2>&1
./otest 2>/dev/null
case $? in
0) echo "yes"; INTERNAL_OGGLIBS=false ;;
1) echo "broken" ;;
*) echo "no" ;;
esac
elif not $INTERNAL_OGGLIBS
then
$echo_n "Checking whether Ogg libs need to be linked explicitly... ${nobr}"
write_ogg
cat >> test.cc <<-_EOF
#include <cstdio>
#include "SDL.h"
#include "SDL_mixer.h"
#include <vorbis/codec.h>
#include <vorbis/vorbisfile.h>
const int ol=4008;
int main(int argc, char**argv){using namespace std;FILE*f=fopen("o.ogg","wb");if(!f||fwrite(o,1,ol,f)!=ol)return 127;fclose(f);
OggVorbis_File vf;f=fopen("o.ogg","rb");int n=ov_open(f,&vf,0,0)<0;fclose(f);return n;}
_EOF
EXPLICIT_OGGLIBS=true
$CXX `$SDL_CONFIG --cflags` `$SDL_CONFIG --libs` -lSDL_mixer test.cc -o mtest >/dev/null 2>&1
case $? in
0) echo "no"; EXPLICIT_OGGLIBS=false ;;
*) echo "yes" ;;
esac
fi
if not $INTERNAL_BZIP2
then
$echo_n "Checking for system libbzip2... ${nobr}"
cat > test.cc <<-_EOF
#include <bzlib.h>
unsigned char bz[]={66,90,104,57,49,65,89,38,83,89,41,212,246,171,0,0,0,16,0,64,0,32,0,33,24,70,130,238,72,167,10,18,5,58,158,213,96};
int main(int argc, char**argv){char out[2];unsigned int olen=2;out[0]='.';return(BZ2_bzBuffToBuffDecompress(out,&olen,(char*)bz,37,0,0)==BZ_OK&&olen==1&&out[0]==' ')?0:1;}
_EOF
# Make the bzip2 check find bzip2 libraries and headers on OpenBSD
# and possibly other operating systems. -grodzio1
$CXX -I/usr/local/include -L/usr/local/lib -lbz2 test.cc -o btest >/dev/null 2>&1
if ./btest 2>/dev/null
then echo "yes"
else echo "no"
INTERNAL_BZIP2=true
fi
fi
if $INTERNAL_SMPEG
then
SMPEG_CONFIG=./extlib/bin/smpeg-config
else
$echo_n "Checking for system libsmpeg... ${nobr}"
VER=`($SMPEG_CONFIG --version) 2>/dev/null`
if [ -n "$VER" ]
then echo "yes"
else echo "no"
INTERNAL_SMPEG=true
SMPEG_CONFIG=./extlib/bin/smpeg-config
fi
fi
if not $INTERNAL_FREETYPE
then
$echo_n "Checking for system Freetype... ${nobr}"
VER=`($FREETYPE_CONFIG --ftversion) 2>/dev/null`
if [ -z "$VER" ]; then
FREETYPE_CONFIG=freetype2-config
VER=`($FREETYPE_CONFIG --ftversion) 2>/dev/null`
if [ -z "$VER" ]; then
FREETYPE_CONFIG="pkg-config freetype2"
VER=`($FREETYPE_CONFIG --modversion) 2>/dev/null`
if [ -n "$VER" ]; then VER=2; fi
fi
fi
if [ -n "$VER" ]
then
if [ `echo $VER | awk -F. '{ print $1; }'` -ge 2 ]
then echo "yes"
else echo "too old"
INTERNAL_FREETYPE=true
fi
else
echo "no"
INTERNAL_FREETYPE=true
fi
fi
if $INTERNAL_FREETYPE
then
INTERNAL_SDL_TTF=true
FREETYPE_CONFIG=./extlib/bin/freetype-config
elif not $INTERNAL_SDL_TTF
then
$echo_n "Checking for system SDL_ttf... ${nobr}"
cat > test.cc <<-_EOF
#include "SDL.h"
#include "SDL_ttf.h"
int main(int argc, char **argv){if(TTF_Init()==-1)return 1;TTF_Quit();return 0;}
_EOF
INTERNAL_SDL_TTF=true
$CXX `$SDL_CONFIG --cflags` `$SDL_CONFIG --libs` -lSDL_ttf test.cc -o ttest >/dev/null 2>&1
if ./ttest 2>/dev/null
then echo "yes"; INTERNAL_SDL_TTF=false
else echo "no"
fi
fi
cd ..
rm -rf .configtest
if $INTERNAL_FREETYPE
then
# See the file itself for explaination
$(cd ${srcdir}; ${srcdir}/extlib/bin/freetype-config-setup --build ${builddir})
if [ $? -ne 0 ]; then
echo "Error: failed to configure internal FreeType" >&2
exit 1
fi
fi
X11_CFLAGS=
X11_LIBS=
case $POSIX in
Linux|*BSD)
rm -rf .configtest
mkdir .configtest
cd .configtest
$echo_n "Checking for Xlib... ${nobr}"
have_xlib=no
cat > test.cc <<-_EOF
#include <X11/Xlib.h>