-
Notifications
You must be signed in to change notification settings - Fork 631
/
configure
executable file
·123 lines (99 loc) · 2.55 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
#!/bin/sh
prefix=/usr/local
develflg=0
usage() {
echo "supported arguments"
echo "--prefix=/path default: $prefix"
echo "--exec_prefix=/path default: $prefix/bin"
echo "--bindir=/path default: $prefix/bin"
echo "--libdir=/path default: $prefix/lib"
echo "--includedir=/path default: $prefix/include"
echo "--sysconfdir=/path default: $prefix/etc"
echo "--devel default:no (set development mode)"
echo "--help : show this text"
exit 1
}
spliteq() {
arg=$1
echo "${arg#*=}"
#alternatives echo "$arg" | cut -d= -f2-
# or echo "$arg" | sed 's/[^=]*=//'
}
parsearg() {
case "$1" in
--prefix=*) prefix=`spliteq $1`;;
--exec_prefix=*) exec_prefix=`spliteq $1`;;
--bindir=*) bindir=`spliteq $1`;;
--libdir=*) libdir=`spliteq $1`;;
--includedir=*) includedir=`spliteq $1`;;
--sysconfdir=*) sysconfdir=`spliteq $1`;;
--devel) develflg=1;;
--help) usage;;
esac
}
ismac() {
uname -s | grep Darwin
}
isbsd() {
uname -s | grep BSD
}
islinux() {
uname -s | grep Linux
}
while true ; do
case $1 in
-*) parsearg "$1"; shift;;
*) break ;;
esac
done
if [ -z "$exec_prefix" ] ; then
exec_prefix=$prefix
fi
if [ -z "$libdir" ] ; then
libdir=$prefix/lib
fi
if [ -z "$includedir" ] ; then
includedir=$prefix/include
fi
if [ -z "$sysconfdir" ] ; then
sysconfdir=$prefix/etc
fi
if [ -z "$bindir" ] ; then
bindir=$exec_prefix/bin
fi
if [ -z "$CC" ] ; then
CC=cc
fi
if [ $develflg -eq 1 ]; then
CFLAGS="-Wextra -Wunused -Wuninitialized -Wconversion -fno-common -g -O0 -DDEBUG"
fi
echo CC?=$CC>config.mak
[ -z "$CPPFLAGS" ] || echo CPPFLAGS?=$CPPFLAGS>>config.mak
[ -z "$CFLAGS" ] || echo USER_CFLAGS?=$CFLAGS>>config.mak
[ -z "$LDFLAGS" ] || echo USER_LDFLAGS?=$LDFLAGS>>config.mak
echo prefix=$prefix>>config.mak
echo exec_prefix=$exec_prefix>>config.mak
echo bindir=$bindir>>config.mak
echo libdir=$libdir>>config.mak
echo includedir=$includedir>>config.mak
echo sysconfdir=$sysconfdir>>config.mak
if ismac ; then
arch=`uname -m`
echo LDSO_SUFFIX=dylib>>config.mak
echo OS_CFLAGS+=-DIS_MAC=1 -arch $arch >>config.mak
echo OS_LDFLAGS+=-arch $arch -lpthread -ldl -Wl,>>config.mak
echo LD_SET_SONAME=-Wl,-install_name,>>config.mak
echo LDSO_SUFFIX=dylib>>config.mak
echo INSTALL_FLAGS=-m>>config.mak
fi
if islinux ; then
echo OS_LDFLAGS=-pthread -ldl -Wl,--no-as-needed>>config.mak
echo LD_SET_SONAME=-Wl,-soname= >>config.mak
fi
if isbsd ; then
#echo OS_LDFLAGS=
#echo OS_CFLAGS
echo INSTALL_FLAGS=-m>>config.mak
echo LD_SET_SONAME=-Wl,-rpath,$libdir -install_name,>>config.mak
fi
echo done, now run make \&\& make install