-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·737 lines (661 loc) · 16.7 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
#!/bin/sh
#
# omc configure script - (c) 2006 Alexis Saettler, 2007 Benjamin Zores
#
# (fully inspirated from ffmpeg configure script, thanks to Fabrice Bellard)
#
# make sure we are running under a compatible shell
unset foo
(: ${foo%%bar}) 2>/dev/null && ! (: ${foo?}) 2>/dev/null
if test "$?" != 0; then
if test "x$OMC_CONFIGURE_EXEC" = x; then
OMC_CONFIGURE_EXEC=1
export OMC_CONFIGURE_EXEC
exec bash "$0" "$@"
exec ksh "$0" "$@"
exec /usr/xpg4/bin/sh "$0" "$@"
fi
echo "No compatible shell script interpreter found."
exit 1
fi
show_help(){
echo "Usage: configure [options]"
echo "Options: [defaults in brackets after descriptions]"
echo
echo "Standard options:"
echo " --help print this message"
echo " --log[=FILE|yes|no] log tests and output to FILE [config.log]"
echo " --prefix=PREFIX install in PREFIX [$PREFIX]"
echo " --bindir=DIR install bins in DIR [PREFIX/bin]"
echo " --datadir=DIR install config files in DIR [PREFIX/share]"
echo " --sysconfdir=DIR install config files in DIR [PREFIX/etc]"
echo " --libdir=DIR install libs in DIR [PREFIX/lib]"
echo " --includedir=DIR install includes in DIR [PREFIX/include]"
echo " --mandir=DIR install man page in DIR [PREFIX/man]"
echo " --with-sdl-prefix=DIR check for SDL installed in DIR"
echo " --with-curl-prefix=DIR check for curl installed in DIR"
echo " --with-libplayer-dir=DIR check for libplayer installed in DIR"
echo ""
echo "Advanced options (experts only):"
echo " --disable-debug disable debugging symbols"
echo " --disable-strip disable stripping of executables at installation"
echo " --disable-optimize disable compiler optimization"
echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
echo " --cross-compile assume a cross-compiler is used"
exit 1
}
log(){
echo "$@" >>$logfile
}
log_file(){
log BEGIN $1
cat -n $1 >>$logfile
log END $1
}
echolog(){
log "$@"
echo "$@"
}
clean(){
rm -f $TMPC $TMPO $TMPE $TMPS $TMPH
}
die(){
echolog "$@"
if enabled logging; then
echo "See file \"$logfile\" produced by configure for more details."
else
echo "Rerun configure with logging enabled (do not use --log=no) for more details."
fi
clean
exit 1
}
enabled(){
eval test "x\$$1" = "xyes"
}
flags_saved(){
(: ${SAVE_CFLAGS?}) 2>/dev/null
}
save_flags(){
flags_saved && return
SAVE_CFLAGS="$CFLAGS"
SAVE_LDFLAGS="$LDFLAGS"
SAVE_extralibs="$extralibs"
}
restore_flags(){
CFLAGS="$SAVE_CFLAGS"
LDFLAGS="$SAVE_LDFLAGS"
extralibs="$SAVE_extralibs"
unset SAVE_CFLAGS
unset SAVE_LDFLAGS
unset SAVE_extralibs
}
temp_cflags(){
temp_append CFLAGS "$@"
}
temp_ldflags(){
temp_append LDFLAGS "$@"
}
temp_extralibs(){
temp_append extralibs "$@"
}
temp_append(){
local var
var=$1
shift
save_flags
append_var "$var" "$@"
}
append_var(){
local var f
var=$1
shift
for f in $@; do
if eval echo \$$var | grep -qv -e "$f"; then
eval "$var=\"\$$var $f\""
fi
done
}
append(){
local var
var=$1
shift
flags_saved && append_var "SAVE_$var" "$@"
append_var "$var" "$@"
}
add_cflags(){
append CFLAGS "$@"
}
add_ldflags(){
append LDFLAGS "$@"
}
add_extralibs(){
append extralibs "$@"
}
check_cmd(){
log "$@"
"$@" >>$logfile 2>&1
}
check_cc(){
log check_cc "$@"
cat >$TMPC
log_file $TMPC
check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
}
check_cpp(){
log check_cpp "$@"
cat >$TMPC
log_file $TMPC
check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
}
check_ld(){
log check_ld "$@"
check_cc || return
check_cmd $cc $LDFLAGS "$@" -o $TMPE $TMPO $extralibs
}
check_exec(){
check_ld "$@" && { enabled cross_compile || $TMPE >>$logfile 2>&1; }
}
check_cflags(){
log check_cflags "$@"
check_cc "$@" <<EOF && add_cflags "$@"
int x;
EOF
}
check_ldflags(){
log check_ldflags "$@"
check_ld "$@" <<EOF && add_ldflags "$@"
int main(){
return 0;
}
EOF
}
check_header(){
local header
log check_header "$@"
header=$1
shift
check_cpp "$@" <<EOF
#include <$header>
int x;
EOF
}
check_func(){
local func
log check_func "$@"
func=$1
shift
check_ld "$@" <<EOF
extern int $func();
int main(){
$func();
}
EOF
}
check_lib(){
local header func err
log check_lib "$@"
header="$1"
func="$2"
shift 2
temp_extralibs "$@"
check_header $header && check_func $func && add_extralibs "$@"
err=$?
restore_flags
return $err
}
check_libconfig(){
local config func ccflags clibs err
log check_libconfig "$@"
config="$1"
func="$2"
ccflags="${3:---cflags}"
clibs="${4:---libs}"
err=1
if `which "$config" 1>/dev/null 2>&1`; then
cflags=`$config $ccflags`
[ -n "$cflags" ] && check_cflags "$cflags"
libs=`$config $clibs`
if [ -n "$libs" ]; then
temp_extralibs "$libs"
check_func $func && add_extralibs "$libs"
err=$?
restore_flags
fi
fi
return $err
}
append_header(){
echo "$@" >> $TMPH
}
append_config(){
echo "$@" >> $CONFIGFILE
}
# set temporary file name
if test ! -z "$TMPDIR" ; then
TMPDIR1="${TMPDIR}"
elif test ! -z "$TEMPDIR" ; then
TMPDIR1="${TEMPDIR}"
else
TMPDIR1="/tmp"
fi
TMPC="${TMPDIR1}/omc-${RANDOM}-$$-${RANDOM}.c"
TMPO="${TMPDIR1}/omc-${RANDOM}-$$-${RANDOM}.o"
TMPE="${TMPDIR1}/omc-${RANDOM}-$$-${RANDOM}"
TMPS="${TMPDIR1}/omc-${RANDOM}-$$-${RANDOM}.S"
TMPH="${TMPDIR1}/omc-${RANDOM}-$$-${RANDOM}.h"
CONFIGFILE="config.mak"
#################################################
# set default parameters
#################################################
logging="yes"
logfile="config.log"
PREFIX="/usr/local"
bindir='${PREFIX}/bin'
datadir='${PREFIX}/share'
sysconfdir='${PREFIX}/etc'
libdir='${PREFIX}/lib'
includedir='${PREFIX}/include'
mandir='${PREFIX}/man'
cc="gcc"
ar="ar"
ranlib="ranlib"
make="make"
strip="strip"
cpu=`uname -m`
optimize="yes"
debug="yes"
dostrip="yes"
extralibs=""
installstrip="-s"
cross_compile="no"
INSTALL="install"
#################################################
# set cpu variable and specific cpu flags
#################################################
case "$cpu" in
i386|i486|i586|i686|i86pc|BePC)
cpu="x86"
;;
x86_64|amd64)
cpu="x86"
canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
if [ -z "`echo $CFLAGS | grep -- -m32`" ]; then
cpu="x86_64"
fi
fi
;;
# armv4l is a subset of armv5tel
arm|armv4l|armv5tel)
cpu="armv4l"
;;
alpha)
cpu="alpha"
;;
"Power Macintosh"|ppc|ppc64|powerpc)
cpu="powerpc"
;;
mips|mipsel|IP*)
cpu="mips"
;;
sun4u|sparc64)
cpu="sparc64"
;;
sparc)
cpu="sparc"
;;
sh4)
cpu="sh4"
;;
parisc|parisc64)
cpu="parisc"
;;
s390|s390x)
cpu="s390"
;;
m68k)
cpu="m68k"
;;
ia64)
cpu="ia64"
;;
bfin)
cpu="bfin"
;;
*)
cpu="unknown"
;;
esac
#################################################
# check options
#################################################
for opt do
optval="${opt#*=}"
case "$opt" in
--log)
;;
--log=*) logging="$optval"
;;
--prefix=*) PREFIX="$optval"; force_prefix=yes
;;
--bindir=*) bindir="$optval"
;;
--datadir=*) datadir="$optval"
;;
--sysconfdir=*) sysconfdir="$optval"
;;
--libdir=*) libdir="$optval"; force_libdir=yes
;;
--includedir=*) includedir="$optval"
;;
--mandir=*) mandir="$optval"
;;
--disable-debug) debug="no"
;;
--disable-strip) dostrip="no"
;;
--disable-optimize) optimize="no"
;;
--cross-prefix=*) cross_prefix="$optval"
;;
--cross-compile) cross_compile="yes"
;;
--with-sdl-prefix=*) sdlprefix="$optval";
;;
--with-curl-prefix=*) curlprefix="$optval";
;;
--with-libplayer-dir=*) libplayerdir="$optval";
;;
--help) show_help
;;
*)
echo "Unknown option \"$opt\"."
echo "See $0 --help for available options."
exit 1
;;
esac
done
if [ -n "$cross_prefix" ]; then
cross_compile="yes"
cc="${cross_prefix}${cc}"
ar="${cross_prefix}${ar}"
ranlib="${cross_prefix}${ranlib}"
strip="${cross_prefix}${strip}"
else
[ -n "$CC" ] && cc="$CC"
[ -n "$AR" ] && ar="$AR"
[ -n "$RANLIB" ] && ranlib="$RANLIB"
[ -n "$STRIP" ] && strip="$STRIP"
fi
[ -n "$MAKE" ] && make="$MAKE"
#################################################
# create logging file
#################################################
if test "$logging" != no; then
enabled logging || logfile="$logging"
echo "# $0 $@" >$logfile
set >>$logfile
else
logfile=/dev/null
fi
#################################################
# compiler sanity check
#################################################
echolog "Checking for compiler available ..."
check_exec <<EOF
int main(){
return 0;
}
EOF
if test "$?" != 0; then
echo "$cc is unable to create an executable file."
if test -z "$cross_prefix" -a "$cross_compile" = no; then
echo "If $cc is a cross-compiler, use the --cross-compile option."
fi
die "C compiler test failed."
fi
#################################################
# check for target specific flags
#################################################
# check for SIMD availability
# AltiVec flags: The FSF version of GCC differs from the Apple version
if test $cpu = "powerpc"; then
if test $altivec = "yes"; then
if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
add_cflags "-faltivec"
else
add_cflags "-maltivec -mabi=altivec"
fi
fi
fi
check_header altivec.h && _altivec_h=yes || _altivec_h=no
# check if our compiler supports Motorola AltiVec C API
if enabled altivec; then
if enabled _altivec_h; then
inc_altivec_h="#include <altivec.h>"
else
inc_altivec_h=
fi
check_cc <<EOF || altivec=no
$inc_altivec_h
int main(void) {
vector signed int v1, v2, v3;
v1 = vec_add(v2,v3);
return 0;
}
EOF
fi
# mmi only available on mips
if [ "$mmi" = "default" ]; then
if [ "$cpu" = "mips" ]; then
mmi="yes"
else
mmi="no"
fi
fi
# check if our compiler supports mmi
enabled mmi && check_cc <<EOF || mmi="no"
int main(void) {
__asm__ ("lq \$2, 0(\$2)");
return 0;
}
EOF
# test gcc version to see if vector builtins can be used
# currently only used on i386 for MMX builtins
check_cc -msse <<EOF && builtin_vector=yes || builtin_vector=no
#include <xmmintrin.h>
int main(void) {
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
return 0;
#else
#error no vector builtins
#endif
}
EOF
# test for mm3dnow.h
test "$cpu" = "x86_64" && march=k8 || march=athlon
check_cc -march=$march <<EOF && mm3dnow=yes || mm3dnow=no
#include <mm3dnow.h>
int main(void) {
__m64 b1;
b1 = _m_pswapd(b1);
_m_femms();
return 0;
}
EOF
# ---
# big/little-endian test
if test "$cross_compile" = "no"; then
check_ld <<EOF || die "endian test failed" && $TMPE && bigendian="yes"
#include <inttypes.h>
int main(int argc, char ** argv){
volatile uint32_t i=0x01234567;
return (*((uint8_t*)(&i))) == 0x67;
}
EOF
else
# programs cannot be launched if cross compiling, so make a static guess
if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then
bigendian="yes"
fi
fi
#################################################
# check for libplayer
#################################################
#echolog "Checking for libplayer ..."
#if [ -n "$libplayerdir" ]; then
# check_cflags -I$libplayerdir
# check_ldflags -L$libplayerdir
#fi
#check_lib player.h player_init -lplayer || die "Error, can't find libplayer !"
#################################################
# check for SDL
#################################################
echolog "Checking for libsdl ..."
sdlconfig="/usr/bin/sdl-config"
[ -n "$sdlprefix" ] && sdlconfig="$sdlprefix/bin/sdl-config"
check_libconfig $sdlconfig SDL_Init ||
{
if [ -n "$sdlprefix" ]; then
check_cflags -I$sdlprefix/include
check_ldflags -L$sdlprefix/lib
fi
check_lib SDL.h SDL_Init -lSDL;
} || die "Error, can't find libsdl !"
#################################################
# check for SDL_image
#################################################
echolog "Checking for libsdl_image ..."
{
if [ -n "$sdlprefix" ]; then
check_cflags -I$sdlprefix/include
check_ldflags -L$sdlprefix/lib
fi
check_lib SDL_image.h IMG_Load -lSDL_image;
} || die "Error, can't find libsdl_image !"
#################################################
# check for SDL_gfx
#################################################
echolog "Checking for libsdl_gfx ..."
{
if [ -n "$sdlprefix" ]; then
check_cflags -I$sdlprefix/include
check_ldflags -L$sdlprefix/lib
fi
check_lib SDL_rotozoom.h zoomSurface -lSDL_gfx;
} || die "Error, can't find libsdl_gfx !"
#################################################
# check for SDL_ttf
#################################################
echolog "Checking for libsdl_ttf ..."
{
if [ -n "$sdlprefix" ]; then
check_cflags -I$sdlprefix/include
check_ldflags -L$sdlprefix/lib
fi
check_lib SDL_ttf.h TTF_OpenFont -lSDL_ttf;
} || die "Error, can't find libsdl_ttf !"
#################################################
# check for libcurl
#################################################
#echolog "Checking for libcurl ..."
#curlconfig="/usr/bin/curl-config"
#[ -n "$curlprefix" ] && curlconfig="$curlprefix/bin/curl-config"
#check_libconfig $curlconfig curl_version ||
#{
# if [ -n "$curlprefix" ]; then
# check_cflags -I$curlprefix/include
# check_ldflags -L$curlprefix/lib
# fi
# check_lib curl/curl.h curl_version -lcurl;
#} || die "Error, can't find libcurl !"
#################################################
# checking for libpthread
#################################################
echolog "Checking for libpthread ..."
check_lib pthread.h pthread_create -lpthread ||
check_func pthread_create ||
die "Error, can't find libpthread"
enabled debug && add_cflags -g3
# add some useful compiler flags if supported
check_cflags -Wall
#check_cflags -W
check_cflags -D_LARGEFILE_SOURCE
check_cflags -D_FILE_OFFSET_BITS=64
check_cflags -D_REENTRANT
if enabled optimize; then
if test -n "`$cc -v 2>&1 | grep xlc`"; then
add_cflags "-O5"
add_ldflags "-O5"
else
add_cflags "-O3"
fi
fi
#################################################
# logging result
#################################################
echolog ""
echolog "omc: configure is OK"
echolog "configuration:"
echolog " install prefix $PREFIX"
echolog " C compiler $cc"
echolog " AR $ar"
echolog " RANLIB $ranlib"
echolog " STRIP $strip"
echolog " make $make"
echolog " CPU $cpu ($tune)"
echolog " debug symbols $debug"
echolog " strip symbols $dostrip"
echolog " optimize $optimize"
echolog ""
echolog " CFLAGS $CFLAGS"
echolog " LDFLAGS $LDFLAGS"
echolog " extralibs $extralibs"
echolog ""
#################################################
# save configs attributes
#################################################
echolog "Creating config.mak and config.h..."
echo "# Automatically generated by configure - do not modify!" > $CONFIGFILE
echo "/* Automatically generated by configure - do not modify! */" > $TMPH
append_config "PREFIX=$PREFIX"
append_config "prefix=\$(DESTDIR)\$(PREFIX)"
append_config "bindir=\$(DESTDIR)$bindir"
append_config "datadir=\$(DESTDIR)$datadir"
append_config "sysconfdir=\$(DESTDIR)$sysconfdir"
append_config "libdir=\$(DESTDIR)$libdir"
append_config "includedir=\$(DESTDIR)$includedir"
append_config "mandir=\$(DESTDIR)$mandir"
append_config "MAKE=$make"
append_config "CC=$cc"
append_config "AR=$ar"
append_config "RANLIB=$ranlib"
if enabled dostrip; then
append_config "STRIP=$strip"
append_config "INSTALLSTRIP=$installstrip"
else
append_config "STRIP=echo ignoring strip"
append_config "INSTALLSTRIP="
fi
append_config "EXTRALIBS=$extralibs"
append_config "OPTFLAGS=$CFLAGS"
append_config "LDFLAGS=$LDFLAGS"
append_config "INSTALL=$INSTALL"
eval CFG_DIR="$sysconfdir/omc"
append_header "#define CFG_DIR \"$CFG_DIR\""
append_config "CFG_DIR=\$(sysconfdir)/omc"
eval DATA_DIR="$datadir/omc"
append_header "#define DATA_DIR \"$DATA_DIR\""
append_config "DATA_DIR=\$(datadir)/omc"
#################################################
# save config.h file
#################################################
# Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
diff $TMPH config.h >/dev/null 2>&1
if test "$?" != "0" ; then
mv -f $TMPH config.h
else
echolog "config.h is unchanged"
fi
clean
exit 0