This repository has been archived by the owner on Sep 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
configure.sh.in
executable file
·340 lines (286 loc) · 8.42 KB
/
configure.sh.in
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
#!/bin/bash
PRODUCT=@PRODUCT_UPPERCASE@
Product=@PRODUCT_MIXEDCASE@
product=@PRODUCT_LOWERCASE@
ProductSpace="@PRODUCT_MIXEDCASE_SPACED@"
VERSION=@VERSION@
STATIC_BUILD_SUPPORTED=@STATIC_BUILD_SUPPORTED@
SOURCE_DIR=`dirname "$0"`
PACKSCRIPTS_DIR="$SOURCE_DIR"/../admin/packscripts
hide_symbols=yes
shared=yes
debug=no
release=yes
prefix=
unittests=no
hostqmake=
targetqmake=
[ -d "$PACKSCRIPTS_DIR" ] && unittests=yes
function die {
echo "$1" 1>&2
exit 1
}
function check_license {
[ -d "$PACKSCRIPTS_DIR" ] && return 0
[ -f .license.accepted ] && return 0
if [ -f "$SOURCE_DIR"/LICENSE.@[email protected] -a -f "$SOURCE_DIR"/LICENSE.US.txt -a -f "$SOURCE_DIR"/LICENSE.txt ] ; then
echo
echo "Please choose your license."
echo
echo "Type 1 for the @PRODUCT_LICENSE_FREE_NAME@ (@PRODUCT_LICENSE_FREE@)."
echo "Type 2 for the $ProductSpace Commercial License for USA/Canada."
echo "Type 3 for the $ProductSpace Commercial License for anywhere outside USA/Canada."
echo "Anything else cancels."
echo
echo -n "Select: "
read license
elif [ -f "$SOURCE_DIR"/LICENSE.@[email protected] ] ; then
license="1"
elif [ -f "$SOURCE_DIR"/LICENSE.US.txt ] ; then
license="2"
elif [ -f "$SOURCE_DIR"/LICENSE.txt ] ; then
license="3"
else
die "Couldn't find license file, aborting"
fi
if [ "$license" = "1" ]; then
license_name="@PRODUCT_LICENSE_FREE_NAME@ (@PRODUCT_LICENSE_FREE@)"
license_file="$SOURCE_DIR"/LICENSE.@[email protected]
elif [ "$license" = "2" ]; then
license_name="$ProductSpace USA/Canada Commercial License"
license_file="$SOURCE_DIR"/LICENSE.US.txt
elif [ "$license" = "3" ]; then
license_name="$ProductSpace Commercial License"
license_file="$SOURCE_DIR"/LICENSE.txt
else
return 1
fi
while true ; do
cat <<EOF
License Agreement
You are licensed to use this software under the terms of
the $license_name.
Type '?' to view the $license_name
Type 'yes' to accept this license offer.
Type 'no' to decline this license offer.
Do you accept the terms of this license?
EOF
read answer
[ "$answer" = "no" ] && return 1
[ "$answer" = "yes" ] && touch .license.accepted && return 0
[ "$answer" = "?" ] && more $license_file
done
}
if ! check_license ; then
die "You are not licensed to use this software."
fi
function usage {
[ -z "$1" ] || echo "$0: unknown option \"$1\"" 1>&2
echo "usage: $0 [options]" 1>&2
cat <<EOF 1>&2
where options include:
EOF
cat <<EOF 1>&2
-prefix <path>
install $ProductSpace into <path>
EOF
cat <<EOF 1>&2
-release / -debug
build in debug/release mode
EOF
if [ "$STATIC_BUILD_SUPPORTED" = "true" ]; then
cat <<EOF 1>&2
-static / -shared
build static/shared libraries
EOF
fi
cat <<EOF 1>&2
-[no-]hide-symbols (Unix only)
reduce the number of exported symbols
-[no-]unittests
enable/disable compiled-in unittests
-qmake </qt/bin/qmake>
explicitly sets the qmake location, instead of using the
qmake in the path.
-hostqmake </host/qt/bin/qmake>
when cross-compiling, the qmake in the path will be used for
compiling the product's code, but the host qmake will be used
to compile the host tools (code generators).
-spec <mkspec>
compile $ProductSpace for specific Qt-supported target <mkspec>
EOF
exit 1
}
while [ $# -ne 0 ] ; do
case "$1" in
-prefix)
shift
if [ $# -eq 0 ] ; then
echo "-prefix needs an argument" 2>&1
usage
fi
prefix="$1"
;;
-no-hide-symbols)
hide_symbols=no
;;
-hide-symbols)
hide_symbols=yes
;;
-override-version) # undocumented by design
shift
if [ $# -eq 0 ] ; then
echo "-override-version needs an argument" 2>&1
usage
fi
VERSION="$1"
;;
-no-unittests)
unittests=no
;;
-unittests)
unittests=yes
;;
-shared)
shared=yes
;;
-static)
if [ "$STATIC_BUILD_SUPPORTED" != "true" ]; then
echo "Static build not supported, -static option not allowed" 2>&1
usage
fi
shared=no
;;
-debug)
debug=yes
release=no
;;
-release)
debug=no
release=yes
;;
-spec)
shift
if [ $# -eq 0 ] ; then
echo "-spec needs an argument" 2>&1
usage
fi
SPEC="-spec $1"
;;
-hostqmake)
shift
if [ $# -eq 0 ] ; then
echo "-hostqmake needs an argument" 2>&1
usage
fi
hostqmake="$1"
;;
-qmake)
shift
if [ $# -eq 0 ] ; then
echo "-make needs an argument" 2>&1
usage
fi
targetqmake="$1"
;;
*)
usage "$1"
;;
esac
shift
done
if [ -n "$targetqmake" ] ; then
if [ -z "$QTDIR" ] ; then
QTDIR="$($targetqmake -query QT_INSTALL_PREFIX)"
if [ $? -ne 0 ] ; then
die "$targetqmake -query QT_INSTALL_PREFIX gave an error"
fi
fi
else
for qmk in qmake qmake-qt5 qmake-qt4
do
which "$qmk" >/dev/null 2>&1
if [ $? -eq 0 -a -z "$targetqmake" ] ; then
QTDIR="$($qmk -query QT_INSTALL_PREFIX)"
if [ $? -eq 0 ] ; then
targetqmake=$qmk
break
fi
fi
done
[ -z "$targetqmake" ] && die "You need qmake or qmake-qt5 or qmake-qt4 in the PATH"
fi
find . -name debug -o -name release -o -name Makefile\* | xargs rm -rf
if [ -f src/src.pro ] ; then
rm -rf lib bin
fi
default_prefix=/usr/local/KDAB/$Product-$VERSION
if [ -z "$prefix" ] ; then
prefix="$default_prefix"
fi
QMAKE_ARGS="$QMAKE_ARGS VERSION=$VERSION"
QMAKE_ARGS="$QMAKE_ARGS CONFIG+=${product}_target"
if [ "$debug" = "yes" ]; then
QMAKE_ARGS="$QMAKE_ARGS CONFIG-=release CONFIG+=debug CONFIG-=debug_and_release"
fi
if [ "$release" = "yes" ]; then
QMAKE_ARGS="$QMAKE_ARGS CONFIG+=release CONFIG-=debug CONFIG-=debug_and_release"
fi
[ "$hide_symbols" = "yes" ] && QMAKE_ARGS="$QMAKE_ARGS CONFIG+=hide_symbols"
[ "$unittests" = "yes" ] && QMAKE_ARGS="$QMAKE_ARGS CONFIG+=unittests"
if [ "$shared" = "yes" ]; then
QMAKE_ARGS="$QMAKE_ARGS CONFIG-=static CONFIG-=staticlib CONFIG+=shared"
else
QMAKE_ARGS="$QMAKE_ARGS CONFIG+=static CONFIG+=staticlib CONFIG-=shared"
fi
if [ -d "$QTDIR/include/Qt/private" ] ; then
QMAKE_ARGS="$QMAKE_ARGS CONFIG+=have_private_qt_headers"
QMAKE_ARGS="$QMAKE_ARGS INCLUDEPATH+=$QTDIR/include/Qt/private"
#else
#echo "QTDIR must point to an installation that has private headers installed."
#echo "Some features will not be available."
fi
QMAKE_ARGS="$QMAKE_ARGS ${PRODUCT}_INSTALL_PREFIX=$prefix"
# This must be the last line that touches QMAKE_ARGS
if [ "$hostqmake" != "" ] ; then
HOST_QMAKE_ARGS="$QMAKE_ARGS"
QMAKE_ARGS="$QMAKE_ARGS CONFIG+=crosscompiling"
fi
cat <<EOF 1>&2
$ProductSpace v$VERSION configuration:
EOF
cat <<EOF 1>&2
Install Prefix.............: $prefix
(default: $default_prefix)
EOF
cat <<EOF 1>&2
Debug......................: $debug (default: no)
Release....................: $release (default: yes)
EOF
if [ "$STATIC_BUILD_SUPPORTED" = "true" ]; then
cat <<EOF 1>&2
Shared build...............: $shared (default: yes)
EOF
fi
if [ "$SPEC" != "" ]; then
cat <<EOF 1>&2
Spec.......................: ${SPEC#-spec }
EOF
fi
if [ "$hostqmake" != "" ]; then
cat <<EOF 1>&2
Host qmake................: ${hostqmake}
EOF
fi
cat <<EOF 1>&2
Compiled-In Unit Tests.....: $unittests (default: no)
Restricted symbol export
(shared build only)......: $hide_symbols (default: yes)
EOF
"$targetqmake" ${SPEC} "$SOURCE_DIR"/$product.pro -recursive $QMAKE_ARGS "${PRODUCT}_BASE=`pwd`" || die "qmake failed"
if [ "$hostqmake" != "" -a -d "$SOURCE_DIR"/kdwsdl2cpp ]; then
[ -d kdwsdl2cpp ] || mkdir kdwsdl2cpp
cd kdwsdl2cpp
$hostqmake "$SOURCE_DIR"/kdwsdl2cpp -recursive $HOST_QMAKE_ARGS || die "host qmake failed"
fi
echo "Ok, now run make, then make install to install into $prefix"