forked from treefrogframework/treefrog-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·226 lines (202 loc) · 5.43 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
#!/usr/bin/env bash
#
# Guess values for system-dependent variables and create Makefiles.
#
# usage message
usage()
{
cat <<_EOF
Usage: $0 [OPTION]... [VAR=VALUE]...
Configuration:
-h, --help display this help and exit
--enable-debug compile with debugging information
--enable-gui-mod compile and link with QtGui module
--enable-shared-mongoc link the mongoc shared library
--spec=SPEC use SPEC as QMAKESPEC
Installation directories:
--prefix=PREFIX install files in PREFIX [$PREFIX]
Fine tuning of the installation directories:
--bindir=DIR user executables [$BINDIR]
--libdir=DIR object code libraries [$LIBDIR]
--includedir=DIR C++ header files [$INCLUDEDIR]
--datadir=DIR read-only architecture-independent data [$DATADIR]
_EOF
}
# absorbs the difference of GNU sed and BSD sed
replace()
{
[ ! -f "$2" ] && return
sed -e "$1" "$2" > "$2".$$
mv -f "$2".$$ "$2"
}
# check the platform
if ! which uname >/dev/null 2>&1; then
echo "uname: command not found"
exit
fi
# default values
BASEDIR=`pwd`/`dirname $0`
KERNEL=`uname -s`
MACHINE=`uname -m`
RELEASE=`uname -r`
NPROC=`nproc 2>/dev/null`
if [ "$KERNEL" = "Darwin" ]; then
PREFIX=/usr/local
else
PREFIX=/usr
fi
BINDIR=$PREFIX/bin
LIBDIR=$PREFIX/lib
INCLUDEDIR=$PREFIX/include/treefrog
DATADIR=$PREFIX/share/treefrog
# parse options
while [ -n "`echo $1 | grep '-'`" ]; do
case $1 in
*=?*) optarg=`expr "X$1" : '[^=]*=\(.*\)'` ;;
*=) optarg= ;;
*) optarg=yes ;;
esac
case $1 in
--prefix=*)
PREFIX=$optarg
BINDIR=$PREFIX/bin
LIBDIR=$PREFIX/lib
INCLUDEDIR=$PREFIX/include/treefrog
DATADIR=$PREFIX/share/treefrog
;;
--bindir=*)
BINDIR=$optarg
;;
--libdir=*)
LIBDIR=$optarg
;;
--includedir=*)
INCLUDEDIR=$optarg
;;
--datadir=*)
DATADIR=$optarg
;;
--enable-debug | --enable-debug=*)
ENABLE_DEBUG=yes
;;
--enable-gui-mod | --enable-gui-mod=*)
ENABLE_GUI="use_gui=1"
;;
--enable-shared-mongoc | --enable-shared-mongoc=*)
ENABLE_SHARED_MONGOC="shared_mongoc=1"
;;
--spec=*)
SPEC=$optarg
;;
--help | -help | -h | *)
usage
exit
;;
esac
shift
done
# spec
if [ "$SPEC" != "" ]; then
OPT="-spec $SPEC"
elif [ "$QMAKESPEC" != "" ]; then
OPT="-spec $QMAKESPEC"
elif [ "$KERNEL" = "Darwin" ]; then # macOS
QT_VERSION=$(echo $(qmake -v) | awk '{ print $7 }')
QT_MAJOR=${QT_VERSION:0:1}
if [ "$QT_MAJOR" -ge 5 ]; then
OPT="-spec macx-clang"
else
OPT="-spec macx-g++"
fi
elif [ "$KERNEL" = "Linux" ]; then
OPT="-spec linux-g++"
elif [ "$KERNEL" = "FreeBSD" ]; then
OPT="-spec freebsd-clang"
fi
# x64 config
if [ "$KERNEL" = "Darwin" ]; then # macOS
REL=`echo $RELEASE | tr -d '.'`
if [ "$REL" -ge 1050 ]; then
OPT="$OPT CONFIG+=x86_64"
fi
if [ "$MACHINE" = "ppc" ]; then
OPT="$OPT CONFIG+=ppc"
fi
else
if [ "$MACHINE" = "x86_64" ]; then
OPT="$OPT CONFIG+=x86_64"
fi
fi
cd "$BASEDIR"
replace "s|unix:LIBS +=.*$|unix:LIBS += -Wl,-rpath,. -Wl,-rpath,$LIBDIR -L$LIBDIR -ltreefrog|" defaults/appbase.pri
replace "s|unix:INCLUDEPATH +=.*$|unix:INCLUDEPATH += $INCLUDEDIR|" defaults/appbase.pri
if [ -n "$ENABLE_DEBUG" ]; then
OPT="$OPT CONFIG+=debug"
else
OPT="$OPT CONFIG+=release"
fi
# search qmake command
if [ -z "$QMAKE" ]; then
which qmake-qt5 >/dev/null 2>&1 && QMAKE=qmake-qt5
which qmake >/dev/null 2>&1 && QMAKE=qmake
if [ -z "$QMAKE" ]; then
echo "qmake: command not found"
echo
exit 1
fi
fi
if [ -z "$ENABLE_SHARED_MONGOC" ] && ! which cmake >/dev/null 2>&1; then
echo "cmake: command not found"
echo
exit 1
fi
cd "$BASEDIR/src"
rm -f .qmake.stash
[ -f Makefile ] && make -k distclean >/dev/null 2>&1
$QMAKE $OPT target.path=\"$LIBDIR\" header.path=\"$INCLUDEDIR\" $ENABLE_GUI $ENABLE_SHARED_MONGOC
cd "$BASEDIR/tools"
rm -f .qmake.stash
[ -f Makefile ] && make -k distclean >/dev/null 2>&1
$QMAKE -recursive $OPT target.path=\"$BINDIR\" header.path=\"$INCLUDEDIR\" datadir=\"$DATADIR\" lib.path=\"$LIBDIR\"
make qmake
# compile MongoDB files
if [ -z "$ENABLE_SHARED_MONGOC" ]; then
echo
echo -n "Compiling MongoDB driver library ... "
cd "$BASEDIR/3rdparty/mongo-driver/src/libbson"
rm -rf CMakeCache.txt cmake_install.cmake CMakeFiles Makefile
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_STATIC=ON -DENABLE_TESTS=OFF -DCMAKE_C_FLAGS="-fPIC" . >/dev/null 2>&1
make clean >/dev/null 2>&1
make -j${NPROC} bson_static >/dev/null 2>&1
cd "$BASEDIR/3rdparty/mongo-driver"
rm -rf CMakeCache.txt cmake_install.cmake CMakeFiles Makefile
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_STATIC=ON -DENABLE_SSL=OFF -DENABLE_SNAPPY=OFF -DENABLE_SRV=OFF -DENABLE_SASL=OFF -DENABLE_ZLIB=OFF -DENABLE_TESTS=OFF -DCMAKE_C_FLAGS="-fPIC" . >/dev/null 2>&1
make clean >/dev/null 2>&1
make -j${NPROC} mongoc_static >/dev/null 2>&1
RET=$?
if [ $RET != 0 ]; then
echo "failed"
echo "MongoDB driver not available."
exit $RET
fi
echo "OK"
fi
# compile LZ4
cd "$BASEDIR/3rdparty/lz4"
echo
echo -n "Compiling LZ4 ... "
make clean >/dev/null 2>&1
CPPFLAGS="-fPIC" make -j${NPROC} lib >/dev/null 2>&1
RET=$?
if [ $RET != 0 ]; then
CPPFLAGS="-fPIC" make SHELL='bash -x' lib
echo "failed"
echo "LZ4 not available."
exit $RET
fi
echo "OK"
echo
echo "First, run \"make\" and \"sudo make install\" in src directory."
echo "Next, run \"make\" and \"sudo make install\" in tools directory."