File: configure

package info (click to toggle)
qtmobility 1.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 169,300 kB
  • ctags: 92,483
  • sloc: cpp: 759,105; ansic: 16,292; xml: 5,054; sh: 920; perl: 369; makefile: 167
file content (773 lines) | stat: -rwxr-xr-x 26,165 bytes parent folder | download
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
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
#!/bin/sh
#############################################################################
##
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
## All rights reserved.
## Contact: Nokia Corporation (qt-info@nokia.com)
##
## This file is part of the Qt Mobility Components.
##
## $QT_BEGIN_LICENSE:LGPL$
## No Commercial Usage
## This file contains pre-release code and may not be distributed.
## You may use this file in accordance with the terms and conditions
## contained in the Technology Preview License Agreement accompanying
## this package.
##
## GNU Lesser General Public License Usage
## Alternatively, 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.
##
## If you have questions regarding the use of this file, please contact
## Nokia at qt-info@nokia.com.
##
##
##
##
##
##
##
##
## $QT_END_LICENSE$
##
#############################################################################

# return status of 1 if absolute path as first argument
# also prints the return status
isAbsPath() {
    slash=$(echo $1 | cut -c 1)
    if [ "$slash" != "/" ]; then
        echo 0
        return 0
    fi
    echo 1
    return 1
}

# Returns the absolute path for $1 for target $2
# as an example $2 might have value "maemo5".
# This is required because when building in scratchbox for
# maemo we do not want to follow symbolic links that are
# introduced by scratchbox
absPath() {
    if [ "$2" = "maemo5" -o "$2" = "maemo6" -o "$2" = "meego" -o "$2" = "" ]; then
        if [ `isAbsPath $1` = '1' ]; then
            echo $1;
        else
            echo >&2 "Relative prefix/bin/lib/header/plugin paths are not supported for Maemo"
            exit 1;
        fi
    else
        PATH=`$relpath/bin/pathhelper $1`
        echo $PATH
    fi
}


# the current directory (shadow build dir)
shadowpath=`/bin/pwd`
# 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)`

CONFIG_IN="$shadowpath/config.in"
QT_MOBILITY_PREFIX=$shadowpath/install
QT_MOBILITY_INCLUDE=
QT_MOBILITY_LIB=
QT_MOBILITY_BIN=
QT_MOBILITY_PLUGINS=
QT_MOBILITY_EXAMPLES=
QT_MOBILITY_DEMOS=
BUILD_UNITTESTS=
BUILD_PUBLIC_UNITTESTS=
BUILD_EXAMPLES=
BUILD_DEMOS=
BUILD_DOCS=yes
BUILD_TOOLS=yes
RELEASEMODE=
BUILD_SILENT=
LINUX_TARGET=
LANGUAGES=
QMAKE_CACHE="$shadowpath/.qmake.cache"
QMAKE_EXEC=qmake
LIB_PATH="lib"
BIN_PATH="bin"
PLUGIN_PATH="plugins"
PLATFORM_CONFIG=
MAC_SDK=
MOBILITY_MODULES="bearer location contacts multimedia publishsubscribe versit messaging systeminfo serviceframework sensors gallery organizer feedback connectivity"
MOBILITY_MODULES_UNPARSED=
QMKSPEC=
OS="other"
# By default, all modules are requested.  Reset this later if -modules is supplied
ORGANIZER_REQUESTED=yes
TEST_USE_SIMULATOR=
NFC_SYMBIAN=auto
MAC_DEPLOY=

usage() 
{
    echo "Usage: configure [-prefix <dir>] [headerdir <dir>] [libdir <dir>]"
    echo "                 [-bindir <dir>] [-tests] [-examples] [-no-docs]"
    echo "                 [-no-tools] [-debug] [-release] [-silent]"
    echo "                 [-modules <list>]"
    echo
    echo "Options:"
    echo
    echo "-prefix <dir> ..... This will install everything relative to <dir>"
    echo "                    (default prefix: $shadowpath/install)"
    echo "-headerdir <dir> .. Header files will be installed to <dir>"
    echo "                    (default prefix: PREFIX/include)"
    echo "-libdir <dir> ..... Libraries will be installed to <dir>"
    echo "                    (default: PREFIX/lib)"
    echo "-bindir <dir> ..... Executables will be installed to <dir>"
    echo "                    (default: PREFIX/bin)"
    echo "-plugindir <dir> .. Plug-ins will be installed to <dir>"
    echo "                    (default: PREFIX/plugins)"
    echo "-demosdir <dir> ... Demos will be installed to <dir>"
    echo "                    (default: PREFIX/bin)"
    echo "-examplesdir <dir>  Examples will be installed to <dir>"
    echo "                    (default PREFIX/bin)"
    echo "-debug ............ Build with debugging symbols"
    echo "-release .......... Build without debugging symbols"
    echo "-silent ........... Reduces build output"
    echo "-tests ............ Build unit tests (not build by default)"
    echo "                    Note, this adds test symbols to all libraries"
    echo "                    and should not be used for release builds."
    echo "-examples ......... Build example applications"
    echo "-demos ............ Build demo applications"
    echo "-no-docs .......... Do not build documentation (build by default)"
    echo "-no-tools ......... Do not build tools (build by default)"
    echo "-modules <list> ... Restrict list of modules to build (default all supported)"
    echo "                    Choose from: bearer contacts gallery location publishsubscribe"
    echo "                    messaging multimedia systeminfo serviceframework"
    echo "                    sensors versit organizer feedback connectivity"
    echo "                    Modules should be separated by a space and surrounded"
    echo "                    by double quotation. If a selected module depends on other modules"
    echo "                    those modules (and their dependencies) will automatically be enabled."
    echo "-maemo6 ........... Build Qt Mobility for Maemo6 (Harmattan)."
    echo "-maemo5 ........... Build Qt Mobility for Maemo5 (Fremantle)."
    echo "-meego  ........... Build Qt Mobility for MeeGo."
    echo "-sdk <sdk> ........ Build using Apple provided SDK <path/to/sdk>."
    echo "                    example: -sdk /Developer/SDKs/MacOSX10.6.sdk"
    echo "-languages ........ Languages/translations to be installed (e.g.: \"ar de ko\")."
    echo "                    (default is empty)"
    echo "-qmake-exec <name>  Sets custom binary name for qmake binary"
    echo "                    (default: qmake)"
    echo "-no-nfc-symbian     Disables the NFC Sybmian backend."
#    echo "-test-sim           Use simulator backend for testing systeminfo"
#    echo "-staticconfig <name>"
#    echo "                    Avoids running of configuration tests. The default"
#    echo "                    values are sourced from features/platformconfig/<name>.pri"
    echo "-mac-deploy ....    Use this option for deploying QtMobility into Qt for use with macdeployqt tool"
    echo "                    This overrides any -prefix that may be set."
    echo
    
    rm -f "$CONFIG_IN"
    exit 1
}

rm -rf "$QMAKE_CACHE"
CONFIG_LOG="$shadowpath/config.log"
rm -rf "$CONFIG_LOG"

while [ "$#" -gt 0 ]; do
    case "$1" in 
        -h|-help|--help)
            usage
            ;;
        -headerdir)
            QT_MOBILITY_INCLUDE="$2"
            shift
            ;;
        -libdir)
            QT_MOBILITY_LIB="$2"
            shift
            ;;
        --prefix|-prefix)
            QT_MOBILITY_PREFIX="$2"
            shift
            ;;
        -bindir)
            QT_MOBILITY_BIN="$2"
            shift
            ;;
        -plugindir)
            QT_MOBILITY_PLUGINS="$2"
            shift
            ;;
        -examplesdir)
            QT_MOBILITY_EXAMPLES="$2"
            shift
            ;;
        -demosdir)
            QT_MOBILITY_DEMOS="$2"
            shift
            ;;
        -tests)
            BUILD_UNITTESTS="yes"
            ;;
        -public-tests-only)
            BUILD_PUBLIC_UNITTESTS="yes"
            ;;
        -demos)
            BUILD_DEMOS="yes"
            ;;
        -examples)
            BUILD_EXAMPLES="yes"
            ;;
        -no-docs)
            BUILD_DOCS=
            ;;
        -no-tools)
            BUILD_TOOLS=
            ;;
        -debug)
            RELEASEMODE=debug
            ;;
        -release)
            RELEASEMODE=release
            ;;
        -silent)
            BUILD_SILENT=yes
            ;;
        -maemo5)
            LINUX_TARGET=maemo5
            ;;
        -maemo6)
            LINUX_TARGET=maemo6
            ;;
        -meego)
            LINUX_TARGET=meego
            ;;
        -sdk)
            MAC_SDK="$2"
            shift
            ;;
        -qmake-exec)
            QMAKE_EXEC="$2"
            shift
            ;;
        -modules)
            MOBILITY_MODULES_UNPARSED=$2
            ORGANIZER_REQUESTED=
            #reset default selection
            MOBILITY_MODULES=
            for m in $MOBILITY_MODULES_UNPARSED; do
                case "$m" in
                    bearer|contacts|location|messaging|multimedia|publishsubscribe|serviceframework|systeminfo|sensors|gallery|versit|feedback|connectivity)
                        MOBILITY_MODULES="$MOBILITY_MODULES $m";
                        ;;
                    organizer)
                        MOBILITY_MODULES="$MOBILITY_MODULES $m";
                        ORGANIZER_REQUESTED=yes
                        ;;
                    *)
                        echo "Unknown module: $m"
                        echo
                        usage
                        ;;

                esac
            done
            if [ -z "$MOBILITY_MODULES" ]; then
                echo "List of selected modules is empty."
                echo 
                usage
            fi
            shift
            ;;
        -staticconfig)
            PLATFORM_CONFIG=$2
            shift
            ;;
        -languages)
            LANGUAGES=$2
            shift
            ;;
        -test-sim)
            TEST_USE_SIMULATOR="yes"
            ;; 
        -no-nfc-symbian)
            NFC_SYMBIAN=no
            ;;
        -mac-deploy)
            MAC_DEPLOY='yes'
            shift
            ;;
        *)
            echo "Unknown option: $1"
            usage
            ;;
    esac
    shift
done

if [ -z "$RELEASEMODE" ]; then
    RELEASEMODE="debug"
fi
echo "CONFIG += $RELEASEMODE" > "$CONFIG_IN"


if [ -n "$BUILD_SILENT" ]; then
    echo "CONFIG += silent"  >> "$CONFIG_IN"
fi

checkostype()
{
    match="Darwin"
    if [ `uname -s` = "${match}" ]; then
        OS="darwin"
        QMKSPEC="-spec macx-g++"
        if [[ `gcc --version` =~ .*llvm.* ]]; then
            QMKSPEC="-spec macx-llvm"
        else
           QMKSPEC="-spec macx-g++"
        fi
        echo "QMAKESPEC = "$QMKSPEC >> "$CONFIG_IN"
    fi
}

checkostype

findUniversal()
{
    if [ -e "mac.inc" ]; then
        rm mac.inc
    fi
    echo "contains(QT_CONFIG,x86): system(echo CONFIG+=x86 >> mac.inc)" > 2.pro
    echo "contains(QT_CONFIG,ppc): system(echo CONFIG+=ppc >> mac.inc)" >> 2.pro
    echo "contains(QT_CONFIG,ppc64): system(echo CONFIG+=ppc64 >> mac.inc)" >> 2.pro
    echo "contains(QT_CONFIG,x86_64): system(echo CONFIG+=x86_64 >> mac.inc)" >> 2.pro
    SOMETIME=`$QMAKE_EXEC $QMKSPEC 2.pro 2>&1`
    rm 2.pro
    if [ -e "mac.inc" ]; then
         echo "exists(mac.inc): include(mac.inc)" >> "$CONFIG_IN"
    fi
}

if [ "$OS" = "darwin" ] ; then
    findUniversal
fi


#do we build for Maemo?
if [ -n "$LINUX_TARGET" ]; then
    if [ "$LINUX_TARGET" = "maemo5" ]; then
        echo "CONFIG+=maemo5" >> "$CONFIG_IN"
    elif [ "$LINUX_TARGET" = "maemo6" ]; then
        echo "CONFIG+=maemo6" >> "$CONFIG_IN"
    elif [ "$LINUX_TARGET" = "meego" ]; then
        echo "CONFIG+=meego" >> "$CONFIG_IN"
    fi
fi


if [ -n "$MAC_DEPLOY" ]; then
    QT_MOBILITY_PREFIX=`$QMAKE_EXEC -query QT_INSTALL_PREFIX`
    echo "QT_MOBILITY_PREFIX = $QT_MOBILITY_PREFIX" >> "$CONFIG_IN"
    QT_MOBILITY_INCLUDE=`$QMAKE_EXEC -query QT_INSTALL_HEADERS`
    echo "QT_MOBILITY_INCLUDE = $QT_MOBILITY_INCLUDE" >> "$CONFIG_IN"
    QT_MOBILITY_LIB=`$QMAKE_EXEC -query QT_INSTALL_LIBS`
    echo "QT_MOBILITY_LIB = $QT_MOBILITY_LIB" >> "$CONFIG_IN"
    QT_MOBILITY_BIN=`$QMAKE_EXEC -query QT_INSTALL_BINS`
    echo "QT_MOBILITY_BIN = $QT_MOBILITY_BIN" >> "$CONFIG_IN"
    QT_MOBILITY_PLUGINS=`$QMAKE_EXEC -query QT_INSTALL_PLUGINS`
    echo "QT_MOBILITY_PLUGINS = $QT_MOBILITY_PLUGINS" >> "$CONFIG_IN"
    QT_MOBILITY_EXAMPLES=`$QMAKE_EXEC -query QT_INSTALL_EXAMPLES`
    echo "QT_MOBILITY_EXAMPLES = $QT_MOBILITY_EXAMPLES" >> "$CONFIG_IN"
    QT_MOBILITY_DEMOS=`$QMAKE_EXEC -query QT_INSTALL_DEMOS`
    echo "QT_MOBILITY_DEMOS = $QT_MOBILITY_DEMOS" >> "$CONFIG_IN"

else

#process PREFIX
QT_MOBILITY_PREFIX=`absPath $QT_MOBILITY_PREFIX $LINUX_TARGET`
if [ "$?" -eq "1" ]; then
    exit 1
fi
echo "QT_MOBILITY_PREFIX = $QT_MOBILITY_PREFIX" >> "$CONFIG_IN"

#process include path
if [ -z "$QT_MOBILITY_INCLUDE" ]; then
    QT_MOBILITY_INCLUDE="$QT_MOBILITY_PREFIX/include"
else
    QT_MOBILITY_INCLUDE=`absPath $QT_MOBILITY_INCLUDE $LINUX_TARGET`
    if [ "$?" -eq "1" ]; then
        exit 1
    fi
fi
echo "QT_MOBILITY_INCLUDE = $QT_MOBILITY_INCLUDE" >> "$CONFIG_IN"


#process library path
if [ -z "$QT_MOBILITY_LIB" ]; then
    QT_MOBILITY_LIB="$QT_MOBILITY_PREFIX/$LIB_PATH"
else
    QT_MOBILITY_LIB=`absPath $QT_MOBILITY_LIB $LINUX_TARGET`
    if [ "$?" -eq "1" ]; then
        exit 1
    fi
fi
echo "QT_MOBILITY_LIB = $QT_MOBILITY_LIB" >> "$CONFIG_IN"

#process bin path
if [ -z "$QT_MOBILITY_BIN" ]; then
    QT_MOBILITY_BIN="$QT_MOBILITY_PREFIX/$BIN_PATH"
else
    QT_MOBILITY_BIN=`absPath $QT_MOBILITY_BIN $LINUX_TARGET`
    if [ "$?" -eq "1" ]; then
        exit 1
    fi
fi
echo "QT_MOBILITY_BIN = $QT_MOBILITY_BIN" >> "$CONFIG_IN"

#process plugin path
if [ -z "$QT_MOBILITY_PLUGINS" ]; then
    QT_MOBILITY_PLUGINS="$QT_MOBILITY_PREFIX/$PLUGIN_PATH"
else
    QT_MOBILITY_PLUGINS=`absPath $QT_MOBILITY_PLUGINS $LINUX_TARGET`
    if [ "$?" -eq "1" ]; then
        exit 1
    fi
fi
echo "QT_MOBILITY_PLUGINS = $QT_MOBILITY_PLUGINS" >> "$CONFIG_IN"

#process examples path
if [ -z "$QT_MOBILITY_EXAMPLES" ]; then
    QT_MOBILITY_EXAMPLES="$QT_MOBILITY_PREFIX/$BIN_PATH"
else
    QT_MOBILITY_EXAMPLES=`absPath $QT_MOBILITY_EXAMPLES $LINUX_TARGET`
    if [ "$?" -eq "1" ]; then
        exit 1
    fi
fi
echo "QT_MOBILITY_EXAMPLES = $QT_MOBILITY_EXAMPLES" >> "$CONFIG_IN"

#process demos path
if [ -z "$QT_MOBILITY_DEMOS" ]; then
    QT_MOBILITY_DEMOS="$QT_MOBILITY_PREFIX/$BIN_PATH"
else
    QT_MOBILITY_DEMOS=`absPath $QT_MOBILITY_DEMOS $LINUX_TARGET`
    if [ "$?" -eq "1" ]; then
        exit 1
    fi
fi
echo "QT_MOBILITY_DEMOS = $QT_MOBILITY_DEMOS" >> "$CONFIG_IN"
fi

echo "QT_MOBILITY_SOURCE_TREE = $relpath" >> "$QMAKE_CACHE"
echo "QT_MOBILITY_BUILD_TREE = $shadowpath" >> "$QMAKE_CACHE"

if [ -n "$MAC_SDK" ]; then
    QMAKE_MAC_SDK="$MAC_SDK"
   echo "QMAKE_MAC_SDK = $QMAKE_MAC_SDK" >> "$CONFIG_IN"
fi

if [ -z "$BUILD_UNITTESTS" ]; then
    echo "build_unit_tests = no" >> "$CONFIG_IN"
else
    echo "build_unit_tests = yes" >> "$CONFIG_IN"
fi

if [ -z "$BUILD_PUBLIC_UNITTESTS" ]; then
    echo "build_public_unit_tests = no" >> "$CONFIG_IN"
else
    echo "build_public_unit_tests = yes" >> "$CONFIG_IN"
fi

if [ -z "$BUILD_EXAMPLES" ]; then
    echo "build_examples = no" >> "$CONFIG_IN"
else
    echo "build_examples = yes" >> "$CONFIG_IN"
fi

if [ -z "$BUILD_DEMOS" ]; then
    echo "build_demos = no" >> "$CONFIG_IN"
else
    echo "build_demos = yes" >> "$CONFIG_IN"
fi

if [ -z "$BUILD_DOCS" ]; then
    echo "build_docs = no" >> "$CONFIG_IN"
else
    echo "build_docs = yes" >> "$CONFIG_IN"
fi

if [ -z "$BUILD_TOOLS" ]; then
    echo "build_tools = no" >> "$CONFIG_IN"
else
    echo "build_tools = yes" >> "$CONFIG_IN"
fi

if [ -z "$TEST_USE_SIMULATOR" ]; then
    echo "test_use_sim = no" >> "$CONFIG_IN"
else
    echo "test_use_sim = yes" >> "$CONFIG_IN"
fi

#process languages
if [ -z "LANGUAGES" ]; then
    echo "selected_languages =" >> "$CONFIG_IN"
else
    echo "selected_languages = $LANGUAGES" >> "$CONFIG_IN"
fi


echo "Configuring Qt Mobility"
echo 

WHICH="$relpath/config.tests/tools/which.test"

printf "Checking available Qt"
if ! "$WHICH" $QMAKE_EXEC 2>/dev/null 1>&2; then
    QMAKE_EXEC_ALTERNATIVE=
    if "$WHICH" qmake4 2>/dev/null 1>&2; then
        QMAKE_EXEC_ALTERNATIVE=qmake4
    elif "$WHICH" qmake-qt4 2>/dev/null 1>&2; then
        QMAKE_EXEC_ALTERNATIVE=qmake-qt4
    fi

    if [ -z "$QMAKE_EXEC_ALTERNATIVE" ]; then
        printf " ... Not found\n\n" >&2
        echo >&2 "Cannot find "$QMAKE_EXEC" in your PATH.";
        echo >&2 "Aborting."
        exit 1
    else
        QMAKE_EXEC="$QMAKE_EXEC_ALTERNATIVE"
    fi
fi

#we found a qmake binary
printf " ... "
$QMAKE_EXEC -query QT_VERSION

# find out which make we want to use
MAKE=
for m in make gmake; do
    if "$WHICH" $m >/dev/null 2>&1; then
        MAKE=`$WHICH $m`
        break
    fi
done
if [ -z "$MAKE" ]; then
    echo >&2 "Cannot find 'make' or 'gmake' in your PATH";
    echo >&2 "Aborting."
    exit 1
fi

compileTest()
{
    printf "Checking $1"
    CURRENT_PWD=`pwd`
    
    if [ "$shadowpath" = "$relpath" ]; then 
        #doing source tree build
        cd "$relpath/config.tests/$2"
        rm -rf ./$2
    else
        #using shadow build
        rm -rf config.tests/$2
        mkdir -p config.tests/$2
        cd config.tests/$2
    fi

    $QMAKE_EXEC $QMKSPEC "$relpath/config.tests/$2/$2.pro" 2>> "$CONFIG_LOG" >> "$CONFIG_LOG"
    printf  " ."
    "$MAKE" clean >> "$CONFIG_LOG"
    printf "."
    "$MAKE" >> "$CONFIG_LOG" 2>&1
    printf ". "
    if [ -e ./$2 ]; then
        echo "OK"
        echo "$2_enabled = yes" >> "$CONFIG_IN"
    else
        echo "Not Found"
        echo "$2_enabled = no" >> "$CONFIG_IN"
    fi
    cd "$CURRENT_PWD"
}

if [ -z "$PLATFORM_CONFIG" ]; then
#compile tests
    compileTest QMF qmf
    compileTest NetworkManager networkmanager
    compileTest "CoreWLAN (MacOS >= 10.6)" corewlan
    compileTest Immersion immersion
    compileTest "MeegoTouch Feedback" meegotouchfeedback
    compileTest "Maemo ICD" maemo-icd
    compileTest "Maemo ICD WLAN" maemo-icd-network-wlan
    compileTest "Maemo5 contacts dependencies" maemo5-contacts
    compileTest "Maemo5 organizer dependencies" maemo5-calendar
    compileTest "Maemo6 landmarks dependencies" maemo6-landmarks
    compileTest "Maemo Battery Managment Entity" bme
    compileTest "Bluez" bluez
    compileTest "Proj.4" proj
    compileTest "Gstreamer Photography" gstreamer-photography
    compileTest "Gstreamer AppSrc" gstreamer-appsrc
    compileTest "Blkid" blkid
    compileTest "Pulse Audio" pulseaudio
    compileTest "udev" udev
    compileTest "Maemo Heartbeat" iphb

    if [ "$NFC_SYMBIAN" = auto ]; then
        compileTest "Symbian NFC" nfc_symbian
    else
        echo "nfc_symbian_enabled = no" >> "$CONFIG_IN"
    fi

    if [ "$LINUX_TARGET" = maemo6 ] || [ "$LINUX_TARGET" = meego ]; then
        compileTest sensord sensord
    else
        echo "sensord_enabled = no" >> "$CONFIG_IN"
    fi

    if [ "$LINUX_TARGET" = meego ]; then
        compileTest connman connman
        compileTest "Location GeoClue master provider" geoclue-master
        compileTest "Location Gypsy provider" gypsy
    else
        echo "geoclue-master_enabled = no" >> "$CONFIG_IN"
        echo "gypsy_enabled = no" >> "$CONFIG_IN"
    fi
else
    echo "Skipping configure tests"
    echo "Loading ... features/platformconfig/$PLATFORM_CONFIG.pri"
    if [ ! -f "$relpath/features/platformconfig/$PLATFORM_CONFIG.pri" ]; then
        echo "Invalid platform configuration $PLATFORM_CONFIG.pri"
        exit 1;
    else
        echo "include(\$\${QT_MOBILITY_SOURCE_TREE}/features/platformconfig/$PLATFORM_CONFIG.pri)" >> "$CONFIG_IN"
    fi
fi
# It's a lot easier to make qmake do the dependency checking...
echo "mobility_modules = $MOBILITY_MODULES" >> "$CONFIG_IN"
echo "contains(mobility_modules,versit): mobility_modules *= contacts" >> "$CONFIG_IN"
echo "symbian:contains(nfc_symbian_enabled,yes):contains(mobility_modules,connectivity): mobility_modules *= serviceframework" >> "$CONFIG_IN"
echo "maemo5|maemo6:contains(maemo-icd_enabled, no): mobility_modules -= bearer" >> "$CONFIG_IN"
# Mobility doesn't support Bearer on MeeGo -> Use Qt 4.7 Bearer instead
echo "meego:contains(mobility_modules, bearer) { " >> "$CONFIG_IN"
#echo "    message(Bearer module not supported on MeeGo)" >> "$CONFIG_IN"
echo "    mobility_modules -= bearer" >> "$CONFIG_IN"
echo "}" >> "$CONFIG_IN"

echo "isEmpty(mobility_modules):error(No module selected. Aborting...)" >> "$CONFIG_IN"

# If libicd-network-wlan-dev.h is not present, use own copy.
# At time of writing, libicd-network-wlan-dev is not released for maemo5.
echo "maemo5:contains(maemo-icd-network-wlan_enabled, no): INCLUDEPATH += $relpath/src/3rdparty/icd-network-wlan" >> "$CONFIG_IN"

echo "Generating Mobility Headers..."
#remove old headers
rm -rf $shadowpath/include
mkdir $shadowpath/include

$relpath/bin/syncheaders $shadowpath/include/QtMobility $relpath/src/global
for module in $MOBILITY_MODULES; do
    case "$module" in 
        bearer)
            $relpath/bin/syncheaders $shadowpath/include/QtBearer $relpath/src/bearer
            ;;
        publishsubscribe)
            $relpath/bin/syncheaders $shadowpath/include/QtPublishSubscribe $relpath/src/publishsubscribe
            ;;
        location)
            $relpath/bin/syncheaders $shadowpath/include/QtLocation $relpath/src/location
            $relpath/bin/syncheaders $shadowpath/include/QtLocation $relpath/src/location/landmarks
            $relpath/bin/syncheaders $shadowpath/include/QtLocation $relpath/src/location/maps
            $relpath/bin/syncheaders $shadowpath/include/QtLocation $relpath/src/location/maps/tiled
            ;;
        serviceframework)
            $relpath/bin/syncheaders $shadowpath/include/QtServiceFramework $relpath/src/serviceframework
            ;;
        systeminfo)
            $relpath/bin/syncheaders $shadowpath/include/QtSystemInfo $relpath/src/systeminfo
            ;;
        contacts)
            $relpath/bin/syncheaders $shadowpath/include/QtContacts $relpath/src/contacts
            $relpath/bin/syncheaders $shadowpath/include/QtContacts $relpath/src/contacts/details
            $relpath/bin/syncheaders $shadowpath/include/QtContacts $relpath/src/contacts/requests
            $relpath/bin/syncheaders $shadowpath/include/QtContacts $relpath/src/contacts/filters
            ;;
        multimedia)
            $relpath/bin/syncheaders $shadowpath/include/QtMultimediaKit $relpath/src/multimedia
            $relpath/bin/syncheaders $shadowpath/include/QtMultimediaKit $relpath/src/multimedia/audio
            $relpath/bin/syncheaders $shadowpath/include/QtMultimediaKit $relpath/src/multimedia/video
            ;;
        messaging)
            $relpath/bin/syncheaders $shadowpath/include/QtMessaging $relpath/src/messaging
            ;;
        versit)
            #versit implies contacts.  organizer includes might also be necessary
            $relpath/bin/syncheaders $shadowpath/include/QtVersit $relpath/src/versit
            $relpath/bin/syncheaders $shadowpath/include/QtContacts $relpath/src/contacts
            $relpath/bin/syncheaders $shadowpath/include/QtContacts $relpath/src/contacts/details
            $relpath/bin/syncheaders $shadowpath/include/QtContacts $relpath/src/contacts/requests
            $relpath/bin/syncheaders $shadowpath/include/QtContacts $relpath/src/contacts/filters
            if [ -n "$ORGANIZER_REQUESTED" ]; then
                $relpath/bin/syncheaders $shadowpath/include/QtVersitOrganizer $relpath/src/versitorganizer
            fi
            ;;
        sensors)
            $relpath/bin/syncheaders $shadowpath/include/QtSensors $relpath/src/sensors
            ;;
        feedback)
            $relpath/bin/syncheaders $shadowpath/include/QtFeedback $relpath/src/feedback
            ;;
        gallery)
            $relpath/bin/syncheaders $shadowpath/include/QtGallery $relpath/src/gallery
            ;;
        organizer)
            $relpath/bin/syncheaders $shadowpath/include/QtOrganizer $relpath/src/organizer
            $relpath/bin/syncheaders $shadowpath/include/QtOrganizer $relpath/src/organizer/items
            $relpath/bin/syncheaders $shadowpath/include/QtOrganizer $relpath/src/organizer/requests
            $relpath/bin/syncheaders $shadowpath/include/QtOrganizer $relpath/src/organizer/filters
            $relpath/bin/syncheaders $shadowpath/include/QtOrganizer $relpath/src/organizer/details
            ;;
        connectivity)
            #connectivity implies serviceframework
            $relpath/bin/syncheaders $shadowpath/include/QtConnectivity $relpath/src/connectivity
            $relpath/bin/syncheaders $shadowpath/include/QtConnectivity $relpath/src/connectivity/nfc
            $relpath/bin/syncheaders $shadowpath/include/QtConnectivity $relpath/src/connectivity/bluetooth
            $relpath/bin/syncheaders $shadowpath/include/QtServiceFramework $relpath/src/serviceframework
            ;;
        *)
            echo "Cannot generate headers for $module"
            ;;
    esac
done

mv "$CONFIG_IN" config.pri
mkdir -p "$shadowpath/features"
if [ "$shadowpath" != "$relpath" ]; then
    cp -f "$relpath/features/strict_flags.prf" "$shadowpath/features"
fi

echo "Running $QMAKE_EXEC..."
if $QMAKE_EXEC -makefile $QMKSPEC -recursive "$relpath/qtmobility.pro"; then
    echo ""
    echo "configure has finished. You may run make or gmake to build the project now."
    echo ""
    echo "QT_MOBILITY_PREFIX = $QT_MOBILITY_PREFIX"
    echo "QT_MOBILITY_INCLUDE = $QT_MOBILITY_INCLUDE"
    echo "QT_MOBILITY_LIB = $QT_MOBILITY_LIB"
    echo "QT_MOBILITY_BIN = $QT_MOBILITY_BIN"
    echo "QT_MOBILITY_PLUGINS = $QT_MOBILITY_PLUGINS"
    echo "QT_MOBILITY_EXAMPLES = $QT_MOBILITY_EXAMPLES"
    echo "QT_MOBILITY_DEMOS = $QT_MOBILITY_DEMOS"

else
    echo ""
    echo "configure failed."
    exit 1
fi