-
Notifications
You must be signed in to change notification settings - Fork 33
/
configure
executable file
·291 lines (272 loc) · 10.4 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
#!/bin/bash
# defaults
QMAKE_BIN=qmake
WHICH=which
NO_DB=0
NO_ZEROCONF=0
NO_OPENSSL=0
NO_XRANDR=0
QXT_MODULES="docs berkeley core designer gui network sql web zeroconf"
# detect platform
if uname -a | grep -iq Darwin; then
QXT_MAC=1
DEFAULT_LIBS="/Library/Frameworks"
QMAKE_PARAMS="-spec macx-g++"
NO_XRANDR=1
else
QXT_MAC=0
DEFAULT_LIBS="PREFIX/lib"
QMAKE_PARAMS=""
fi
# working directories
QXT_SOURCE_TREE=`dirname $0`
QXT_SOURCE_TREE=`(cd "$QXT_SOURCE_TREE"; /bin/pwd)`
QXT_BUILD_TREE=`/bin/pwd`
[ ! -d $QXT_BUILD_TREE/features ] && mkdir $QXT_BUILD_TREE/features
[ ! -d $QXT_BUILD_TREE/examples ] && mkdir $QXT_BUILD_TREE/examples
[ ! -d $QXT_BUILD_TREE/tests ] && mkdir $QXT_BUILD_TREE/tests
# output files
CONFIG_LOG=$QXT_BUILD_TREE/config.log
QMAKE_CACHE=$QXT_BUILD_TREE/.qmake.cache
QXT_VARS=$QXT_BUILD_TREE/features/qxtvars.prf
[ -f $CONFIG_LOG ] && mv $CONFIG_LOG $CONFIG_LOG.bak
[ -f $QMAKE_CACHE ] && mv $QMAKE_CACHE $QMAKE_CACHE.bak
[ -f $QXT_VARS ] && mv $QXT_VARS $QXT_VARS.bak
# colors
C_RED='\e[1;31m'
C_BLUE='\e[1;34m'
C_GREEN='\e[1;32m'
C_CYAN='\e[1;36m'
C_NONE='\e[0m'
# defaults
echo "CONFIG += silent" > $QMAKE_CACHE
echo "QXT_MODULES = $QXT_MODULES" >> $QMAKE_CACHE
echo "QXT_MODULES = $QXT_MODULES" > $QXT_VARS
# parse configure options
while (( $# > 0 )); do
if [ $1 == "-qmake-bin" ]; then
QMAKE_BIN=$2; shift
elif [ $1 == "-L" ]; then
echo "LIBS += -L$2" >> $QMAKE_CACHE;shift
elif [ $1 == "-l" ]; then
echo "LIBS += -l$2" >> $QMAKE_CACHE;shift
elif [ $1 == "-I" ]; then
echo "INCLUDEPATH += $2" >> $QMAKE_CACHE;shift
elif [ $1 == "-bootstrap" ]; then
echo "CONFIG += bootstrap" >> $QMAKE_CACHE; shift
elif [ $1 == "-nomake" ]; then
echo "QXT_MODULES -= $2" >> $QMAKE_CACHE
echo "QXT_MODULES -= $2" >> $QXT_VARS; shift
elif [ $1 == "-prefix" ]; then
QXT_INSTALL_PREFIX=$2; shift
elif [ $1 == "-libdir" ]; then
QXT_INSTALL_LIBS=$2; shift
elif [ $1 == "-docdir" ]; then
QXT_INSTALL_DOCS=$2; shift
elif [ $1 == "-headerdir" ]; then
QXT_INSTALL_HEADERS=$2; shift
elif [ $1 == "-bindir" ]; then
QXT_INSTALL_BINS=$2; shift
elif [ $1 == "-featuredir" ]; then
QXT_INSTALL_FEATURES=$2; shift
elif [ $1 == "-static" ]; then
echo "CONFIG += static staticlib" >> $QMAKE_CACHE
echo "DEFINES += QXT_STATIC" >> $QXT_VARS
elif [ $1 == "-debug" ]; then
echo "CONFIG += debug" >> $QMAKE_CACHE
echo "QXT_INSTALL_TYPE = debug" >> $QXT_VARS
elif [ $1 == "-release" ]; then
echo "CONFIG += release" >> $QMAKE_CACHE
echo "QXT_INSTALL_TYPE = release" >> $QXT_VARS
elif [ $1 == "-no-db" ]; then
NO_DB=1
elif [ $1 == "-no-xrandr" ]; then
NO_XRANDR=1
elif [ $1 == "-no-zeroconf" ]; then
NO_ZEROCONF=1
elif [ $1 == "-no-openssl" ]; then
NO_OPENSSL=1
elif [ $1 == "-no-avahi" ]; then
echo "CONFIG += NO_AVAHI" >> $QMAKE_CACHE
elif [ $1 == "-verbose" ]; then
echo "CONFIG -= silent" >> $QMAKE_CACHE
elif [ $1 == "-qws" ]; then
echo "CONFIG += qws" >> $QMAKE_CACHE
elif [ $1 == "-coverage" ]; then
echo "CONFIG += coverage" >> $QMAKE_CACHE
elif [ $1 == "-universal" ]; then
echo "CONFIG += x86 ppc" >> $QMAKE_CACHE
elif [ $1 == "-arch" ]; then
echo "CONFIG += $2" >> $QMAKE_CACHE
shift
elif [ $1 == "-sdk" ]; then
echo "QMAKE_MAC_SDK=$2" >> $QMAKE_CACHE; shift
elif [ $1 == "-h" ] || [ $1 == "-help" ] || [ $1 == "--help" ]; then
echo "Usage: configure [-prefix <dir>] [-libdir <dir>] [-docdir <dir>]"
echo " [-bindir <dir>] [-headerdir <dir>] [-featuredir <dir> ]"
echo " [-qmake-bin <path>] [-static] [-debug] [-release]"
echo " [-no-db] [-no-zeroconf] [-nomake <module>]"
if [[ "$QXT_MAC" == "0" ]]; then
echo -n " [-no-xrandr] [-qws]"
else
echo -n " [-universal] [-arch <arch>] [-sdk <path>]"
fi
echo " [-verbose] [-coverage]"
echo
echo "Installation options:"
echo
echo "-prefix <dir> ....... This will install everything relative to <dir>"
echo " default: /usr/local/Qxt"
echo "-libdir <dir> ....... Libraries will be installed to <dir>"
echo " default: $DEFAULT_LIBS"
echo "-docdir <dir> ....... Documentation will be installed to <dir>"
echo " default: PREFIX/doc"
echo "-bindir <dir> ....... Executables will be installed to <dir>"
echo " default: PREFIX/bin"
echo "-headerdir <dir> .... Include files will be installed to <dir>"
echo " default: PREFIX/include"
echo "-featuredir <dir> ... Feature files will be installed to <dir>"
echo " default: QMAKE_MKSPECS/features"
echo "-qmake-bin <path> ... Specifies the path to the qmake executable"
echo " default: search the system path"
echo "-L <path> ........... Specifies the a additional library search path"
echo "-I <path> ........... Specifies the a additional include search path"
echo "-l <path> ........... Add a custom library"
echo "-static ............. Build Qxt as a static library"
echo "-debug .............. Build Qxt with debugging symbols"
echo "-release ............ Build Qxt without debugging support"
if [[ "$QXT_MAC" != "1" ]]; then
echo "-qws ................ Build for Qt/Embedded"
echo "-no-xrandr ......... Do not link to Xrandr"
fi
echo "-no-db .............. Do not link to Berkeley DB"
echo "-no-zeroconf ........ Do not link to Zeroconf"
echo "-no-openssl ......... Do not link to Openssl"
echo "-no-avahi ........... Apple mdns-sd instead of avahi even on linux"
echo "-nomake <module> .... Do not compile the specified module"
echo " options: $QXT_MODULES"
echo "-verbose ............ Show full compiler output"
echo "-coverage ........... Collect coverage information"
if [[ "$QXT_MAC" == "1" ]]; then
echo "-universal .......... Equivalent to -arch ppc -arch x86"
echo "-arch <arch> ........ Include <arch> in universal binary"
echo "-sdk <path> ......... Use a different Mac SDK"
fi
[ -f $CONFIG_LOG.bak ] && mv $CONFIG_LOG.bak $CONFIG_LOG
[ -f $QMAKE_CACHE.bak ] && mv $QMAKE_CACHE.bak $QMAKE_CACHE
[ -f $QXT_VARS.bak ] && mv $QXT_VARS.bak $QXT_VARS
exit
else
echo "Unrecognized configure option: $1"
[ -f $CONFIG_LOG.bak ] && mv $CONFIG_LOG.bak $CONFIG_LOG
[ -f $QMAKE_CACHE.bak ] && mv $QMAKE_CACHE.bak $QMAKE_CACHE
[ -f $QXT_VARS.bak ] && mv $QXT_VARS.bak $QXT_VARS
exit
fi
shift
done
# detect qmake
if ! $WHICH $QMAKE_BIN >>$CONFIG_LOG 2>&1; then
echo >&2 "You don't seem to have 'qmake' in your PATH."
echo >&2 "Cannot proceed."
exit 1
fi
# default directories
if [[ "$QXT_INSTALL_PREFIX" == "" ]]; then
QXT_INSTALL_PREFIX="/usr/local/Qxt"
fi
if [[ "$QXT_INSTALL_LIBS" == "" ]]; then
if [[ "$QXT_MAC" == "1" ]]; then
QXT_INSTALL_LIBS="/Library/Frameworks"
else
QXT_INSTALL_LIBS="$QXT_INSTALL_PREFIX/lib"
fi
fi
if [[ "$QXT_INSTALL_DOCS" == "" ]]; then
QXT_INSTALL_DOCS="$QXT_INSTALL_PREFIX/doc"
fi
if [[ "$QXT_INSTALL_HEADERS" == "" ]]; then
QXT_INSTALL_HEADERS="$QXT_INSTALL_PREFIX/include"
fi
if [[ "$QXT_INSTALL_BINS" == "" ]]; then
QXT_INSTALL_BINS="$QXT_INSTALL_PREFIX/bin"
fi
if [[ "$QXT_INSTALL_FEATURES" == "" ]]; then
QXT_INSTALL_FEATURES=`$QMAKE_BIN -query QMAKE_MKSPECS`
QXT_INSTALL_FEATURES="$QXT_INSTALL_FEATURES/features"
fi
# output variables
echo "QXT_INSTALL_PREFIX = $QXT_INSTALL_PREFIX" >> $QMAKE_CACHE
echo "QXT_INSTALL_PREFIX = $QXT_INSTALL_PREFIX" >> $QXT_VARS
echo "QXT_INSTALL_LIBS = $QXT_INSTALL_LIBS" >> $QMAKE_CACHE
echo "QXT_INSTALL_LIBS = $QXT_INSTALL_LIBS" >> $QXT_VARS
echo "QXT_INSTALL_BINS = $QXT_INSTALL_BINS" >> $QMAKE_CACHE
echo "QXT_INSTALL_BINS = $QXT_INSTALL_BINS" >> $QXT_VARS
echo "QXT_INSTALL_HEADERS = $QXT_INSTALL_HEADERS" >> $QMAKE_CACHE
echo "QXT_INSTALL_HEADERS = $QXT_INSTALL_HEADERS" >> $QXT_VARS
echo "QXT_INSTALL_FEATURES = $QXT_INSTALL_FEATURES" >> $QMAKE_CACHE
echo "QXT_INSTALL_FEATURES = $QXT_INSTALL_FEATURES" >> $QXT_VARS
echo "QXT_INSTALL_DOCS = $QXT_INSTALL_DOCS" >> $QMAKE_CACHE
echo "QXT_INSTALL_DOCS = $QXT_INSTALL_DOCS" >> $QXT_VARS
echo "QXT_SOURCE_TREE = $QXT_SOURCE_TREE" >> $QMAKE_CACHE
echo "QXT_BUILD_TREE = $QXT_BUILD_TREE" >> $QMAKE_CACHE
# detect make
echo>$CONFIG_LOG
if [ -z "$MAKE" ]; then
MAKE=
for mk in gmake make; do
if "$WHICH" $mk 2>&1| grep -qv "no "; then
MAKE=`$WHICH $mk`
break
fi
done
if [ -z "$MAKE" ]; then
echo >&2 "You don't seem to have 'make' or 'gmake' in your PATH."
echo >&2 "Cannot proceed."
exit 1
fi
fi
# detect dependencies
configtest()
{
echo -en "Checking for $1 "
echo -e " \n\n $1\n" >>$CONFIG_LOG
mkdir -p "$QXT_BUILD_TREE/config.tests/$1"
cd "$QXT_BUILD_TREE/config.tests/$1"
$QMAKE_BIN $QMAKE_PARAMS "$QXT_SOURCE_TREE/config.tests/$1/$1.pro" >>$CONFIG_LOG
echo -n "."
$MAKE clean >>$CONFIG_LOG 2>&1
[ -f ./$1 ] && rm ./$1
echo -n "."
$MAKE >>$CONFIG_LOG 2>&1 >>$CONFIG_LOG 2>&1
if [ -x $1 ] ; then
echo -e >&2 " [${C_GREEN}success${C_NONE}] "
echo "DEFINES+=HAVE_$2">>$QMAKE_CACHE
else
echo -e >&2 " [${C_RED}failure${C_NONE}] "
fi
}
echo >&2 "Testing for optional external libraries."
echo >&2 "If tests fail, some features will not be available."
configtest qt4 QT
if [[ "$NO_DB" == "0" ]]; then
configtest db DB
fi
if [[ "$NO_OPENSSL" == "0" ]]; then
configtest openssl OPENSSL
fi
if [[ "$QXT_MAC" == "0" ]]; then
if [[ "$NO_XRANDR" == "0" ]]; then
configtest xrandr XRANDR
fi
if [[ "$NO_ZEROCONF" == "0" ]]; then
configtest zeroconf ZEROCONF
fi
else
echo "DEFINES+=HAVE_ZEROCONF">>$QMAKE_CACHE
fi
# run qmake
echo "Autodetection finished. Running qmake."
cd $QXT_BUILD_TREE
$QMAKE_BIN $QMAKE_PARAMS "$QXT_SOURCE_TREE/libqxt.pro" -recursive >>$CONFIG_LOG
echo -e >&2 "${C_CYAN}Configure finished. Run $MAKE now.${C_NONE}\n"