-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·106 lines (87 loc) · 2.07 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
#!/bin/sh
opt=false
dbg=true
prefix=/usr/local
libdir=lib
for arg in $*; do
case $arg in
--enable-opt)
opt=true
;;
--disable-opt)
opt=false
;;
--enable-debug)
dbg=true
;;
--disable-debug)
dbg=false
;;
--prefix=*)
prefix=`echo $arg | sed 's/--prefix=//'`
;;
--libdir=*)
libdir=`echo $arg | sed 's/--libdir=//'`
;;
*)
;;
esac
done
sys=`uname -s | sed 's/MINGW.*/mingw/'`
testsrc=/tmp/meshfile_cfg_test.c
testbin=/tmp/meshfile_cfg_test
testlog=/tmp/meshfile_cfg_test.log
run_test() {
if ! $CC -o $testbin $testsrc >$testlog 2>&1; then
echo "failed to compile test program, see $testlog" >&2
exit 1
fi
$testbin && return 0 || return 1
}
if [ -z "$CC" ]; then
CC=cc
fi
# check if CC is gcc
echo 'int main(void) {' >$testsrc
echo '#ifdef __GNUC__' >>$testsrc
echo ' return 0;' >>$testsrc
echo '#endif' >>$testsrc
echo ' return 1;' >>$testsrc
echo '}' >>$testsrc
run_test && cc_is_gcc=true || cc_is_gcc=false
$cc_is_gcc && echo 'compiler is gcc or compatible'
echo "optimizations: $opt"
echo "debug symbols: $dbg"
echo "install prefix: $prefix"
cfgmk=config.mk
echo "# Generated by: $0 $*" >$cfgmk
echo "PREFIX = $prefix" >>$cfgmk
echo "libdir = $libdir" >>$cfgmk
echo 'src =' `ls src/*.c | sort` >>$cfgmk
echo >>$cfgmk
$opt && echo 'opt = -O3' >>$cfgmk
$dbg && echo 'dbg = -g' >>$cfgmk
if $cc_is_gcc; then
echo 'warn = -pedantic -Wall -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast' >>$cfgmk
echo 'dep = -MMD' >>$cfgmk
fi
echo >>$cfgmk
if [ "$sys" = mingw ]; then
# windows/mingw
echo 'libso = libmeshfile.dll' >>$cfgmk
echo 'shared = -shared' >>$cfgmk
elif [ "$sys" = Darwin ]; then
# macosx
echo 'libso = libmeshfile.dylib' >>$cfgmk
echo 'shared = -dynamiclib' >>$cfgmk
else
# other UNIX
echo 'ldname = libmeshfile.so' >>$cfgmk
echo 'soname = $(ldname).$(somajor)' >>$cfgmk
echo 'libso = $(ldname).$(somajor).$(sominor)' >>$cfgmk
echo 'shared = -shared -Wl,-soname,$(soname)' >>$cfgmk
echo 'pic = -fPIC' >>$cfgmk
fi
[ -n "$CFLAGS" ] && echo "CFLAGS_cfg = $CFLAGS" >>$cfgmk
[ -n "$LDFLAGS" ] && echo "LDFLAGS_cfg = $LDFLAGS" >>$cfgmk
exit 0