-
Notifications
You must be signed in to change notification settings - Fork 52
/
configure
executable file
·786 lines (722 loc) · 20.2 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
#! /bin/sh
ARGS=$*
PROGRAM=ufo
#set -e
#set -x
echo "" > config.log
CONFIG_H=config.h
MAKEFILE_LOCAL=Makefile.local
DEBUG=1
UNIVERSAL=
HARD_LINKED_GAME=
HARD_LINKED_CGAME=1
PARANOID=
PROFILING=
PREFIX=/usr/local
PKGDATADIR=
PKGBINDIR=
PKGLIBDIR=
LOCALEDIR=
USE_SIGNALS=1
MODE=
CROSS=
USE_CCACHE=
STATIC=
W2K=
SSE=
DISABLE_DEPENDENCY_TRACKING=
DEFAULT_COMPILER_CC=gcc
DEFAULT_COMPILER_CXX=g++
HOST_OS=`uname | sed -e s/_.*// | tr '[:upper:]' '[:lower:]'`
TARGET_OS=${HOST_OS}
if [ "${HOST_OS}" = "sunos" ] || [ "${HOST_OS}" = "darwin" ]; then
TARGET_ARCH=`uname -p | sed -e s/i.86/i386/`
else
TARGET_ARCH=`uname -m | sed -e s/i.86/i386/`
fi
add_line_to_makefile_local() {
makefile_local_data="${makefile_local_data}"'
'"$1"
}
error() {
echo $@
exit 1
}
add_to_makefile_local_quote() {
VALUE=`get_var $1`
if [ "$1" = "CC" ] || [ "$1" = "CXX" ]; then
# these are internal make variables and are already set, so don't use ?= here
ASSIGN_OP=":="
else
ASSIGN_OP="?="
fi
if [ -n "$VALUE" ]; then
add_line_to_makefile_local "$1 $ASSIGN_OP \"$VALUE\""
[ -n "$2" ] && echo $2
else
add_line_to_makefile_local "# $1 $ASSIGN_OP \"$VALUE\""
[ -n "$3" ] && echo $3
[ "$4" = "yes" ] && exit 1
fi
}
add_to_makefile_local() {
VALUE=`get_var $1`
if [ "$1" = "CC_VER" ] || [ "$1" = "CXX_VER" ]; then
ASSIGN_OP=":="
else
ASSIGN_OP="?="
fi
if [ -n "$VALUE" ]; then
add_line_to_makefile_local "$1 $ASSIGN_OP $VALUE"
[ -n "$2" ] && echo $2
else
add_line_to_makefile_local "# $1 $ASSIGN_OP $VALUE"
[ -n "$3" ] && echo $3
[ "$4" = "yes" ] && exit 1
fi
}
add_line_to_config_h() {
config_h_data="${config_h_data}"'
'"$1"
}
add_to_config_h_quote() {
VALUE=`get_var $1`
if [ -n "$VALUE" ] && [ "$VALUE" != "no" ]; then
add_line_to_config_h "#define $1 \"$VALUE\""
[ -n "$2" ] && echo $2
else
add_line_to_config_h "/* #define $1 \"$VALUE\" */"
[ -n "$3" ] && echo $3
[ "$4" = "yes" ] && exit 1
fi
}
add_to_config_h() {
VALUE=`get_var $1`
if [ -n "$VALUE" ] && [ "$VALUE" != "no" ]; then
add_line_to_config_h "#define $1 $VALUE"
[ -n "$2" ] && echo $2
else
add_line_to_config_h "/* #define $1 $VALUE */"
[ -n "$3" ] && echo $3
[ "$4" = "yes" ] && exit 1
fi
}
config_h() {
add_to_config_h PARANOID "Enable paranoid build"
add_to_config_h HARD_LINKED_GAME "Enable hard linked game"
add_to_config_h HARD_LINKED_CGAME "Enable hard linked cgame"
add_to_config_h USE_SIGNALS "Use signal handler"
add_to_config_h_quote PKGDATADIR "Setting custom data directory"
add_to_config_h_quote PKGLIBDIR "Setting custom library directory"
add_to_config_h_quote LOCALEDIR "Setting custom locale directory"
}
makefile_local() {
add_to_makefile_local DEBUG "Debug build"
add_to_makefile_local PROFILING "Enable profiling"
add_to_makefile_local STATIC "Enable static linking"
add_to_makefile_local W2K "Enable Windows 2000 compatibility"
add_to_makefile_local SSE "Enable Streaming SIMD Extensions"
add_to_makefile_local HARD_LINKED_GAME
add_to_makefile_local HARD_LINKED_CGAME
add_to_makefile_local DISABLE_DEPENDENCY_TRACKING "Disable dependency tracking"
add_to_makefile_local UNIVERSAL "Build a universal binary"
add_to_makefile_local TARGET_OS "Compile for ${TARGET_OS}"
add_to_makefile_local TARGET_ARCH "Compile for ${TARGET_ARCH}"
add_to_makefile_local MODE "Compile in ${MODE} mode"
add_to_makefile_local USE_CCACHE "Use ccache" "Disable ccache"
add_to_makefile_local CFLAGS "Added CFLAGS ${CFLAGS}" "Using default CFLAGS"
add_to_makefile_local LDFLAGS "Added LDFLAGS ${LDFLAGS}" "Using default LDFLAGS"
add_to_makefile_local_quote CROSS "Using tools prefix ${CROSS}"
add_to_makefile_local_quote PKGBINDIR "Using bindir ${PKGBINDIR}"
add_to_makefile_local_quote PKGDATADIR "Using datadir ${PKGDATADIR}"
add_to_makefile_local_quote PKGLIBDIR "Using libdir ${PKGLIBDIR}"
add_to_makefile_local_quote LOCALEDIR "Using localedir ${LOCALEDIR}"
add_to_makefile_local_quote PREFIX "Using prefix ${PREFIX}"
}
check_header_cc() {
SOURCE=`cat << EOF
#include <stdlib.h>
#include <stdio.h>
#include <${1}>
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM < 503
#error Lua version must be at least 5.3
#endif
EOF`
if [ -n "${2}" ]; then
while [ -n "${2}" ]; do
( echo "$SOURCE" | ${CROSS}${CXX} -DPACKAGE ${CCFLAGS} ${CXXFLAGS} ${CFLAGS} $(${CROSS}pkg-config --cflags ${2} 2> /dev/null) -o /dev/null -xc++ -c - 2>> config.log ) && echo "1" && break || echo ""
shift
done
else
( echo "$SOURCE" | ${CROSS}${CXX} -DPACKAGE ${CCFLAGS} ${CXXFLAGS} ${CFLAGS} -o /dev/null -xc++ -c - 2>> config.log ) && echo "1" || echo ""
fi
}
check_header() {
HEADER=$1
PACKAGE=$2
PACKAGE=${PACKAGE%+*}
HEADER=${HEADER%.*}
if [ "$PACKAGE" != "" ]; then
PACKAGE="`echo ${PACKAGE} | sed 's,\.,_,g' | sed 's,-,_,g' | tr '[a-z]' '[A-Z]'`_"
HEADER=${HEADER##*/}
else
HEADER="`echo ${HEADER} | sed 's,/,_,g'`"
fi
HEADER="`echo ${HEADER} | sed 's,\.,_,g' | sed 's,-,_,g' | tr '[a-z]' '[A-Z]'`"
HAVE=HAVE_${PACKAGE}${HEADER}_H
if [ "${TARGET_OS}" = "android" ]; then
VALUE="no"
else
VALUE=`get_var $HAVE`
fi
if [ "$VALUE" != "no" ]; then
if [ "$VALUE" != "internal" ]; then
set_var $HAVE `check_header_cc $@`
PACKAGE_VARIANT="`if [ -n \"$2\" ]; then echo \"($2)\";else echo ""; fi`"
add_to_config_h $HAVE "Found $1 $PACKAGE_VARIANT" "Could not find $1 $PACKAGE_VARIANT" $2
add_to_makefile_local $HAVE
else
set_var $HAVE ""
add_to_config_h $HAVE "" "Use embedded $1" $2
add_to_makefile_local $HAVE
fi
else
add_to_config_h $HAVE "Found $1" "Disable $1"
fi
}
check_header_bundled() {
HEADER=$1
PACKAGE=$2
VAR="WITH_EMBEDDED_${PACKAGE}"
VALUE=`get_var $VAR`
if [ -n "$VALUE" ]; then
PACKAGE=${PACKAGE%+*}
HEADER=${HEADER%.*}
if [ "$PACKAGE" != "" ]; then
PACKAGE="`echo ${PACKAGE} | sed 's,\.,_,g' | sed 's,-,_,g' | tr '[a-z]' '[A-Z]'`_"
HEADER=${HEADER##*/}
else
HEADER="`echo ${HEADER} | sed 's,/,_,g'`"
fi
HEADER="`echo ${HEADER} | sed 's,\.,_,g' | sed 's,-,_,g' | tr '[a-z]' '[A-Z]'`"
HAVE=HAVE_${PACKAGE}${HEADER}_H
set_var $HAVE "internal"
fi
check_header $@
}
check_headers() {
check_header "xvid.h"
check_header "theora/theora.h" "theora"
check_header "execinfo.h"
check_header "libiberty.h"
check_header "libiberty/libiberty.h"
if [ "$HAVE_LIBIBERTY_H" = "1" -o "$HAVE_LIBIBERTY_LIBIBERTY_H" = "1" ]; then
check_header "bfd.h"
fi
check_header "libintl.h"
if [ "$HAVE_LIBINTL_H" != "1" ]; then
for i in testall ufo; do
set_var "${i}_DISABLE" "yes" >/dev/null
set_var "${i}_REASON" "`get_var ${i}_REASON`\t- LibIntl missing\n" >/dev/null
done
fi
check_header "sys/utsname.h"
check_header "link.h"
check_header "jpeglib.h"
if [ "${HAVE_JPEGLIB_H}" != "1" ]; then
for i in ufo2map ufomodel; do
set_var "${i}_DISABLE" "yes" >/dev/null
set_var "${i}_REASON" "`get_var ${i}_REASON`\t- LibJpeg missing\n" >/dev/null
done
fi
check_header "zlib.h" "zlib"
if [ "${HAVE_ZLIB_ZLIB_H}" != "1" ]; then
for i in ufo2map; do
set_var "${i}_DISABLE" "yes" >/dev/null
set_var "${i}_REASON" "`get_var ${i}_REASON`\t- ZLib missing\n" >/dev/null
done
fi
check_header "png.h" "libpng"
if [ "${HAVE_LIBPNG_PNG_H}" != "1" ]; then
for i in ufo2map ufomodel; do
set_var "${i}_DISABLE" "yes" >/dev/null
set_var "${i}_REASON" "`get_var ${i}_REASON`\t- LibPNG missing\n" >/dev/null
done
fi
check_header "webp/decode.h" "libwebp"
check_header "curl/curl.h" "libcurl"
if [ "${HAVE_LIBCURL_CURL_H}" != "1" ]; then
for i in ufoded; do
set_var "${i}_DISABLE" "yes" >/dev/null
set_var "${i}_REASON" "`get_var ${i}_REASON`\t- LibCURL missing\n" >/dev/null
done
fi
check_header "lua.h" "lua5.4"
if [ "${HAVE_LUA5_4_LUA_H}" != "1" ]; then
check_header "lua.h" "lua5.3"
if [ "${HAVE_LUA5_3_LUA_H}" != "1" ]; then
for i in game ufo ufo2map ufoded ufomodel; do
set_var "${i}_DISABLE" "yes" >/dev/null
set_var "${i}_REASON" "`get_var ${i}_REASON`\t- Lua missing\n" >/dev/null
done
fi
fi
check_header_bundled "mxml.h" "mxml"
check_header "SDL.h" "sdl2"
if [ "${HAVE_SDL2_SDL_H}" != "1" ]; then
for i in game ufo ufo2map ufoded ufomodel; do
set_var "${i}_DISABLE" "yes" >/dev/null
set_var "${i}_REASON" "`get_var ${i}_REASON`\t- SDL2 missing\n" >/dev/null
done
fi
check_header "SDL_mixer.h" "SDL2_mixer"
if [ "${HAVE_SDL2_MIXER_SDL_MIXER_H}" != "1" ]; then
for i in testall ufo; do
set_var "${i}_DISABLE" "yes" >/dev/null
set_var "${i}_REASON" "`get_var ${i}_REASON`\t- SDL2-Mixer missing\n" >/dev/null
done
fi
check_header "SDL_ttf.h" "SDL2_ttf"
if [ "${HAVE_SDL2_TTF_SDL_TTF_H}" != "1" ]; then
for i in testall ufo; do
set_var "${i}_DISABLE" "yes" >/dev/null
set_var "${i}_REASON" "`get_var ${i}_REASON`\t- SDL2-TTF missing\n" >/dev/null
done
fi
check_header "gtest/gtest.h"
if [ "${HAVE_GTEST_GTEST_H}" != "1" ]; then
for i in testall; do
set_var "${i}_DISABLE" "yes" >/dev/null
set_var "${i}_REASON" "`get_var ${i}_REASON`\t- GoogleTest missing\n" >/dev/null
done
fi
check_header "ogg/ogg.h"
if [ "$HAVE_OGG_OGG_H" != "1" ]; then
for i in ufo; do
set_var "${i}_DISABLE" "yes" >/dev/null
set_var "${i}_REASON" "`get_var ${i}_REASON`\t- LibOGG missing\n" >/dev/null
done
fi
check_header "vorbis/codec.h"
if [ "$HAVE_VORBIS_CODEC_H" != "1" ]; then
for i in ufo; do
set_var "${i}_DISABLE" "yes" >/dev/null
set_var "${i}_REASON" "`get_var ${i}_REASON`\t- LibVorbis missing\n" >/dev/null
done
fi
check_header "picomodel.h" "picomodel"
check_header "gtk/gtk.h" "gtk+-2.0"
if [ "$HAVE_GTK_GTK_H" != "1" ]; then
for i in uforadiant; do
set_var "${i}_DISABLE" "yes" >/dev/null
set_var "${i}_REASON" "`get_var ${i}_REASON`\t- Gtk2 missing\n" >/dev/null
done
fi
check_header "gtksourceview/gtksourceview.h" "gtksourceview-2.0"
check_header "libxml/parser.h" "libxml-2.0"
check_header "AL/al.h" "openal"
check_header "gtk/gtkglwidget.h" "gtkglext-1.0"
if [ "$HAVE_GTKGLEXT_1_0_GTKGLWIDGET_H" != "1" ]; then
for i in uforadiant; do
set_var "${i}_DISABLE" "yes" >/dev/null
set_var "${i}_REASON" "`get_var ${i}_REASON`\t- GtkGL missing\n" >/dev/null
done
fi
}
check_compiler() {
# TODO Implement compiler check
CC=${CC:-${DEFAULT_COMPILER_CC}}
CXX=${CXX:-${DEFAULT_COMPILER_CXX}}
if [ "${TARGET_OS}" = "mingw32" ] || [ "${TARGET_OS}" = "mingw64" ] || [ "${TARGET_OS}" = "mingw64_64" ]; then
CC=gcc
fi
if [ "${TARGET_OS}" = "mingw32" ] && [ "${HOST_OS}" != "mingw32" ]; then
CROSS="i686-pc-mingw32-"
fi
if [ "${TARGET_OS}" = "mingw64" ] && [ "${HOST_OS}" != "mingw64" ]; then
CROSS="i686-w64-mingw32-"
fi
if [ "${TARGET_OS}" = "mingw64_64" ] && [ "${HOST_OS}" != "mingw64_64" ]; then
CROSS="x86_64-w64-mingw32-"
fi
if [ -n "${CROSS}" ]; then
command -v "${CROSS}${CC}" 2>> config.log >> config.log
if [ $? -eq 0 ]; then
echo "Found ${CROSS}${CC} in the path"
else
echo "Cross compiling, make sure that ${CROSS}${CC} is in your path"
fi
command -v "${CROSS}pkg-config" 2>> config.log >> config.log
if [ $? -eq 0 ]; then
echo "Found ${CROSS}pkg-config in the path"
else
echo "Cross compiling, make sure that ${CROSS}pkg-config is in your path"
fi
fi
echo "Check C compiler as '${CROSS}${CC}'..."
CC_VER=`${CROSS}${CC} -dumpfullversion 2>> config.log`
if [ $? -ne 0 ]; then
CC_VER=`${CROSS}${CC} -dumpversion 2>> config.log`
if [ $? -ne 0 ]; then
set_var "CC" "";
fi;
fi;
add_to_makefile_local_quote CC "C compiler version ${CC_VER} was found" "Could not use the c compiler, see config.log for details"
add_to_makefile_local CC_VER
echo "Check C++ compiler as '${CROSS}${CXX}'..."
CXX_VER=`${CROSS}${CXX} -dumpfullversion 2>> config.log`
if [ $? -ne 0 ]; then
CXX_VER=`${CROSS}${CXX} -dumpversion 2>> config.log`
if [ $? -ne 0 ]; then
set_var "CXX" "";
fi;
fi;
add_to_makefile_local_quote CXX "C++ compiler version ${CXX_VER} was found" "Could not use the c++ compiler, see config.log for details"
add_to_makefile_local CXX_VER
}
usage() {
echo "Usage: $0"
echo " --help show this help message"
echo " --enable-ccache use ccache for building"
echo " --enable-hardlinkedgame hard link the server game code"
echo " --enable-hardlinkedcgame hard link the client game code"
echo " --enable-paranoid compile in paranoid mode with extra checks"
echo " --enable-profiling activates profiling"
echo " --enable-release build with optimizations"
echo " --enable-static enable static linking"
echo " --enable-universal enable universal build"
echo " --enable-w2k enable Windows 2000 compatibility"
if [ -n "$(echo ${TARGET_ARCH} | grep -e '^i.86$' -e '^x86_64$')" ]; then
echo " --enable-sse enable Streaming SIMD Extensions"
fi
echo " --disable-execinfo disable backtraces for crashes"
echo " --disable-signals disable the use of a signal handler"
echo " --with-embedded-mxml use the copy of mxml bundled with the source"
echo
echo " --target-os= specify the target os"
(cd build/platforms; for i in *.mk; do echo " * ${i%.mk}"; done)
echo
echo " --bindir= path for the ufoai binaries"
echo " --datadir= path for the ufoai game data"
echo " --libdir= path for the ufoai shared objects"
echo " --localedir= path for the ufoai translations"
echo " --prefix= prefix for directories"
echo
echo " --disable-* specify which target should not get built"
echo " --enable-* specify which target should get built"
echo " --enable-only-* disable all other targets"
(cd build/modules; for i in *.mk; do echo " * ${i%.mk}"; done)
echo
echo " --disable-dependency-tracking"
exit 1
}
make_var() {
echo "$1" | sed 's/-/_/g' | sed 's/\./_/g'
}
set_var() {
eval `make_var "$1"`=\""$2"\"
}
get_var() {
eval echo \${`make_var "$1"`}
}
get_modules() {
(cd build/modules; for i in *.mk; do echo "${i%.mk}"; done)
}
check_path_characters() {
# Find out where configure is (in what dir)
ROOT_DIR="`dirname $0`"
# For MSYS/MinGW we want to know the FULL path. This as that path is generated
# once you call an outside binary. Having the same path for the rest is needed
# for dependency checking.
# pwd -W returns said FULL path, but doesn't exist on others so fall back.
ROOT_DIR="`cd $ROOT_DIR && (pwd -W 2>/dev/null || pwd 2>/dev/null)`"
if [ -n "`echo \"$ROOT_DIR\" | grep '[^-\w\/\\\.:]~?'`" ]; then
echo "WARNING: The path contains a non-alphanumeric character that might cause"
echo " failures in subsequent build stages. Any failures with the build"
echo " will most likely be caused by this."
echo " $ROOT_DIR"
fi
if [ -n "`echo \"$ROOT_DIR\" | grep '[\(\)]'`" ]; then
echo "ERROR: The path contains a square character that cause"
echo " failures in subsequent build stages!!!"
echo " $ROOT_DIR"
exit 1
fi
}
check_ccache() {
if [ "$USE_CCACHE" = "1" ]; then
ccache --help 2>> config.log >> config.log
if [ $? -ne 0 ]; then
USE_CCACHE=0
fi
fi
}
check_program() {
BINARY=$1
TOOL=${2:-${BINARY}}
MANDATORY=${3:-0}
HAVE=PROGRAM_`echo ${BINARY%.*} | sed 's,/,_,g' | tr '[a-z]' '[A-Z]'`
command -v "${BINARY}" 2>> config.log >> config.log
if [ $? -eq 0 ]; then
set_var $HAVE "$1"
fi
add_to_makefile_local $HAVE "Found ${BINARY} from ${TOOL}" "Could not find ${BINARY} from ${TOOL}" $MANDATORY
}
check_programs() {
check_program zip
check_program python
check_program python3
check_program doxygen
}
check_target_os() {
local FOUND=0
for i in build/platforms/*.mk; do
if [ `basename $i .mk` = $1 ]; then
FOUND=1
fi
done
[ $FOUND -eq 0 ] && echo "invalid target-os given: $1" && exit 1
}
check_module() {
local FOUND=0
for i in `get_modules`; do
if [ $i = $1 ]; then
FOUND=1
fi
done
[ $FOUND -eq 0 ] && error "invalid module given: $1"
}
get_ini_value() {
awk -v str="$2" -F '[ \t]*=[ \t]*' '{if (! ($0 ~ /^;/) && $0 ~ str) print $2}' "$1" 2>> config.log
}
set_path_env() {
case ${TARGET_OS} in
mingw*)
MXE_FILE=~/.mxe.settings
set_var "ADDITIONAL_PATH" `get_ini_value "${MXE_FILE}" "PATH"`
add_to_makefile_local ADDITIONAL_PATH "Found mxe additional path settings" "Could not get the mxe path from ${MXE_FILE}"
PATH="${ADDITIONAL_PATH}:$PATH"
;;
esac
}
enable_only() {
for i in `get_modules`; do
if [ "$i" = "$1" ]; then
set_var "${i}_DISABLE" ""
else
set_var "${i}_DISABLE" "yes"
fi
done
}
check_path_characters
while [ $# -gt 0 ]; do
case "$1" in
--help|-h)
usage
;;
--enable-ccache)
USE_CCACHE="1"
;;
--disable-ccache)
USE_CCACHE="0"
;;
--enable-release)
MODE=release
DEBUG=
;;
--disable-release)
MODE=debug
DEBUG=1
;;
--enable-static)
STATIC=1
;;
--disable-static)
STATIC=
;;
--enable-universal)
UNIVERSAL=1
DISABLE_DEPENDENCY_TRACKING=1
;;
--disable-universal)
UNIVERSAL=
;;
--enable-hardlinkedgame)
HARD_LINKED_GAME=1
;;
--disable-hardlinkedgame)
HARD_LINKED_GAME=
;;
--enable-hardlinkedcgame)
HARD_LINKED_CGAME=1
;;
--disable-hardlinkedcgame)
HARD_LINKED_CGAME=
;;
--enable-paranoid)
PARANOID=1
;;
--disable-paranoid)
PARANOID=
;;
--enable-profiling)
PROFILING=1
;;
--disable-profiling)
PROFILING=
;;
--enable-w2k)
W2K=1
;;
--disable-w2k)
W2K=
;;
--enable-sse)
if [ -z "$(echo ${TARGET_ARCH} | grep -e '^i.86$' -e '^x86_64$')" ] ;then
echo "invalid $1 option for your CPU"
exit 1
fi
SSE=1
;;
--disable-sse)
SSE=0
;;
--enable-signals)
USE_SIGNALS=1
;;
--with-embedded-*)
set_var "WITH_EMBEDDED_${1#--with-embedded-}" "1"
;;
--disable-signals)
USE_SIGNALS=
;;
--enable-execinfo)
HAVE_EXECINFO_H=yes
;;
--disable-execinfo)
HAVE_EXECINFO_H=no
;;
--disable-dependency-tracking)
DISABLE_DEPENDENCY_TRACKING=1
;;
--prefix=*)
PREFIX="${1#*=}"
;;
--datadir=*)
PKGDATADIR="${1#*=}"
;;
--libdir=*)
PKGLIBDIR="${1#*=}"
;;
--localedir=*)
LOCALEDIR="${1#*=}"
;;
--bindir=*)
PKGBINDIR="${1#*=}"
;;
--target-os=*)
TARGET_OS="${1#*=}"
check_target_os $TARGET_OS
;;
--disable-*)
OPTION="${1#--disable-}"
check_module $OPTION
set_var "${OPTION}_DISABLE" "yes"
;;
--enable-only-*)
OPTION="${1#--enable-only-}"
HARD_LINKED_GAME=1
HARD_LINKED_CGAME=1
check_module $OPTION
enable_only $OPTION
;;
--enable-*)
OPTION="${1#--enable-}"
check_module $OPTION
set_var "${OPTION}_DISABLE" ""
;;
CC=*) CC="${1#CC=}";;
CXX=*) CXX="${1#CXX=}";;
CFLAGS=*) CFLAGS="${1#*=}";;
LDFLAGS=*) LDFLAGS="${1#*=}";;
*)
echo "invalid option $1"
exit 1
;;
esac
shift
done
set_path_env
case ${TARGET_OS} in
mingw32|mingw64)
TARGET_ARCH=i386
TARGET_ARCH=i386
;;
mingw64_64)
TARGET_ARCH=x86_64
;;
android)
TARGET_ARCH=arm
HARD_LINKED_GAME=1
HARD_LINKED_CGAME=1
enable_only ${PROGRAM}
;;
html5)
HARD_LINKED_GAME=1
HARD_LINKED_CGAME=1
if [ -z "$EMSCRIPTEN_ROOT" ]; then
EMSCRIPTEN_ROOT=`python -c "import os, sys, re, json, shutil; exec(open(os.path.expanduser('~/.emscripten'), 'r').read()); print EMSCRIPTEN_ROOT"`
CONFIGURE_PREFIX=${EMSCRIPTEN_ROOT}/emconfigure
echo "restart configure ($ARGS)"
EMSCRIPTEN_ROOT="${EMSCRIPTEN_ROOT}" CONFIGURE_PREFIX="${EMSCRIPTEN_ROOT}/emconfigure" $CONFIGURE_PREFIX ./configure $ARGS
exit
else
enable_only ${PROGRAM}
add_to_makefile_local EMSCRIPTEN_ROOT "Emscripten found at ${EMSCRIPTEN_ROOT}"
add_to_makefile_local CONFIGURE_PREFIX "Use ${EMSCRIPTEN_ROOT}/emconfigure"
fi
;;
darwin)
USE_SIGNALS=
;;
esac
PKGDATADIR=${PKGDATADIR:-${PREFIX}/games/${PROGRAM}/}
PKGBINDIR=${PKGBINDIR:-${PREFIX}/bin/}
PKGLIBDIR=${PKGLIBDIR:-${PREFIX}/lib/}
check_compiler
check_ccache
makefile_local
config_h
check_programs
check_headers
echo
echo "Build modules:"
for i in `get_modules`; do
add_to_makefile_local ${i}_DISABLE
if [ "`get_var ${i}_DISABLE`" = "yes" ]; then
echo "Disable $i"
echo "`get_var ${i}_REASON`"
else
echo "Build $i"
fi
done
cat > ${MAKEFILE_LOCAL} << EOF
# -------- Automatically generated -----------
$makefile_local_data
# allow to specify your own targets
-include config.mk
EOF
cat > ${TARGET_OS}-${CONFIG_H}.tmp << EOF
/* This file is automatically generated */
#pragma once
$config_h_data
EOF
if diff ${TARGET_OS}-${CONFIG_H}.tmp ${TARGET_OS}-${CONFIG_H} 2>/dev/null >/dev/null; then
if [ configure -nt ${TARGET_OS}-${CONFIG_H} ]; then
mv ${TARGET_OS}-${CONFIG_H}.tmp ${TARGET_OS}-${CONFIG_H}
else
rm -f ${TARGET_OS}-${CONFIG_H}.tmp
fi
else
mv ${TARGET_OS}-${CONFIG_H}.tmp ${TARGET_OS}-${CONFIG_H}
fi