forked from treefrogframework/treefrog-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·187 lines (164 loc) · 4.14 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
#!/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
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
KERNEL=`uname -s`
MACHINE=`uname -m`
RELEASE=`uname -r`
if [ "$QMAKESPEC" != "" ]; then
OPT="-spec $QMAKESPEC"
if [ "$MACHINE" = "x86_64" ]; then
OPT="$OPT CONFIG+=x86_64"
fi
elif [ "$KERNEL" = "Darwin" ]; then
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
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 [ "$KERNEL" = "Linux" ]; then
OPT="-spec linux-g++"
elif [ "$KERNEL" = "FreeBSD" ]; then
OPT="-spec freebsd-clang"
fi
if [ "$MACHINE" = "x86_64" ]; then
OPT="$OPT CONFIG+=x86_64"
fi
fi
else
echo "uname: command not found"
exit
fi
# default values
BASEDIR=`pwd`/`dirname $0`
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"
;;
--help | -help | -h | *)
usage
exit
;;
esac
shift
done
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-qt4 >/dev/null 2>&1 && QMAKE=qmake-qt4
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
fi
fi
cd "$BASEDIR/src"
[ -f Makefile ] && make -k distclean >/dev/null 2>&1
$QMAKE $OPT target.path=\"$LIBDIR\" header.path=\"$INCLUDEDIR\" $ENABLE_GUI
cd "$BASEDIR/tools"
[ -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
cd "$BASEDIR/3rdparty/mongo-c-driver"
echo
echo -n "Compiling MongoDB driver library ... "
$QMAKE $OPT mongo-c-driver.pro
make clean >/dev/null 2>&1
make >/dev/null 2>&1
RET=$?
if [ $RET != 0 ]; then
echo "failed"
echo "MongoDB driver 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."