qtmobility/configure
changeset 0 cfcbf08528c4
child 2 5822d84012fb
child 4 90517678cc4f
equal deleted inserted replaced
-1:000000000000 0:cfcbf08528c4
       
     1 #!/bin/sh
       
     2 #############################################################################
       
     3 ##
       
     4 ## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     5 ## All rights reserved.
       
     6 ## Contact: Nokia Corporation (qt-info@nokia.com)
       
     7 ##
       
     8 ## This file is part of the Qt Mobility Components.
       
     9 ##
       
    10 ## $QT_BEGIN_LICENSE:LGPL$
       
    11 ## No Commercial Usage
       
    12 ## This file contains pre-release code and may not be distributed.
       
    13 ## You may use this file in accordance with the terms and conditions
       
    14 ## contained in the Technology Preview License Agreement accompanying
       
    15 ## this package.
       
    16 ##
       
    17 ## GNU Lesser General Public License Usage
       
    18 ## Alternatively, this file may be used under the terms of the GNU Lesser
       
    19 ## General Public License version 2.1 as published by the Free Software
       
    20 ## Foundation and appearing in the file LICENSE.LGPL included in the
       
    21 ## packaging of this file.  Please review the following information to
       
    22 ## ensure the GNU Lesser General Public License version 2.1 requirements
       
    23 ## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    24 ##
       
    25 ## In addition, as a special exception, Nokia gives you certain additional
       
    26 ## rights.  These rights are described in the Nokia Qt LGPL Exception
       
    27 ## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    28 ##
       
    29 ## If you have questions regarding the use of this file, please contact
       
    30 ## Nokia at qt-info@nokia.com.
       
    31 ##
       
    32 ##
       
    33 ##
       
    34 ##
       
    35 ##
       
    36 ##
       
    37 ##
       
    38 ##
       
    39 ## $QT_END_LICENSE$
       
    40 ##
       
    41 #############################################################################
       
    42 
       
    43 # the current directory (shadow build dir)
       
    44 shadowpath=`/bin/pwd`
       
    45 # the name of this script
       
    46 relconf=`basename $0`
       
    47 # the directory of this script is the "source tree"
       
    48 relpath=`dirname $0`
       
    49 relpath=`(cd "$relpath"; /bin/pwd)`
       
    50 
       
    51 CONFIG_IN="$shadowpath/config.in"
       
    52 QT_MOBILITY_PREFIX=$shadowpath/install
       
    53 QT_MOBILITY_INCLUDE=
       
    54 QT_MOBILITY_LIB=
       
    55 QT_MOBILITY_BIN=
       
    56 BUILD_UNITTESTS=
       
    57 BUILD_EXAMPLES=
       
    58 BUILD_DOCS=yes
       
    59 RELEASEMODE=
       
    60 BUILD_SILENT=
       
    61 LINUX_TARGET=
       
    62 QMAKE_CACHE="$shadowpath/.qmake.cache"
       
    63 LIB_PATH="lib"
       
    64 BIN_PATH="bin"
       
    65 MAC_SDK=
       
    66 MOBILITY_MODULES="bearer location contacts multimedia publishsubscribe versit messaging systeminfo serviceframework sensors"
       
    67 MOBILITY_MODULES_UNPARSED=
       
    68 
       
    69 usage() 
       
    70 {
       
    71     echo "Usage: configure [-prefix <dir>] [headerdir <dir>] [libdir <dir>]"
       
    72     echo "                 [-bindir <dir>] [-tests] [-examples] [-no-docs]"
       
    73     echo "                 [-debug] [-release] [-silent] [-modules <list>]"
       
    74     echo
       
    75     echo "Options:"
       
    76     echo
       
    77     echo "-prefix <dir> ..... This will install everything relative to <dir>"
       
    78     echo "                    (default prefix: $shadowpath/install)"
       
    79     echo "-headerdir <dir> .. Header files will be installed to <dir>"
       
    80     echo "                    (default prefix: PREFIX/include)"
       
    81     echo "-libdir <dir> ..... Libraries will be installed to <dir>"
       
    82     echo "                    (default PREFIX/lib)"
       
    83     echo "-bindir <dir> ..... Executables will be installed to <dir>"
       
    84     echo "                    (default PREFIX/bin)"
       
    85     echo "-debug ............ Build with debugging symbols"
       
    86     echo "-release .......... Build without debugging symbols"
       
    87     echo "-silent ........... Reduces build output"
       
    88     echo "-tests ............ Build unit tests (not build by default)"
       
    89     echo "                    Note, this adds test symbols to all libraries"
       
    90     echo "                    and should not be used for release builds."
       
    91     echo "-examples ......... Build example applications"
       
    92     echo "-no-docs .......... Do not build documentation (build by default)"
       
    93     echo "-modules <list> ... Restrict list of modules to build (default all supported)"
       
    94     echo "                    Choose from: bearer contacts location publishsubscribe"
       
    95     echo "                    messaging multimedia systeminfo serviceframework versit"
       
    96     echo "                    sensors"
       
    97     echo "                    Modules should be separated by a space and surrounded"
       
    98     echo "                    by double quotation. If a"
       
    99     echo "                    selected module depends on other modules dependencies"
       
   100     echo "                    will automatically be enabled."
       
   101     echo "-maemo6 ........... Build Qt Mobility for Maemo6 (Harmattan)."
       
   102     echo "-maemo5 ........... Build Qt Mobility for Maemo5 (Freemantle)."
       
   103     echo "-sdk <sdk>..........Build using Apple provided SDK <path/to/sdk>."
       
   104     echo "                    example: -sdk /Developer/SDKs/MacOSX10.6.sdk"
       
   105     echo
       
   106     
       
   107     rm -f "$CONFIG_IN"
       
   108     exit 1
       
   109 }
       
   110 
       
   111 rm -rf "$QMAKE_CACHE"
       
   112 CONFIG_LOG="$shadowpath/config.log"
       
   113 rm -rf "$CONFIG_LOG"
       
   114 
       
   115 while [ "$#" -gt 0 ]; do
       
   116     case "$1" in 
       
   117         -h|-help|--help)
       
   118             usage
       
   119             ;;
       
   120         -headerdir)
       
   121             QT_MOBILITY_INCLUDE="$2"
       
   122             shift
       
   123             ;;
       
   124         -libdir)
       
   125             QT_MOBILITY_LIB="$2"
       
   126             shift
       
   127             ;;
       
   128         --prefix|-prefix)
       
   129             QT_MOBILITY_PREFIX="$2"
       
   130             shift
       
   131             ;;
       
   132         -bindir)
       
   133             QT_MOBILITY_BIN="$2"
       
   134             shift
       
   135             ;;
       
   136         -tests)
       
   137             BUILD_UNITTESTS="yes"
       
   138             ;;
       
   139         -examples)
       
   140             BUILD_EXAMPLES="yes"
       
   141             ;;
       
   142         -no-docs)
       
   143             BUILD_DOCS=
       
   144             ;;
       
   145         -debug)
       
   146             RELEASEMODE=debug
       
   147             ;;
       
   148         -release)
       
   149             RELEASEMODE=release
       
   150             ;;
       
   151         -silent)
       
   152             BUILD_SILENT=yes
       
   153             ;;
       
   154         -maemo5)
       
   155             LINUX_TARGET=maemo5
       
   156             ;;
       
   157         -maemo6)
       
   158             LINUX_TARGET=maemo6
       
   159             ;;
       
   160         -sdk)
       
   161             MAC_SDK="$2"
       
   162             shift
       
   163             ;;
       
   164         -modules)
       
   165             MOBILITY_MODULES_UNPARSED=$2
       
   166             #reset default selection
       
   167             MOBILITY_MODULES=
       
   168             for m in $MOBILITY_MODULES_UNPARSED; do
       
   169                 case "$m" in
       
   170                     bearer|contacts|location|messaging|multimedia|publishsubscribe|serviceframework|systeminfo|versit|sensors)
       
   171                         MOBILITY_MODULES="$MOBILITY_MODULES $m";
       
   172                         ;;
       
   173                     *)
       
   174                         echo "Unknown module: $m"
       
   175                         echo
       
   176                         usage
       
   177                         ;;
       
   178 
       
   179                 esac
       
   180             done
       
   181             if [ -z "$MOBILITY_MODULES" ]; then
       
   182                 echo "List of selected modules is empty."
       
   183                 echo 
       
   184                 usage
       
   185             fi
       
   186             shift
       
   187             ;;
       
   188         *)
       
   189             echo "Unknown option: $1"
       
   190             usage
       
   191             ;;
       
   192     esac
       
   193     shift
       
   194 done
       
   195 
       
   196 findframeworks()
       
   197 {
       
   198 # figure out if Qt was built with frameworks
       
   199 # if so, install in the correct place.
       
   200 # and fix rpath
       
   201     echo "contains(QT_CONFIG,qt_framework):message(1)" > 1.pro
       
   202     SOMETHING=`qmake 1.pro 2>&1`
       
   203         if [ "$SOMETHING" = "Project MESSAGE: 1" ]; then
       
   204             LIB_PATH="Library/Frameworks"
       
   205             BIN_PATH="Applications"
       
   206         fi
       
   207     rm 1.pro
       
   208 }
       
   209 
       
   210 findframeworks
       
   211 
       
   212 if [ -n "$BUILD_SILENT" ]; then
       
   213     echo "CONFIG += silent"  > "$CONFIG_IN"
       
   214 fi
       
   215 
       
   216 if [ -z "$RELEASEMODE" ]; then
       
   217     RELEASEMODE="debug"
       
   218 fi
       
   219 echo "CONFIG += $RELEASEMODE" >> "$CONFIG_IN"
       
   220 
       
   221 #do we build for Maemo?
       
   222 if [ -n "$LINUX_TARGET" ]; then
       
   223     if [ "$LINUX_TARGET" = "maemo5" ]; then
       
   224         echo "CONFIG+=maemo5" >> "$CONFIG_IN"
       
   225     elif [ "$LINUX_TARGET" = "maemo6" ]; then
       
   226         echo "CONFIG+=maemo6" >> "$CONFIG_IN"
       
   227     fi
       
   228 fi
       
   229 
       
   230 #process PREFIX
       
   231 if [ -d "$QT_MOBILITY_PREFIX" ]; then
       
   232     QT_MOBILITY_PREFIX=`(cd "$QT_MOBILITY_PREFIX"; /bin/pwd)`
       
   233 else
       
   234     mkdir -p "$QT_MOBILITY_PREFIX"
       
   235     absPath=`(cd "$QT_MOBILITY_PREFIX"; /bin/pwd)`
       
   236     rm -rf "$QT_MOBILITY_PREFIX"
       
   237     QT_MOBILITY_PREFIX="$absPath"
       
   238 fi
       
   239 echo "QT_MOBILITY_PREFIX = $QT_MOBILITY_PREFIX" >> "$CONFIG_IN"
       
   240 
       
   241 #process include path
       
   242 if [ -z "$QT_MOBILITY_INCLUDE" ]; then
       
   243     QT_MOBILITY_INCLUDE="$QT_MOBILITY_PREFIX/include"
       
   244 elif [ -d "$QT_MOBILITY_INCLUDE" ]; then
       
   245     QT_MOBILITY_INCLUDE=`(cd "$QT_MOBILITY_INCLUDE"; /bin/pwd)`
       
   246 else
       
   247     mkdir -p "$QT_MOBILITY_INCLUDE"
       
   248     absPath=`(cd "$QT_MOBILITY_INCLUDE"; /bin/pwd)`
       
   249     rm -rf "$QT_MOBILITY_INCLUDE"
       
   250     QT_MOBILITY_INCLUDE="$absPath"
       
   251 fi
       
   252 echo "QT_MOBILITY_INCLUDE = $QT_MOBILITY_INCLUDE" >> "$CONFIG_IN"
       
   253 
       
   254 
       
   255 #process library path
       
   256 if [ -z "$QT_MOBILITY_LIB" ]; then
       
   257     QT_MOBILITY_LIB="$QT_MOBILITY_PREFIX/$LIB_PATH"
       
   258 elif [ -d "$QT_MOBILITY_LIB" ]; then
       
   259     QT_MOBILITY_LIB=`(cd "$QT_MOBILITY_LIB"; /bin/pwd)`
       
   260 else
       
   261     mkdir -p "$QT_MOBILITY_LIB"
       
   262     absPath=`(cd "$QT_MOBILITY_LIB"; /bin/pwd)`
       
   263     rm -rf "$QT_MOBILITY_LIB"
       
   264     QT_MOBILITY_LIB="$absPath"
       
   265 fi
       
   266 echo "QT_MOBILITY_LIB = $QT_MOBILITY_LIB" >> "$CONFIG_IN"
       
   267 
       
   268 #process binary path
       
   269 if [ -z "$QT_MOBILITY_BIN" ]; then
       
   270     QT_MOBILITY_BIN="$QT_MOBILITY_PREFIX/$BIN_PATH"
       
   271 elif [ -d "$QT_MOBILITY_BIN" ]; then
       
   272     QT_MOBILITY_BIN=`(cd "$QT_MOBILITY_BIN"; /bin/pwd)`
       
   273 else
       
   274     mkdir -p "$QT_MOBILITY_BIN"
       
   275     absPath=`(cd "$QT_MOBILITY_BIN"; /bin/pwd)`
       
   276     rm -rf "$QT_MOBILITY_BIN"
       
   277     QT_MOBILITY_BIN="$absPath"
       
   278 fi
       
   279 echo "QT_MOBILITY_BIN = $QT_MOBILITY_BIN" >> "$CONFIG_IN"
       
   280 
       
   281 echo "QT_MOBILITY_SOURCE_TREE = $relpath" >> "$QMAKE_CACHE"
       
   282 echo "QT_MOBILITY_BUILD_TREE = $shadowpath" >> "$QMAKE_CACHE"
       
   283 
       
   284 if [ -n "$MAC_SDK" ]; then
       
   285     QMAKE_MAC_SDK="$MAC_SDK"
       
   286    echo "QMAKE_MAC_SDK = $QMAKE_MAC_SDK" >> "$CONFIG_IN"
       
   287 fi
       
   288 
       
   289 if [ -z "$BUILD_UNITTESTS" ]; then
       
   290     echo "build_unit_tests = no" >> "$CONFIG_IN"
       
   291 else
       
   292     echo "build_unit_tests = yes" >> "$CONFIG_IN"
       
   293 fi
       
   294 
       
   295 if [ -z "$BUILD_EXAMPLES" ]; then
       
   296     echo "build_examples = no" >> "$CONFIG_IN"
       
   297 else
       
   298     echo "build_examples = yes" >> "$CONFIG_IN"
       
   299 fi
       
   300 
       
   301 if [ -z "$BUILD_DOCS" ]; then
       
   302     echo "build_docs = no" >> "$CONFIG_IN"
       
   303 else
       
   304     echo "build_docs = yes" >> "$CONFIG_IN"
       
   305 fi
       
   306 
       
   307 echo "Configuring Qt Mobility"
       
   308 echo 
       
   309 
       
   310 WHICH="$relpath/config.tests/tools/which.test"
       
   311 
       
   312 printf "Checking available Qt"
       
   313 if ! "$WHICH" qmake 2>/dev/null 1>&2; then
       
   314     printf " ... Not found\n\n" >&2
       
   315     echo >&2 "Cannot find 'qmake' in your PATH.";
       
   316     echo >&2 "Aborting." 
       
   317 else
       
   318     printf " ... "
       
   319     qmake -query QT_VERSION
       
   320 fi
       
   321 
       
   322 # find out which make we want to use
       
   323 MAKE=
       
   324 for m in make gmake; do
       
   325     if "$WHICH" $m >/dev/null 2>&1; then
       
   326         MAKE=`$WHICH $m`
       
   327         break
       
   328     fi
       
   329 done
       
   330 if [ -z "$MAKE" ]; then
       
   331     echo >&2 "Cannot find 'make' or 'gmake' in your PATH";
       
   332     echo >&2 "Aborting." 
       
   333 fi
       
   334 
       
   335 compileTest()
       
   336 {
       
   337     printf "Checking $1"
       
   338     CURRENT_PWD=`pwd`
       
   339     
       
   340     if [ "$shadowpath" = "$relpath" ]; then 
       
   341         #doing source tree build
       
   342         cd "$relpath/config.tests/$2"
       
   343         rm -rf ./$2
       
   344     else
       
   345         #using shadow build
       
   346         rm -rf config.tests/$2
       
   347         mkdir -p config.tests/$2
       
   348         cd config.tests/$2
       
   349     fi
       
   350 
       
   351     qmake "$relpath/config.tests/$2/$2.pro" >> "$CONFIG_LOG"
       
   352     printf  " ."
       
   353     "$MAKE" clean >> "$CONFIG_LOG"
       
   354     printf "."
       
   355     "$MAKE" >> "$CONFIG_LOG" 2>&1
       
   356     printf ". "
       
   357     if ./$2 >> "$CONFIG_LOG" 2>&1; then
       
   358         echo "OK"
       
   359         echo "$2_enabled = yes" >> "$CONFIG_IN"
       
   360     else
       
   361         echo "Not Found"
       
   362         echo "$2_enabled = no" >> "$CONFIG_IN"
       
   363     fi
       
   364     cd "$CURRENT_PWD"
       
   365 }
       
   366 
       
   367 #compile tests
       
   368 compileTest QMF qmf
       
   369 compileTest NetworkManager networkmanager
       
   370 compileTest "CoreWLAN (MacOS 10.6)" corewlan
       
   371 
       
   372 # Now module selection
       
   373 # using 'expr match ....' should help a bit
       
   374 #if [ -n "$MOBILITY_MODULES_UNPARSED" ]; then
       
   375     # In theory we should do some sanity checking here.
       
   376 #    MOBILITY_MODULES="$MOBILITY_MODULES_UNPARSED"
       
   377 #fi
       
   378 
       
   379 # It's a lot easier to make qmake do the dependency checking...
       
   380 echo "mobility_modules = $MOBILITY_MODULES" >> "$CONFIG_IN"
       
   381 echo "contains(mobility_modules,versit): mobility_modules *= contacts" >> "$CONFIG_IN"
       
   382 
       
   383 # Ideally we'd skip generating headers for modules that are not enabled
       
   384 echo "Generating Mobility Headers..."
       
   385 #remove old headers
       
   386 rm -rf $shadowpath/include
       
   387 mkdir $shadowpath/include
       
   388 for module in $MOBILITY_MODULES; do
       
   389     case "$module" in 
       
   390         bearer)
       
   391             $relpath/bin/syncheaders $shadowpath/include $relpath/src/bearer
       
   392             ;;
       
   393         publishsubscribe)
       
   394             $relpath/bin/syncheaders $shadowpath/include $relpath/src/publishsubscribe
       
   395             ;;
       
   396         location)
       
   397             $relpath/bin/syncheaders $shadowpath/include $relpath/src/location
       
   398             ;;
       
   399         serviceframework)
       
   400             $relpath/bin/syncheaders $shadowpath/include $relpath/src/serviceframework
       
   401             ;;
       
   402         systeminfo)
       
   403             $relpath/bin/syncheaders $shadowpath/include $relpath/src/systeminfo
       
   404             ;;
       
   405         contacts)
       
   406             $relpath/bin/syncheaders $shadowpath/include $relpath/src/contacts
       
   407             $relpath/bin/syncheaders $shadowpath/include $relpath/src/contacts/details
       
   408             $relpath/bin/syncheaders $shadowpath/include $relpath/src/contacts/requests
       
   409             $relpath/bin/syncheaders $shadowpath/include $relpath/src/contacts/filters
       
   410             ;;
       
   411         multimedia)
       
   412             $relpath/bin/syncheaders $shadowpath/include $relpath/src/multimedia
       
   413             $relpath/bin/syncheaders $shadowpath/include $relpath/src/multimedia/experimental
       
   414             ;;
       
   415         messaging)
       
   416             $relpath/bin/syncheaders $shadowpath/include $relpath/src/messaging
       
   417             ;;
       
   418         versit)
       
   419             #versit implies contacts
       
   420             $relpath/bin/syncheaders $shadowpath/include $relpath/src/versit
       
   421             $relpath/bin/syncheaders $shadowpath/include $relpath/src/contacts
       
   422             $relpath/bin/syncheaders $shadowpath/include $relpath/src/contacts/details
       
   423             $relpath/bin/syncheaders $shadowpath/include $relpath/src/contacts/requests
       
   424             $relpath/bin/syncheaders $shadowpath/include $relpath/src/contacts/filters
       
   425             ;;
       
   426         sensors)
       
   427             $relpath/bin/syncheaders $shadowpath/include $relpath/src/sensors
       
   428             ;;
       
   429         *)
       
   430             echo "Cannot generate headers for $module"
       
   431             ;;
       
   432     esac
       
   433 done
       
   434 
       
   435 mv "$CONFIG_IN" config.pri
       
   436 mkdir -p "$shadowpath/features"
       
   437 cp -f "$relpath/features/strict_flags.prf" "$shadowpath/features"
       
   438 
       
   439 echo "Running qmake..."
       
   440 if qmake -recursive "$relpath/qtmobility.pro"; then
       
   441     echo ""
       
   442     echo "configure has finished. You may run make or gmake to build the project now."
       
   443 else
       
   444     echo ""
       
   445     echo "configure failed."
       
   446 fi