forked from nemomobile/libqtsparql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·528 lines (451 loc) · 16.9 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
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
#!/bin/sh
#############################################################################
##
## Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
## All rights reserved.
## Contact: Nokia Corporation ([email protected])
##
## This file is part of the QtSparql module (not yet part of the Qt Toolkit).
##
## $QT_BEGIN_LICENSE:LGPL$
## GNU Lesser General Public License Usage
## This file may be used under the terms of the GNU Lesser General Public
## License version 2.1 as published by the Free Software Foundation and
## appearing in the file LICENSE.LGPL included in the packaging of this
## file. Please review the following information to ensure the GNU Lesser
## General Public License version 2.1 requirements will be met:
## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
##
## In addition, as a special exception, Nokia gives you certain additional
## rights. These rights are described in the Nokia Qt LGPL Exception
## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
##
## GNU General Public License Usage
## Alternatively, this file may be used under the terms of the GNU General
## Public License version 3.0 as published by the Free Software Foundation
## and appearing in the file LICENSE.GPL included in the packaging of this
## file. Please review the following information to ensure the GNU General
## Public License version 3.0 requirements will be met:
## http://www.gnu.org/copyleft/gpl.html.
##
## Other Usage
## Alternatively, this file may be used in accordance with the terms and
## conditions contained in a signed written agreement between you and Nokia.
##
## If you have questions regarding the use of this file, please contact
## Nokia at [email protected].
## $QT_END_LICENSE$
##
#############################################################################
#-------------------------------------------------------------------------------
# script initialization
#-------------------------------------------------------------------------------
# the name of this script
relconf=`basename $0`
# the directory of this script is the "source tree"
relpath=`dirname $0`
relpath=`(cd "$relpath"; /bin/pwd)`
# the current directory is the "build tree" or "object tree"
outpath=`/bin/pwd`
# FIXME: full support for "shadow builds" is not yet here
unixtests="$relpath/config.tests/unix"
WHICH="$unixtests/which.test"
if [ -z "$PKG_CONFIG" ]; then
PKG_CONFIG=`"$WHICH" pkg-config 2>/dev/null`
fi
QMAKE_VARS_FILE=.qmake.vars
:> "$QMAKE_VARS_FILE"
# default flags for SPARQL drivers (can get changed later)
QT_CFLAGS_ENDPOINT=
QT_CFLAGS_TRACKER=
QT_LFLAGS_ODBC="-lodbc"
OPT_VERBOSE=no
OPT_SHADOW=maybe
PERL=`$WHICH perl 2>/dev/null`
QMAKE=`$WHICH qmake 2>/dev/null`
if [ -z "$QMAKE" ] ; then
QMAKE=`$WHICH qmake-qt4 2>/dev/null`
fi
if [ -z "$QMAKE" ] ; then
echo
echo "You need qmake in your PATH to build QSparql."
echo "Cannot proceed."
exit 1
fi
export QMAKE
QT_VERSION=`$QMAKE -query QT_VERSION`
if [ -z "$QT_VERSION" ] ; then
echo
echo "Cannot proceed without QT_VERSION determined."
exit 1
fi
# is this a shadow build?
if [ "$OPT_SHADOW" = "maybe" ]; then
OPT_SHADOW=no
if [ "$relpath" != "$outpath" ] && [ '!' -f "$outpath/configure" ]; then
if [ -h "$outpath" ]; then
[ "$relpath" -ef "$outpath" ] || OPT_SHADOW=yes
else
OPT_SHADOW=yes
fi
fi
fi
# if the source tree is different from the build tree,
# symlink or copy part of the sources
if [ "$OPT_SHADOW" = "yes" ]; then
echo "Preparing build tree..."
if [ -z "$PERL" ]; then
echo
echo "You need perl in your PATH to make a shadow build."
echo "Cannot proceed."
exit 1
fi
[ -d "$outpath/bin" ] || mkdir -p "$outpath/bin"
# make a syncqt script that can be used in the shadow
rm -f "$outpath/bin/syncqt"
if [ -x "$relpath/bin/syncqt" ]; then
mkdir -p "$outpath/bin"
echo "#!/bin/sh" >"$outpath/bin/syncqt"
echo "QTDIR=\"$relpath\"; export QTDIR" >>"$outpath/bin/syncqt"
echo "perl \"$relpath/bin/syncqt\" -outdir \"$outpath\" \"\$@\"" >>"$outpath/bin/syncqt"
chmod 755 "$outpath/bin/syncqt"
fi
fi
# symlink includes
if [ -n "$PERL" ] && [ -x "$relpath/bin/syncqt" ]; then
SYNCQT_OPTS=
[ "$CFG_DEV" = "yes" ] && SYNCQT_OPTS="$SYNCQT_OPTS -check-includes"
if [ "$OPT_SHADOW" = "yes" ]; then
"$outpath/bin/syncqt" $SYNCQT_OPTS
elif [ "$CFG_DEV" = "yes" ] || [ ! -d $relpath/include ] || [ -d $relpath/.git ]; then
QTDIR="$relpath" perl "$outpath/bin/syncqt" $SYNCQT_OPTS
fi
fi
# find a make command
if [ -z "$MAKE" ]; then
MAKE=
for mk in gmake make; do
if "$WHICH" $mk >/dev/null 2>&1; 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
# export MAKE, we need it later in the config.tests
export MAKE
fi
# read which sparql drivers we have in the source code tree
CFG_SPARQL_AVAILABLE=
if [ -d "$relpath/src/plugins/sparqldrivers" ]; then
for a in "$relpath/src/plugins/sparqldrivers/"*; do
if [ -d "$a" ]; then
base_a=`basename "$a"`
CFG_SPARQL_AVAILABLE="${CFG_SPARQL_AVAILABLE} ${base_a}"
eval "CFG_SPARQL_${base_a}=auto"
fi
done
fi
CFG_PREFIX_INSTALL=yes
# initalize variables used for installation
QTSPARQL_INSTALL_PREFIX=
QTSPARQL_INSTALL_DOCS=
QTSPARQL_INSTALL_HEADERS=
QTSPARQL_INSTALL_IMPORTS=
QTSPARQL_INSTALL_PLUGINS=`$QMAKE -query QT_INSTALL_PLUGINS`
QTSPARQL_INSTALL_LIBS=
QTSPARQL_INSTALL_EXAMPLES=
QTSPARQL_INSTALL_TESTS=
CFG_QTSPARQL_COVERAGE=
case $QT_VERSION in
# In qt5, QML imports are in the 'qml' directory
"5."*) QTSPARQL_INSTALL_IMPORTS=`$QMAKE -query QT_INSTALL_QML`;;
*) QTSPARQL_INSTALL_IMPORTS=`$QMAKE -query QT_INSTALL_IMPORTS`;;
esac
# check how the user wants the SPARQL drivers to be built
# options:
# -plugin-sparql-<driver> build as separate plugin
# -qt-sparql-<driver> build into libqsparql
# -no-sparql-<driver> don't build
# parse the arguments, setting things to "yes" or "no"
while [ "$#" -gt 0 ]; do
CURRENT_OPT="$1"
UNKNOWN_ARG=no
case "$1" in
-no-*-*|-plugin-*-*|-qt-*-*)
VAR=`echo $1 | sed "s,^-[^-]*-\(.*\),\1,"`
VAL=`echo $1 | sed "s,^-\([^-]*\).*,\1,"`
;;
--enable-coverage)
CFG_QTSPARQL_COVERAGE=yes
;;
-prefix|-docdir|-headerdir|-importdir|-plugindir|-libdir|-examplesdir|-testdir)
VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
shift
VAL="$1"
;;
-h|help|--help|-help)
VAR=`echo $1 | sed "s,^[-]*\(.*\),\1,"`
VAL=yes
OPT_HELP=yes
;;
*)
echo "Unknown option: $1";
OPT_HELP=yes
ERROR=yes
shift
continue
;;
esac
case "$VAR" in
prefix)
QTSPARQL_INSTALL_PREFIX="$VAL"
;;
docdir)
QTSPARQL_INSTALL_DOCS="$VAL"
;;
headerdir)
QTSPARQL_INSTALL_HEADERS="$VAL"
;;
importdir)
QTSPARQL_INSTALL_IMPORTS="$VAL"
;;
plugindir)
QTSPARQL_INSTALL_PLUGINS="$VAL"
;;
libdir)
QTSPARQL_INSTALL_LIBS="$VAL"
;;
examplesdir)
QTSPARQL_INSTALL_EXAMPLES="$VAL"
;;
testdir)
QTSPARQL_INSTALL_TESTS="$VAL"
;;
sparql-*)
OPT="$VAL"
VAL=`echo $VAR | sed "s,^[^-]*-\([^-]*\).*,\1,"`
VAR=`echo $VAR | sed "s,^\([^-]*\).*,\1,"`
found=no
for d in $CFG_SPARQL_AVAILABLE; do
if [ "$VAL" = "$d" ]; then
found=yes
break
fi
done
[ "$found" = yes ] || ( echo "driver not available: $VAR"; exit 1 )
eval "CFG_SPARQL_$VAL=\$OPT"
;;
esac
shift
done
#overwrite the way the drivers are built if user wants coverage report
if [ "$CFG_QTSPARQL_COVERAGE" = "yes" ]; then
CFG_SPARQL_endpoint=qt
CFG_SPARQL_tracker=qt
CFG_SPARQL_tracker_direct=qt
echo "Preparing configuration for coverage report..."
fi
# next, emit a usage message if something failed.
if [ "$OPT_HELP" = "yes" ]; then
cat <<EOF
Usage: $relconf [-h] [-prefix <dir>]
[-no-sparql-<driver>] [-sparql-<driver>] [-plugin-sparql-<driver>]
Installation options:
These are optional, but you may specify install directories.
-prefix <dir> ...... This will install everything relative to <dir>
(default $QTSPARQL_INSTALL_PREFIX)
-docdir <dir> ...... Documentation will be installed to <dir>
(default PREFIX/share/doc)
-headerdir <dir> ... Headers will be installed to <dir>
(default PREFIX/include/QtSparql)
-importdir <dir> ... QML plugins will be installed to <dir>
(default QT_INSTALL_IMPORTS)
-plugindir <dir> ... Plugins will be installed to <dir>
(default QT_PLUGIN_DIR)
-libdir <dir> ...... Libraries will be installed to <dir>
(default PREFIX/lib)
-examplesdir <dir> . Examples will be installed to <dir>
(default QT_EXAMPLES_DIR)
-testdir <dir> ..... Tests will be installed to <dir>
(default PREFIX/lib/qtsparql-tests)
EOF
[ "x$ERROR" = "xyes" ] && exit 1
exit 0
fi
#-------------------------------------------------------------------------------
# post process QTSPARQL_* variables
#-------------------------------------------------------------------------------
#prefix
if [ -z "$QTSPARQL_INSTALL_PREFIX" ]; then
QTSPARQL_INSTALL_PREFIX="/usr/local"
fi
QTSPARQL_INSTALL_PREFIX=`"$relpath/config.tests/unix/makeabs" "$QTSPARQL_INSTALL_PREFIX"`
if [ -z "$QTSPARQL_INSTALL_DOCS" ]; then
QTSPARQL_INSTALL_DOCS="$QTSPARQL_INSTALL_PREFIX/share/doc"
fi
QTSPARQL_INSTALL_DOCS=`"$relpath/config.tests/unix/makeabs" "$QTSPARQL_INSTALL_DOCS"`
if [ -z "$QTSPARQL_INSTALL_HEADERS" ]; then
case $QT_VERSION in
"5."*) QTSPARQL_INSTALL_HEADERS="$QTSPARQL_INSTALL_PREFIX/include/Qt5Sparql";;
*) QTSPARQL_INSTALL_HEADERS="$QTSPARQL_INSTALL_PREFIX/include/QtSparql";;
esac
fi
QTSPARQL_INSTALL_HEADERS=`"$relpath/config.tests/unix/makeabs" "$QTSPARQL_INSTALL_HEADERS"`
if [ -n "$QTSPARQL_INSTALL_IMPORTS" ]; then
QTSPARQL_INSTALL_IMPORTS=`"$relpath/config.tests/unix/makeabs" "$QTSPARQL_INSTALL_IMPORTS"`
fi
if [ -n "$QTSPARQL_INSTALL_PLUGINS" ]; then
QTSPARQL_INSTALL_PLUGINS=`"$relpath/config.tests/unix/makeabs" "$QTSPARQL_INSTALL_PLUGINS"`
fi
if [ -z "$QTSPARQL_INSTALL_LIBS" ]; then
QTSPARQL_INSTALL_LIBS="$QTSPARQL_INSTALL_PREFIX/lib"
fi
QTSPARQL_INSTALL_LIBS=`"$relpath/config.tests/unix/makeabs" "$QTSPARQL_INSTALL_LIBS"`
if [ -n "$QTSPARQL_INSTALL_EXAMPLES" ]; then
QTSPARQL_INSTALL_EXAMPLES=`"$relpath/config.tests/unix/makeabs" "$QTSPARQL_INSTALL_EXAMPLES"`
fi
if [ -z "$QTSPARQL_INSTALL_TESTS" ]; then
QTSPARQL_INSTALL_TESTS="$QTSPARQL_INSTALL_PREFIX/lib/libqtsparql-tests"
fi
QTSPARQL_INSTALL_TESTS=`"$relpath/config.tests/unix/makeabs" "$QTSPARQL_INSTALL_TESTS"`
# detect which SPARQL drivers we can build
# CFG_SPARQL_driver=plugin -> we'll build the driver as a plugin
# CFG_SPARQL_driver=qt -> we'll embed the driver into QtSparql library
# CFG_SPARQL=no (or empty) -> we don't build that driver at all
for _SPARQLDR in $CFG_SPARQL_AVAILABLE; do
case $_SPARQLDR in
tracker)
if [ "$CFG_SPARQL_tracker" != "no" ]; then
QT_LFLAGS_TRACKER=
if [ "$CFG_SPARQL_tracker" = "auto" ]; then
CFG_SPARQL_tracker=plugin
fi
fi
;;
tracker_direct)
if [ "$CFG_SPARQL_tracker_direct" != "no" ]; then
if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/tracker-sparql "tracker-sparql" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
if [ "$CFG_SPARQL_tracker_direct" = "auto" ]; then
CFG_SPARQL_tracker_direct=plugin
fi
fi
fi
;;
endpoint)
if [ "$CFG_SPARQL_endpoint" != "no" ]; then
QT_LFLAGS_ENDPOINT=
if [ "$CFG_SPARQL_endpoint" = "auto" ]; then
CFG_SPARQL_endpoint=plugin
fi
fi
;;
virtuoso)
if [ "$CFG_SPARQL_virtuoso" != "no" ]; then
if [ "$PLATFORM_MAC" != "yes" ] && "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/iodbc "iODBC" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
QT_LFLAGS_ODBC="-liodbc"
if [ "$CFG_SPARQL_virtuoso" = "auto" ]; then
CFG_SPARQL_virtuoso=plugin
fi
else
if [ "$CFG_SPARQL_virtuoso" != "auto" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
echo "Virtuoso SPARQL support cannot be enabled due to functionality tests!"
echo " Turn on verbose messaging (-v) to $0 to see the final report."
echo " If you believe this message is in error you may use the continue"
echo " switch (-continue) to $0 to continue."
exit 101
else
CFG_SPARQL_virtuoso=no
fi
fi
fi
;;
*)
if [ "$OPT_VERBOSE" = "yes" ]; then
echo "unknown SPARQL driver: $_SPARQLDR"
fi
;;
esac
done
# read which drivers were really buildable
for DRIVER in $CFG_SPARQL_AVAILABLE; do
eval "VAL=\$CFG_SPARQL_$DRIVER"
case "$VAL" in
qt)
ONDRIVER=`echo $DRIVER | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
QCONFIG_FLAGS="$QCONFIG_FLAGS QT_SPARQL_$ONDRIVER"
SPARQL_DRIVERS="$SPARQL_DRIVERS $DRIVER"
;;
plugin)
SPARQL_PLUGINS="$SPARQL_PLUGINS $DRIVER"
;;
esac
done
# write that info down for qmake
echo "sparql-drivers =" "$SPARQL_DRIVERS" >> "$QMAKE_VARS_FILE"
echo "sparql-plugins =" "$SPARQL_PLUGINS" >> "$QMAKE_VARS_FILE"
# create the cache file (simplified)
CACHEFILE="$outpath/.qmake.cache"
[ -f "$CACHEFILE.tmp" ] && rm -f "$CACHEFILE.tmp"
# cmdline args
cat "$QMAKE_VARS_FILE" >> "$CACHEFILE.tmp"
rm -f "$QMAKE_VARS_FILE" 2>/dev/null
#-------------------------------------------------------------------------------
# save configuration into .qmake.cache
#-------------------------------------------------------------------------------
cat >>"$CACHEFILE.tmp" <<EOF
QTSPARQL_SOURCE_TREE = \$\$quote($relpath)
QTSPARQL_BUILD_TREE = \$\$quote($outpath)
EOF
if [ -n "$QT_CFLAGS_ENDPOINT" ]; then
echo "QT_CFLAGS_ENDPOINT = $QT_CFLAGS_ENDPOINT" >> "$CACHEFILE.tmp"
fi
if [ -n "$QT_CFLAGS_TRACKER" ]; then
echo "QT_CFLAGS_TRACKER = $QT_CFLAGS_TRACKER" >> "$CACHEFILE.tmp"
fi
if [ -n "$QT_LFLAGS_ODBC" ]; then
echo "QT_LFLAGS_ODBC = $QT_LFLAGS_ODBC" >> "$CACHEFILE.tmp"
fi
echo "QTSPARQL_INSTALL_PREFIX = $QTSPARQL_INSTALL_PREFIX" >> "$CACHEFILE.tmp"
echo "QTSPARQL_INSTALL_DOCS = $QTSPARQL_INSTALL_DOCS" >> "$CACHEFILE.tmp"
echo "QTSPARQL_INSTALL_HEADERS = $QTSPARQL_INSTALL_HEADERS" >> "$CACHEFILE.tmp"
echo "QTSPARQL_INSTALL_IMPORTS = $QTSPARQL_INSTALL_IMPORTS" >> "$CACHEFILE.tmp"
echo "QTSPARQL_INSTALL_PLUGINS = $QTSPARQL_INSTALL_PLUGINS" >> "$CACHEFILE.tmp"
echo "QTSPARQL_INSTALL_LIBS = $QTSPARQL_INSTALL_LIBS" >> "$CACHEFILE.tmp"
echo "QTSPARQL_INSTALL_EXAMPLES = $QTSPARQL_INSTALL_EXAMPLES" >> "$CACHEFILE.tmp"
echo "QTSPARQL_INSTALL_TESTS = $QTSPARQL_INSTALL_TESTS" >> "$CACHEFILE.tmp"
# replace .qmake.cache if it differs from the newly created temp file
if cmp -s "$CACHEFILE.tmp" "$CACHEFILE"; then
rm -f "$CACHEFILE.tmp"
else
mv -f "$CACHEFILE.tmp" "$CACHEFILE"
fi
# create / copy header files to include/
QTDIR=. bin/syncqt
echo "Finding project files. Please wait..."
"$QMAKE" -prl -r "${relpath}/projects.pro"
if [ -f "${relpath}/projects.pro" ]; then
mkfile="${outpath}/Makefile"
[ -f "$mkfile" ] && chmod +w "$mkfile"
QTDIR="$outpath" "$QMAKE" -spec "$XQMAKESPEC" "${relpath}/projects.pro" -o "$mkfile"
fi
MAKE=`basename "$MAKE"`
echo
echo QtSparql is now configured for building. Just run \'$MAKE\'.
if [ "$relpath" = "$QTSPARQL_INSTALL_PREFIX" ]; then
echo Once everything is built, QtSparql is installed.
echo You should not run \'$MAKE install\'.
else
echo Once everything is built, you must run \'$MAKE install\'.
echo QtSparql will be installed into $QTSPARQL_INSTALL_PREFIX
fi
if [ "$CFG_QTSPARQL_COVERAGE" = "yes" ]; then
"$QMAKE" CONFIG+=coverage
echo "You are ready to generate coverage report. Just run tests (make check) and make coverage"
fi
echo
echo To reconfigure, run \'$MAKE distclean\' and \'configure\'.
echo