aboutsummaryrefslogtreecommitdiff
path: root/configure
blob: d37ea808ac6d0059a1a42da50c3fc9300e13441a (plain)
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
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
#!/bin/sh
#
# Configures the libmeegotouch build
#
# Copyright (C) 2010 Nokia Corporation.
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
# WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

#-------------------------------------------------------------------------------
# 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`

#-------------------------------------------------------------------------------
# operating system detection
#-------------------------------------------------------------------------------

# need that throughout the script
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown

#-----------------------------------------------------------------------------
# M version detection
#-----------------------------------------------------------------------------
cd "$relpath"
M_MAJOR_VERSION=`grep -m1 M_MAJOR_VERSION mkspecs/features/meegotouch_defines.prf.in |cut -f2 -d'='|sed 's/ //g'`
M_MINOR_VERSION=`grep -m1 M_MINOR_VERSION mkspecs/features/meegotouch_defines.prf.in |cut -f2 -d'='|sed 's/ //g'`
M_PATCH_VERSION=`grep -m1 M_PATCH_VERSION mkspecs/features/meegotouch_defines.prf.in |cut -f2 -d'='|sed 's/ //g'`
M_VERSION=$M_MAJOR_VERSION.$M_MINOR_VERSION.$M_PATCH_VERSION

if [ -z "$M_MAJOR_VERSION" ]; then
   echo "Cannot process version from src/meegotouch_defines.prf: $M_VERSION"
   echo "Cannot proceed."
   exit 1
fi

#-------------------------------------------------------------------------------
# initalize variables
#-------------------------------------------------------------------------------

# initalize internal variables
CFG_DEBUG=yes
CFG_RELEASE=no
CFG_OPENGL=yes
CFG_TESTABLE=no
CFG_COVERAGE=no
CFG_TIMESTAMPS=no
CFG_PCH=no
CFG_NO_WERROR=no
CFG_DEV=no
CFG_MINIMAL=no
CFG_BUILD_TESTS=no
CFG_BUILD_BENCHMARKS=no
CFG_BUILD_EXAMPLES=no

M_DEFAULT_BUILD_PARTS="libs demos"
CFG_BUILD_PARTS=""
CFG_NOBUILD_PARTS=""
CFG_DBUS=auto
CFG_ICU=auto
CFG_GCONF=auto
CFG_MEEGOGRAPHICSSYSTEM=no

HAVE_ICU=no
HAVE_CONTEXTSUBSCRIBER=no
HAVE_GCONF=no
HAVE_DBUS=no
HAVE_CONTENTACTION=no
HAVE_XDAMAGE=no
HAVE_XFIXES=no
HAVE_QTM_SERVICEFRAMEWORK=no
IS_MAEMO5=no
HAVE_MEEGOGRAPHICSSYSTEM=no

OPT_SHADOW=maybe

IS_ARMEL=no
   
# initalize variables used for installation
M_INSTALL_PREFIX=/usr/local
M_INSTALL_SYSCONFDIR=/etc
M_INSTALL_LIBDIR= # Will be $M_INSTALL_PREFIX/lib unless overriden

#-------------------------------------------------------------------------------
# parse command line arguments
#-------------------------------------------------------------------------------

# parse the arguments, setting things to "yes" or "no"
while [ "$#" -gt 0 ]; do
    CURRENT_OPT="$1"
    UNKNOWN_ARG=no
    case "$1" in
    #Autoconf style options
    --enable-*)
        VAR=`echo $1 | sed "s,^--enable-\(.*\),\1,"`
        VAL=yes
        ;;
    --disable-*)
        VAR=`echo $1 | sed "s,^--disable-\(.*\),\1,"`
        VAL=no
        ;;
    --*=*)
        VAR=`echo $1 | sed "s,^--\(.*\)=.*,\1,"`
        VAL=`echo $1 | sed "s,^--.*=\(.*\),\1,"`
        ;;
    --no-*)
        VAR=`echo $1 | sed "s,^--no-\(.*\),\1,"`
        VAL=no
        ;;
    --*)
        VAR=`echo $1 | sed "s,^--\(.*\),\1,"`
        VAL=yes
        ;;
    #Qt style no options
    -no-*)
        VAR=`echo $1 | sed "s,^-no-\(.*\),\1,"`
        VAL=no
        ;;
    #Qt style yes options
        -h|-help|-v|-verbose|-debug|-release|-testable|-coverage|-timestamps|-dev|-minimal|-dbus|-icu|-gconf|-meegographicssystem)
        VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
        VAL=yes
        ;;
    #Qt style options that pass an argument
    -prefix|-make|-nomake|-sysconfdir|-libdir)
        VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
        shift
        VAL="$1"
        ;;
    #Qt style complex options in one command
    -enable-*|-disable-*)
        VAR=`echo $1 | sed "s,^-\([^-]*\)-.*,\1,"`
        VAL=`echo $1 | sed "s,^-[^-]*-\(.*\),\1,"`
        ;;
    #Qt Builtin/System style options
    -no-*)
        VAR=`echo $1 | sed "s,^-[^-]*-\(.*\),\1,"`
        VAL=`echo $1 | sed "s,^-\([^-]*\)-.*,\1,"`
        ;;
    #Options that cannot be generalized
    -opengl)
        VAR=opengl
        # this option may or may not be followed by an argument
        if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then
            VAL=yes
        else
            shift;
            VAL=$1
        fi
	;;
    -*)
        VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
        VAL="unknown"
        ;;
    *)
        UNKNOWN_ARG=yes
        ;;
    esac
    if [ "$UNKNOWN_ARG" = "yes" ]; then
        echo "$1: unknown argument"
        OPT_HELP=yes
        ERROR=yes
        shift
        continue
     fi
    shift

    UNKNOWN_OPT=no
    case "$VAR" in
    prefix)
        M_INSTALL_PREFIX="$VAL"
        ;;
    sysconfdir)
        M_INSTALL_SYSCONFDIR="$VAL"
        ;;
    libdir)
        M_INSTALL_LIBDIR="$VAL"
        ;;
    nomake)
	CFG_NOBUILD_PARTS="$CFG_NOBUILD_PARTS $VAL"
        ;;
    make)
	CFG_BUILD_PARTS="$CFG_BUILD_PARTS $VAL"
        ;;
    opengl)
        if  [ "$VAL" = "auto" ] || [ "$VAL" = "desktop" ] ||
            [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] ||
            [ "$VAL" = "es1cl" ] || [ "$VAL" = "es1" ] || [ "$VAL" = "es2" ]; then
            CFG_OPENGL="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    release)
        CFG_RELEASE="$VAL"
	;;
    debug)
        CFG_DEBUG="$VAL"
        ;;
    testable)
        CFG_TESTABLE="$VAL"
        ;;
    no-werror)
        CFG_NO_WERROR="yes" 
        ;;
    coverage)
        CFG_COVERAGE="$VAL"
        ;;
    timestamps)
        CFG_TIMESTAMPS="$VAL"
        ;;
    pch)
        CFG_PCH="$VAL"
        ;;
    dev)
        CFG_DEV="yes"
        CFG_BUILD_TESTS="yes"
        CFG_BUILD_EXAMPLES="yes"
        CFG_BUILD_BENCHMARKS="yes"
        ;;
    minimal)
        CFG_MINIMAL="yes"
        ;;
    tests)
        CFG_BUILD_TESTS="yes"
        ;;
    examples)
        CFG_BUILD_EXAMPLES="yes"
        ;;
    benchmarks)
        CFG_BUILD_BENCHMARKS="yes"
        ;;
    maemo5)
        IS_MAEMO5="yes"
        ;;
    dbus)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_DBUS="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    icu)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_ICU="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    gconf)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_GCONF="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    meegographicssystem)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_MEEGOGRAPHICSSYSTEM="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    h|help)
        if [ "$VAL" = "yes" ]; then
            OPT_HELP="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    v|verbose)
        if [ "$VAL" = "yes" ]; then
            if [ "$OPT_VERBOSE" = "$VAL" ]; then            # takes two verboses to turn on qmake debugs
                QMAKE_SWITCHES="$QMAKE_SWITCHES -d"
            else
                OPT_VERBOSE=yes
            fi
        elif [ "$VAL" = "no" ]; then
            if [ "$OPT_VERBOSE" = "$VAL" ] && echo "$QMAKE_SWITCHES" | grep ' -d' >/dev/null 2>&1; then
                QMAKE_SWITCHES=`echo $QMAKE_SWITCHES | sed "s, -d,,"`
            else
                OPT_VERBOSE=no
            fi
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    silent)
        CFG_SILENT="$VAL"
        ;;
    esac
    if [ "$UNKNOWN_OPT" = "yes" ]; then
        echo "${CURRENT_OPT}: invalid command-line switch"
        OPT_HELP=yes
        ERROR=yes
    fi
done

if [ "$CFG_SILENT" = "yes" ]; then
    QMAKE_CONFIG="$QMAKE_CONFIG silent"
fi

#-------------------------------------------------------------------------------
# tests
#-------------------------------------------------------------------------------

# Make default LIBDIR relative to prefix unless overriden
if [ -z "$M_INSTALL_LIBDIR" ]; then
    M_INSTALL_LIBDIR=$M_INSTALL_PREFIX/lib
fi

#setup the build parts
CFG_BUILD_PARTS="$CFG_BUILD_PARTS $M_DEFAULT_BUILD_PARTS"

for nobuild in $CFG_NOBUILD_PARTS; do
    CFG_BUILD_PARTS=`echo "$CFG_BUILD_PARTS" | sed "s, $nobuild,,g"`
done

if echo $CFG_BUILD_PARTS | grep -v libs >/dev/null 2>&1; then
    echo
    echo "WARNING: libs is a required part of the build."
    echo
    CFG_BUILD_PARTS="$CFG_BUILD_PARTS libs"
fi

if [ "$CFG_BUILD_TESTS" = "yes" ]; then
    CFG_BUILD_PARTS="$CFG_BUILD_PARTS tests"
else
  if echo $CFG_BUILD_PARTS | grep tests >/dev/null 2>&1; then
    CFG_BUILD_TESTS="yes"
  fi
fi

if [ "$CFG_BUILD_BENCHMARKS" = "yes" ]; then
    CFG_BUILD_PARTS="$CFG_BUILD_PARTS benchmarks"
else
  if echo $CFG_BUILD_PARTS | grep benchmarks >/dev/null 2>&1; then
    CFG_BUILD_BENCHMARKS="yes"
  fi
fi

if [ "$CFG_BUILD_EXAMPLES" = "yes" ]; then
    CFG_BUILD_PARTS="$CFG_BUILD_PARTS examples"
else
  if echo $CFG_BUILD_PARTS | grep examples >/dev/null 2>&1; then
    CFG_BUILD_EXAMPLES="yes"
  fi
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

# Test for ICU
if [ "$CFG_ICU" != "no" ]; then
    which icu-config > /dev/null
    if [ $? -eq 0 ]; then
        icu-config --exists
        if [ $? -eq 0 ]; then
            HAVE_ICU=yes
        fi
    fi
    if [ "$CFG_ICU" = "yes" -a "$HAVE_ICU" = "no" ]; then
        echo "You specified  -icu  but icu was not found."
        echo "Please install the libicu-dev package."
        exit 1
    fi
fi

# Test for pkg-config enabled dependencies
which pkg-config > /dev/null
if [ $? -eq 0 ]; then

    pkg-config --atleast-version=0.5.25 contextsubscriber-1.0
    if [ $? -eq 0 ]; then
        HAVE_CONTEXTSUBSCRIBER=yes
    fi

    if [ "$CFG_GCONF" != "no" ]; then
        pkg-config --exists gconf-2.0
        if [ $? -eq 0 ]; then
            HAVE_GCONF=yes
        else
            if [ "$CFG_GCONF" = "yes" ]; then
                echo "You specified  -gconf  but gconf was not found."
                echo "Please install the libgconf2-dev package."
                exit 1
            fi
        fi
    fi

    # Test for DBus
    if [ "$CFG_DBUS" != "no" ]; then
        pkg-config --exists QtDBus
        if [ $? -eq 0 ]; then
	    HAVE_DBUS=yes
        fi
        if [ "$CFG_DBUS" = "yes" -a "$HAVE_DBUS" = "no" ]; then
            echo "You specified  -dbus  but dbus was not found."
            echo "Please install the DBus and QtDBus packages."
            exit 1
        fi
    fi

    pkg-config --exists contentaction-0.1
    if [ $? -eq 0 ]; then
	#HAVE_CONTENTACTION=yes DISABLED FOR NOW
	HAVE_CONTENTACTION=no
    fi

    pkg-config --exists xdamage
    if [ $? -eq 0 ]; then
        HAVE_XDAMAGE=yes
    fi

    pkg-config --exists xfixes
    if [ $? -eq 0 ]; then
        HAVE_XFIXES=yes
    fi
    # For Scratchbox and  For OBS/MeeGo
    if [ ! -z "`uname -m | grep arm`" ]; then   
    	IS_ARMEL=yes  
    fi      

    if [ "$CFG_MEEGOGRAPHICSSYSTEM" != "no" ]; then
        if  [ "$IS_ARMEL" = "yes" ]; then
            HAVE_MEEGOGRAPHICSSYSTEM=yes
        else
            echo "MeeGo graphicssystem is only available for ARM."
            exit 1
        fi
    fi
fi

# Test for qt service framework
which servicexmlgen > /dev/null
if [ $? -eq 0 ]; then
    HAVE_QTM_SERVICEFRAMEWORK=yes
fi


#-------------------------------------------------------------------------------
# help - interactive parts of the script _after_ this section please
#-------------------------------------------------------------------------------

# next, emit a usage message if something failed.
if [ "$OPT_HELP" = "yes" ]; then
    [ "x$ERROR" = "xyes" ] && echo
    cat <<EOF
Usage:  $relconf [-prefix <dir>] [-release] [-debug] [-make <part>]
        [-no-make <part>]

Installation options:

    -prefix <dir> ...... This will install everything relative to <dir>
                         (default $M_INSTALL_PREFIX)
    -sysconfdir <dir> .. This will put configuration files in <dir>
                         (default $M_INSTALL_SYSCONFDIR)
    -libdir <dir> ...... This will put libraries in <dir>
                         (default $M_INSTALL_LIBDIR)

Configure options:

 The defaults (*) are usually acceptable. A plus (+) denotes a default value
 that needs to be evaluated. If the evaluation succeeds, the feature is
 included. Here is a short explanation of each option:

    -release ................. Compile and link libmeegotouch in release mode
 *  -debug ................... Compile and link libmeegotouch with debugging turned on

    -testable ................ Enable the testability plugin interface in libmeegotouch
    -timestamps .............. Enable time debug measurements in the code
    -coverage ................ Enable code coverage calculation
    -pch ..................... Enable pre-compiled header
    -no-werror ............... Disable warnings as errors gcc flag

Additional options:

    -make <part> ............. Add part to the list of parts to be built at make time
                               (*libs *demos tests benchmarks)
    -nomake <part> ........... Exclude part from the list of parts to be built

    -dev ..................... Compile and link with default developer options.
                               This enables the benchmarks and tests parts.

    -tests ................... Build the tests.
    -benchmarks .............. Build the benchmarks.
    -examples ................ Build the examples.

    -maemo5 .................. Build libmeegotouch for the N900 device with maemo5.

    -no-dbus ................. Do not compile with DBus support.
 +  -dbus .................... Compile with DBus support.

    -no-gconf ................ Do not compile with gconf support.
 +  -gconf ................... Compile with gconf support.

    -no-icu .................. Do not compile with ICU support.
 +  -icu ..................... Compile with ICU support.

    -no-meegographicssystem .. Do not compile with meego graphicssystem support.
 +  -meegographicssystem ..... Compile with meego graphicssystem support.

EOF

exit 0

fi

#-------------------------------------------------------------------------------
# save configuration into meegotouchconfig.pri
#-------------------------------------------------------------------------------

if [ "$OPT_SHADOW" = "yes" ]; then
    if [ -f "$relpath/mkspecs/meegotouchconfig.pri" ]; then
        echo >&2 "You cannot make a shadow build from a source tree containing a previous build."
        echo >&2 "Cannot proceed."
        echo >&2 ""
        echo >&2 "Please clean your source directory by executing this command:"
        echo >&2 ""
        echo >&2 "make distclean"
        echo >&2 ""
        exit 1
    fi

    # create mkspecs/features dir in build tree
    mkdir -p "$outpath/mkspecs/features"
fi


MEEGOTOUCHCONFIG="$outpath/mkspecs/meegotouchconfig.pri"
[ -f "$MEEGOTOUCHCONFIG.tmp" ] && rm -f "$MEEGOTOUCHCONFIG.tmp"

if [ "$CFG_DEBUG" = "yes" ]; then
    MEEGOTOUCHCONFIG_CONFIG="$MEEGOTOUCHCONFIG_CONFIG debug"
fi

if [ "$CFG_RELEASE" = "yes" ]; then
    MEEGOTOUCHCONFIG_CONFIG="$MEEGOTOUCHCONFIG_CONFIG release"
fi


if [ "$CFG_TESTABLE" = "yes" ]; then
    MEEGOTOUCHCONFIG_FEATURES="$MEEGOTOUCHCONFIG_FEATURES testable"
fi

if [ "$CFG_NO_WERROR" = "yes" ]; then
    MEEGOTOUCHCONFIG_FEATURES="$MEEGOTOUCHCONFIG_FEATURES no-werror" 	
fi

if [ "$CFG_TIMESTAMPS" = "yes" ]; then
    MEEGOTOUCHCONFIG_FEATURES="$MEEGOTOUCHCONFIG_FEATURES timestamps"
fi

if [ "$CFG_COVERAGE" = "yes" ]; then
    which bcov > /dev/null
    if [ $? -ne 0 ]; then
        echo "You specified  -coverage but bcov was not found."
        echo "Please install the bcov and lcov packages."
        exit 1
    fi
    which lcov > /dev/null
    if [ $? -ne 0 ]; then
        echo "You specified  -coverage but lcov was not found."
        echo "Please install the bcov and lcov packages."
        exit 1
    fi
    if [ "$SBOX_USE_CCACHE" != "no" ]; then
        echo "You specified  -coverage so the SBOX_USE_CCACHE has to be set to \"no\"."
        exit 1
    fi

    MEEGOTOUCHCONFIG_CONFIG="$MEEGOTOUCHCONFIG_CONFIG coverage"
fi

if [ "$CFG_PCH" = "yes" ]; then
    MEEGOTOUCHCONFIG_FEATURES="$MEEGOTOUCHCONFIG_FEATURES pch"
fi

if [ "$CFG_MINIMAL" = "yes" ]; then
    MEEGOTOUCHCONFIG_FEATURES="$MEEGOTOUCHCONFIG_FEATURES minimal"
fi


if [ "$HAVE_ICU" = "yes" ]; then
    MEEGOTOUCHCONFIG_DEPS="$MEEGOTOUCHCONFIG_DEPS HAVE_ICU"
fi

if [ "$HAVE_CONTENTACTION" = "yes" ]; then
    MEEGOTOUCHCONFIG_DEPS="$MEEGOTOUCHCONFIG_DEPS HAVE_CONTENTACTION"
fi

if [ "$HAVE_XDAMAGE" = "yes" ]; then
    MEEGOTOUCHCONFIG_DEPS="$MEEGOTOUCHCONFIG_DEPS HAVE_XDAMAGE"
fi

if [ "$HAVE_XFIXES" = "yes" ]; then
    MEEGOTOUCHCONFIG_DEPS="$MEEGOTOUCHCONFIG_DEPS HAVE_XFIXES"
fi

if [ "$HAVE_CONTEXTSUBSCRIBER" = "yes" ]; then
    MEEGOTOUCHCONFIG_DEPS="$MEEGOTOUCHCONFIG_DEPS HAVE_CONTEXTSUBSCRIBER"
fi

if [ "$HAVE_GCONF" = "yes" ]; then
    MEEGOTOUCHCONFIG_DEPS="$MEEGOTOUCHCONFIG_DEPS HAVE_GCONF"
fi

if [ "$HAVE_DBUS" = "yes" ]; then
    MEEGOTOUCHCONFIG_DEPS="$MEEGOTOUCHCONFIG_DEPS HAVE_DBUS"
fi

if [ "$HAVE_QTM_SERVICEFRAMEWORK" = "yes" ]; then
    MEEGOTOUCHCONFIG_DEPS="$MEEGOTOUCHCONFIG_DEPS HAVE_QTM_SERVICEFRAMEWORK"
fi

if [ "$IS_MAEMO5" = "yes" ]; then
    MEEGOTOUCHCONFIG_DEPS="$MEEGOTOUCHCONFIG_DEPS M_OS_MAEMO5"
fi

if [ "$HAVE_MEEGOGRAPHICSSYSTEM" = "yes" ]; then
    MEEGOTOUCHCONFIG_DEPS="$MEEGOTOUCHCONFIG_DEPS HAVE_MEEGOGRAPHICSSYSTEM"
fi

if [ "$IS_ARMEL" = "yes" ]; then
    MEEGOTOUCHCONFIG_DEPS="$MEEGOTOUCHCONFIG_DEPS IS_ARMEL"
fi                               


cat >>"$MEEGOTOUCHCONFIG.tmp" <<EOF
# Autogenerated by configure script

#cleaning in CONFIG to get right configuration
CONFIG -=release
CONFIG -=debug

#build configuration
CONFIG += $MEEGOTOUCHCONFIG_CONFIG

M_BUILD_PARTS += $CFG_BUILD_PARTS

M_BUILD_FEATURES += $MEEGOTOUCHCONFIG_FEATURES

#versioning
M_VERSION = $M_VERSION

#paths
M_INSTALL_PREFIX = $M_INSTALL_PREFIX
M_INSTALL_SYSCONFDIR = $M_INSTALL_SYSCONFDIR
M_INSTALL_LIBDIR = $M_INSTALL_LIBDIR

#dependencies
DEFINES += BUILD_M $MEEGOTOUCHCONFIG_DEPS

EOF

# replace meegotouchconfig.pri if it differs from the newly created temp file
if cmp -s "$MEEGOTOUCHCONFIG.tmp" "$MEEGOTOUCHCONFIG"; then
    rm -f "$MEEGOTOUCHCONFIG.tmp"
else
    mv -f "$MEEGOTOUCHCONFIG.tmp" "$MEEGOTOUCHCONFIG"
fi

# now try to create a .qmake.cache file to be able to find the build root
M_QMAKE_CACHE="$outpath/.qmake.cache"
[ -f "$M_QMAKE_CACHE.tmp" ] && rm -f "$M_QMAKE_CACHE.tmp"

cat >>"$M_QMAKE_CACHE.tmp" <<EOF
# Autogenerated by configure script
M_BUILD_TREE = \$\$quote($outpath)
M_SOURCE_TREE = \$\$quote($relpath)

EOF

# replace .qmake.cache if it differs from the newly created temp file
if cmp -s "$M_QMAKE_CACHE.tmp" "$M_QMAKE_CACHE"; then
    rm -f "$M_QMAKE_CACHE.tmp"
else
    mv -f "$M_QMAKE_CACHE.tmp" "$M_QMAKE_CACHE"
fi

MEEGOTOUCH_DEFINES_PRF="$outpath/mkspecs/features/meegotouch_defines.prf"

# and now we generate a meegotouch_defines.prf that will contain the right
# install prefix
cat "$relpath/mkspecs/features/meegotouch_defines.prf.in" \
| sed -e "s,@@M_UNIX_INSTALL_PREFIX@@,$M_INSTALL_PREFIX,g" \
| sed -e "s,@@M_UNIX_INSTALL_SYSCONFDIR@@,$M_INSTALL_SYSCONFDIR,g" \
| sed -e "s,@@M_UNIX_INSTALL_LIBDIR@@,$M_INSTALL_LIBDIR,g" \
| sed -e "s,@@MEEGOTOUCHCONFIG_DEPS@@,$MEEGOTOUCHCONFIG_DEPS,g" \
> "$MEEGOTOUCH_DEFINES_PRF.tmp"

# replace meegotouch_defines.prf if it differs from the newly created temp file
if cmp -s "$MEEGOTOUCH_DEFINES_PRF.tmp" "$MEEGOTOUCH_DEFINES_PRF"; then
    rm -f "$MEEGOTOUCH_DEFINES_PRF.tmp"
else
    mv -f "$MEEGOTOUCH_DEFINES_PRF.tmp" "$MEEGOTOUCH_DEFINES_PRF"
fi

# substitute prefix in .pc files
MEEGOTOUCH_PC_DIR="$outpath/src/data"
MEEGOTOUCH_PC_FILES="meegotouch
meegotouchcore
meegotouchsettings
meegotouch-boostable
"

# make sure the directory exists
if [ ! -d $MEEGOTOUCH_PC_DIR ]; then
    mkdir -p $MEEGOTOUCH_PC_DIR
fi

for i in $MEEGOTOUCH_PC_FILES
do
   pc_file="$MEEGOTOUCH_PC_DIR/$i.pc"
   pc_in="$relpath/src/data/$i.pc.in"

   cat "$pc_in" \
   | sed -e "s,@@M_UNIX_INSTALL_PREFIX@@,$M_INSTALL_PREFIX,g" \
   | sed "s/@@M_VERSION@@/$M_VERSION/g" \
   > "$pc_file.tmp"

  # replace meegotouch_defines.prf if it differs from the newly created temp file
  if cmp -s "$pc_file.tmp" "$pc_file"; then
      rm -f "$pc_file.tmp"
  else
      mv -f "$pc_file.tmp" "$pc_file"
  fi

done

#-------------------------------------------------------------------------------
# build makefiles based on the configuration
#-------------------------------------------------------------------------------

#echo "Finding project files. Please wait..."
#"qmake" -r "${relpath}/projects.pro"
#if [ -f "${relpath}/projects.pro" ]; then
#    mkfile="${outpath}/Makefile"
#    [ -f "$mkfile" ] && chmod +w "$mkfile"
#fi

if [ -z "$QTDIR" ]; then
    which qmake > /dev/null
    if [ $? -eq 0 ]; then
        QMAKE_BIN=`which qmake`
    else
        echo "qmake was not found in your path\n"
    fi
elif [ -f "$QTDIR/bin/qmake" ]; then
    QMAKE_BIN="$QTDIR/bin/qmake"
else
    echo "QTDIR variable was set but could not find $QTDIR/bin/qmake\n"
fi

if [ -z "$QMAKE_BIN" ]; then
    echo "If your Qt is in a nonstandard location, try:"
    echo "QTDIR=<path to your Qt directory> ./$relconf"
    exit 1
fi

# now check for qt version
QT_MAJOR_VERSION_NEEDED=4
QT_MINOR_VERSION_NEEDED=7

QT_VERSION=`$QMAKE_BIN -version | tail -1`

QT_MAJOR_VERSION=0
QT_MINOR_VERSION=0
QT_PATCH_VERSION=0
if [ -n "$QT_VERSION" ]; then
   QT_VERSION=`echo $QT_VERSION | sed 's,^ *Using *Qt *version *\([^ ]*\) *in .*$,\1,'`
   MAJOR=`echo $QT_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\1,'`
   if [ -n "$MAJOR" ]; then
     MINOR=`echo $QT_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\2,'`
      PATCH=`echo $QT_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\3,'`
      QT_MAJOR_VERSION="$MAJOR"
      [ -z "$MINOR" ] || QT_MINOR_VERSION="$MINOR"
      [ -z "$PATCH" ] || QT_PATCH_VERSION="$PATCH"
   fi
fi

if [ -z "$QT_MAJOR_VERSION" ]; then
   echo "Cannot process version from qglobal.h: $QT_VERSION"
   echo "Cannot proceed."
   exit 1
fi

if [ "$QT_MAJOR_VERSION" -lt "$QT_MAJOR_VERSION_NEEDED" ] \
    || [ "$QT_MINOR_VERSION" -lt "$QT_MINOR_VERSION_NEEDED" ]; then
    echo "Your Qt version is too old: $QT_VERSION"
    echo "You need at least version $QT_MAJOR_VERSION_NEEDED.$QT_MINOR_VERSION_NEEDED.0"
    echo "Cannot proceed."
    exit 1
fi

# set special options for mac build
if [ "$UNAME_SYSTEM" = "Darwin" ]; then
    QMAKE_SWITCHES="$QMAKE_SWITCHES -spec macx-g++"
fi


#Run qmake
cd "$outpath"
$QMAKE_BIN "$relpath/projects.pro" $QMAKE_CONFIG $QMAKE_SWITCHES

#-------------------------------------------------------------------------------
# give feedback on configuration
#-------------------------------------------------------------------------------

echo ""
echo ""
echo "Optional build dependencies found:"

echo "ICU ............................. $HAVE_ICU"
echo "Context Subscriber 1.0 .......... $HAVE_CONTEXTSUBSCRIBER"
echo "Content Action 0.1 .............. $HAVE_CONTENTACTION"
echo "GConf 2.0 ....................... $HAVE_GCONF"
echo "DBus (incl. QtDBus) ............. $HAVE_DBUS"
echo "XDamage ......................... $HAVE_XDAMAGE"
echo "XFixes .......................... $HAVE_XFIXES"
echo "Qt Mobility Service Framework ... $HAVE_QTM_SERVICEFRAMEWORK"
echo "MeeGo graphicssystem ............ $HAVE_MEEGOGRAPHICSSYSTEM"

if [ "$CFG_DEV" = "yes" ]; then
    echo ""
    echo ""
    echo "Enabling MeeGo Touch UI developer's build"
    echo ""
else
    echo ""
    echo ""
fi

echo "MeeGo Touch UI framework build configuration:"
echo "Version ............. $M_VERSION"
echo "Build ............... $CFG_BUILD_PARTS"
echo "Extra features ...... $MEEGOTOUCHCONFIG_FEATURES"
echo "Release ............. $CFG_RELEASE"
echo "Debug ............... $CFG_DEBUG"

echo
echo "Benchmarks .......... $CFG_BUILD_BENCHMARKS"
echo "Tests ............... $CFG_BUILD_TESTS"
echo "Examples ............ $CFG_BUILD_EXAMPLES"

if [ "$IS_MAEMO5" = "yes" ]; then
    echo ""
    echo "Building for Maemo 5"
fi

echo ""
echo libmeegotouch is now configured for building. Just run \'make\'.
if [ "$relpath" = "$M_INSTALL_PREFIX" ]; then
    echo Once everything is built, libmeegotouch is installed.
    echo You should not run \'make install\'.
else
    echo Once everything is built, you can run \'make install\'.
    echo libmeegotouch will be installed into $M_INSTALL_PREFIX
fi

echo ""
echo ""