CMake: Fix the generated location of static libraries.
[profile/ivi/qtbase.git] / configure
index 2923e65..364e4da 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,39 +1,39 @@
 #!/bin/sh
 #############################################################################
 ##
-## Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-## Contact: http://www.qt-project.org/
+## Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+## Contact: http://www.qt-project.org/legal
 ##
 ## This file is the build configuration utility of the Qt Toolkit.
 ##
 ## $QT_BEGIN_LICENSE:LGPL$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Digia.  For licensing terms and
+## conditions see http://qt.digia.com/licensing.  For further information
+## use the contact form at http://qt.digia.com/contact-us.
+##
 ## 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.
+## 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
+## In addition, as a special exception, Digia gives you certain additional
+## rights.  These rights are described in the Digia 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.
-##
-##
-##
-##
+## 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.
 ##
 ##
 ## $QT_END_LICENSE$
@@ -108,6 +108,21 @@ QMakeVar()
     echo "$2" "$eq" "$3" >> "$QMAKE_VARS_FILE"
 }
 
+shellArgumentListToQMakeListHelper()
+{
+    local retval
+    for arg in "$@"; do retval="$retval \"$arg\""; done
+    echo "$retval"
+}
+
+# Convert a string usable on a shell command line into word-by-word quoted
+# qmake list.
+shellArgumentListToQMakeList()
+{
+    # eval is needed for the shell to interpret the backslash escape sequences
+    eval shellArgumentListToQMakeListHelper "$@"
+}
+
 # Helper function for getQMakeConf. It parses include statements in
 # qmake.conf and prints out the expanded file
 getQMakeConf1()
@@ -123,6 +138,14 @@ getQMakeConf1()
             fi
             getQMakeConf1 "$conf_file"
         ;;
+        *load\(device_config\)*)
+            conf_file="$DEVICE_VARS_FILE"
+            if [ ! -f  "$conf_file" ]; then
+                echo "WARNING: Unable to find file $conf_file" >&2
+                continue
+            fi
+            getQMakeConf1 "$conf_file"
+        ;;
         *)
             echo "$line"
         ;;
@@ -225,6 +248,66 @@ linkerSupportsFlag()
     compilerSupportsFlag "$lflags" >/dev/null 2>&1
 }
 
+# $1: newline-separated list of default paths
+# stdin: input path
+# stdout: input path or nothing
+filterDefaultPaths()
+{
+    local path
+    path=`cat`
+    echo "$1" | grep "^$path\$" > /dev/null || echo "$path"
+}
+
+filterIncludePath()
+{
+    filterDefaultPaths "$DEFAULT_INCDIRS"
+}
+
+filterLibraryPath()
+{
+    filterDefaultPaths "$DEFAULT_LIBDIRS"
+}
+
+filterPathOptionsHelper()
+{
+    local flag defpaths sep p path
+    flag=$1; shift
+    defpaths=$1; shift
+    sep=
+    for p in "$@"; do
+        path=${p#$flag}
+        if [ "x$path" != "x$p" ]; then
+            path=`echo "$path" | filterDefaultPaths "$defpaths"`
+            test -z "$path" && continue
+        fi
+        # Re-quote for shell & qmake
+        p=`echo "$p" | sed 's,[^ ]* .*,"&",g'`
+        printf "%s%s" "$sep" "$p"
+        sep=" "
+    done
+    echo
+}
+
+# $1: flag
+# $2: newline-separated list of default paths
+# stdin: list of command line options
+# sdout: stdin without the options naming default paths
+filterPathOptions()
+{
+    # The eval does escape interpretation for us
+    eval filterPathOptionsHelper $1 "\"$2\"" "`cat`"
+}
+
+filterIncludeOptions()
+{
+    filterPathOptions -I "$DEFAULT_INCDIRS"
+}
+
+filterLibraryOptions()
+{
+    filterPathOptions -L "$DEFAULT_LIBDIRS"
+}
+
 #-------------------------------------------------------------------------------
 # device options
 #-------------------------------------------------------------------------------
@@ -242,6 +325,23 @@ DeviceVar()
     echo "$2" "$eq" "$3" >> "$DEVICE_VARS_FILE"
 }
 
+resolveDeviceMkspec()
+{
+    result=$(find "$relpath/mkspecs/devices/" -type d -name "*$1*" | sed "s,^$relpath/mkspecs/,,")
+    match_count=$(echo "$result" | wc -w)
+    if [ "$match_count" -gt 1 ]; then
+        echo >&2 "Error: Multiple matches for device '$1'. Candidates are:"
+        tabbed_result=$(echo "$result" | sed "s,^,    ,")
+        echo >&2 "$tabbed_result"
+        echo "undefined"
+    elif [ "$match_count" -eq 0 ]; then
+        echo >&2 "Error: No device matching '$1'"
+        echo "undefined"
+    else
+        echo "$result"
+    fi
+}
+
 #-------------------------------------------------------------------------------
 # operating system detection
 #-------------------------------------------------------------------------------
@@ -294,13 +394,6 @@ if [ -z "$QT_MAJOR_VERSION" ]; then
    exit 1
 fi
 
-QT_PACKAGEDATE=`grep '^# *define *QT_PACKAGEDATE_STR' "$relpath"/src/corelib/global/qglobal.h | sed -e 's,^# *define *QT_PACKAGEDATE_STR *"\([^ ]*\)"$,\1,' -e s,-,,g`
-if [ -z "$QT_PACKAGEDATE" ]; then
-   echo "Unable to determine package date from qglobal.h: '$QT_PACKAGEDATE'"
-   echo "Cannot proceed"
-   exit 1
-fi
-
 #-------------------------------------------------------------------------------
 # check the license
 #-------------------------------------------------------------------------------
@@ -417,7 +510,7 @@ elif [ $COMMERCIAL_USER = "yes" ]; then
             echo
             echo "You are using an old license file."
             echo
-            echo "Please install the license file supplied by Nokia,"
+            echo "Please install the license file supplied by Digia,"
             echo "or install the Qt Open Source Edition if you intend to"
             echo "develop free software."
             exit 1
@@ -524,9 +617,9 @@ elif [ $COMMERCIAL_USER = "yes" ]; then
             echo
             echo "You are not licensed for the $Platform platform."
             echo
-            echo "Please contact qt-info@nokia.com to upgrade your license to"
-            echo "include the $Platform platform, or install the Qt Open Source Edition"
-            echo "if you intend to develop free software."
+            echo "Please use the contact form at http://qt.digia.com/contact-us"
+            echo "to upgrade your license to include the $Platform platform, or install"
+            echo "the Qt Open Source Edition if you intend to develop free software."
             exit 1
             ;;
     esac
@@ -645,12 +738,14 @@ MIN_DBUS_1_VERSION=0.93
 # initalize internal variables
 CFG_CONFIGURE_EXIT_ON_ERROR=yes
 CFG_PROFILE=no
+CFG_STRIP=yes
 CFG_GUI=auto # (yes|no|auto)
 CFG_WIDGETS=yes
 CFG_QCONFIG=full
 CFG_DEBUG=auto
 CFG_MYSQL_CONFIG=
 CFG_DEBUG_RELEASE=no
+CFG_FORCEDEBUGINFO=no
 CFG_SHARED=yes
 CFG_SM=auto
 CFG_XSHAPE=auto
@@ -679,7 +774,7 @@ CFG_SSE=auto
 CFG_FONTCONFIG=auto
 CFG_LIBFREETYPE=auto
 CFG_SQL_AVAILABLE=
-QT_DEFAULT_BUILD_PARTS="libs examples"
+QT_DEFAULT_BUILD_PARTS="libs tools examples"
 CFG_BUILD_PARTS=""
 CFG_NOBUILD_PARTS=""
 CFG_RELEASE_QMAKE=no
@@ -691,8 +786,10 @@ CFG_PKGCONFIG=auto
 
 # Target architecture
 CFG_ARCH=
+CFG_CPUFEATURES=
 # Host architecture, same as CFG_ARCH when not cross-compiling
 CFG_HOST_ARCH=
+CFG_HOST_CPUFEATURES=
 # Set when the -arch or -host-arch arguments are used
 OPT_OBSOLETE_HOST_ARG=no
 
@@ -705,6 +802,8 @@ CFG_XCB=auto
 CFG_XCB_LIMITED=yes
 CFG_EGLFS=auto
 CFG_DIRECTFB=auto
+CFG_LINUXFB=auto
+CFG_KMS=auto
 CFG_LIBUDEV=auto
 CFG_OBSOLETE_WAYLAND=no
 CFG_EVDEV=auto
@@ -732,8 +831,8 @@ CFG_REDUCE_RELOCATIONS=auto
 CFG_ACCESSIBILITY=auto
 CFG_IWMMXT=no
 CFG_NEON=auto
-CFG_MIPS_DSP=yes
-CFG_MIPS_DSPR2=yes
+CFG_MIPS_DSP=auto
+CFG_MIPS_DSPR2=auto
 CFG_CLOCK_GETTIME=auto
 CFG_CLOCK_MONOTONIC=auto
 CFG_MREMAP=auto
@@ -743,21 +842,20 @@ CFG_GETIFADDRS=auto
 CFG_INOTIFY=auto
 CFG_RPATH=yes
 CFG_FRAMEWORK=auto
-MAC_CONFIG_TEST_COMMANDLINE=  # used to make the configure tests run with the correct arch's and SDK settings
 CFG_MAC_HARFBUZZ=no
-CFG_SXE=no
 CFG_PREFIX_INSTALL=yes
 CFG_SDK=
+DEFINES=
 D_FLAGS=
 I_FLAGS=
 L_FLAGS=
 RPATH_FLAGS=
-l_FLAGS=
 W_FLAGS=
 QCONFIG_FLAGS=
 XPLATFORM=              # This seems to be the QMAKESPEC, like "linux-g++"
 XPLATFORM_MINGW=no      # Whether target platform is MinGW (win32-g++*)
 XPLATFORM_MAEMO=no
+XPLATFORM_QNX=no
 PLATFORM=$QMAKESPEC
 QT_CROSS_COMPILE=no
 OPT_CONFIRM_LICENSE=no
@@ -769,11 +867,12 @@ CFG_SILENT=no
 CFG_ALSA=auto
 CFG_PULSEAUDIO=auto
 CFG_COREWLAN=auto
-CFG_NOPROCESS=no
+CFG_PROCESS=yes
 CFG_ICU=auto
 CFG_FORCE_ASSERTS=no
 CFG_PCRE=auto
 QPA_PLATFORM_GUARD=yes
+CFG_CXX11=auto
 
 # initalize variables used for installation
 QT_INSTALL_PREFIX=
@@ -789,6 +888,7 @@ QT_INSTALL_SETTINGS=
 QT_INSTALL_EXAMPLES=
 QT_INSTALL_TESTS=
 CFG_SYSROOT=
+CFG_GCC_SYSROOT="yes"
 QT_HOST_PREFIX=
 QT_HOST_BINS=
 QT_HOST_DATA=
@@ -889,19 +989,8 @@ while [ "$#" -gt 0 ]; do
         VAR=`echo $1 | sed "s,^-no-\(.*\),\1,"`
         VAL=no
         ;;
-    #Qt style yes options
-    -profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-xinput2|-egl|-reduce-exports|-pch|-separate-debug-info|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-xcb|-eglfs|-directfb|-nis|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-debug-and-release|-harfbuzz|-prefix-install|-silent|-optimized-qmake|-reduce-relocations|-sse|-openssl|-openssl-linked|-phonon-backend|-audio-backend|-qml-debug|-javascript-jit|-rpath|-pkg-config|-force-pkg-config|-icu|-force-asserts|-testcocoon)
-        VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
-        VAL=yes
-        ;;
     #Qt style options that pass an argument
-    -qconfig)
-        CFG_QCONFIG="$VAL"
-        VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
-        shift
-        VAL=$1
-        ;;
-    -prefix|-docdir|-headerdir|-plugindir|-importdir|-datadir|-libdir|-bindir|-translationdir|-sysconfdir|-examplesdir|-testsdir|-depths|-make|-nomake|-platform|-xplatform|-device|-device-option|-sdk|-arch|-host-arch|-mysql_config|-sysroot|-hostdatadir|-hostbindir|-qpa)
+    -prefix|-docdir|-headerdir|-plugindir|-importdir|-datadir|-libdir|-bindir|-translationdir|-sysconfdir|-examplesdir|-testsdir|-depths|-make|-nomake|-platform|-xplatform|-device|-device-option|-sdk|-arch|-host-arch|-mysql_config|-sysroot|-hostdatadir|-hostbindir|-qpa|-qconfig)
         VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
         shift
         VAL="$1"
@@ -1007,9 +1096,14 @@ while [ "$#" -gt 0 ]; do
             VAL=`echo $1 | sed 's,-R,,'`
         fi
         ;;
-    -l?*)
+    -l?*|-l)
         VAR="add_link"
-        VAL=`echo $1 | sed 's,-l,,'`
+        if [ "$1" = "-l" ]; then
+            shift
+            VAL="$1"
+        else
+            VAL=`echo $1 | sed 's,-l,,'`
+        fi
         ;;
     -F?*|-F)
         VAR="add_fpath"
@@ -1033,9 +1127,10 @@ while [ "$#" -gt 0 ]; do
         VAR="add_warn"
         VAL="$1"
         ;;
+    #General options, including Qt style yes options
     -*)
         VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
-        VAL="unknown"
+        VAL="yes"
         ;;
     *)
         UNKNOWN_ARG=yes
@@ -1132,12 +1227,12 @@ while [ "$#" -gt 0 ]; do
     sysroot)
         CFG_SYSROOT="$VAL"
         ;;
+    gcc-sysroot)
+        CFG_GCC_SYSROOT="$VAL"
+        ;;
     bindir)
         QT_INSTALL_BINS="$VAL"
         ;;
-    sxe)
-       CFG_SXE="$VAL"
-        ;;
     sse)
         if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
             CFG_SSE="$VAL"
@@ -1203,6 +1298,13 @@ while [ "$#" -gt 0 ]; do
             UNKNOWN_OPT=yes
         fi
         ;;
+    strip)
+        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
+            CFG_STRIP=$VAL
+        else
+            UNKNOWN_OPT=yes
+        fi
+        ;;
     testcocoon)
         if [ "$VAL" = "yes" ]; then
             QTCONFIG_CONFIG="$QTCONFIG_CONFIG testcocoon"
@@ -1267,10 +1369,16 @@ while [ "$#" -gt 0 ]; do
         ;;
     xplatform)
         XPLATFORM="$VAL"
-        case `basename "$XPLATFORM"` in win32-g++*) XPLATFORM_MINGW=yes;; esac
+        case `basename "$XPLATFORM"` in win32-g++*)
+            XPLATFORM_MINGW=yes
+            CFG_RPATH=no
+            CFG_REDUCE_EXPORTS=no
+            ;;
+        esac
         ;;
     device)
-        XPLATFORM="devices/$VAL"
+        XPLATFORM=`resolveDeviceMkspec $VAL`
+        [ "$XPLATFORM" = "undefined" ] && exit 101
         ;;
     device-option)
         DEV_VAR=`echo $VAL | sed "s,^\(.*\)=.*,\1,"`
@@ -1313,6 +1421,9 @@ while [ "$#" -gt 0 ]; do
     debug)
         CFG_DEBUG="$VAL"
         ;;
+    force-debug-info)
+        CFG_FORCEDEBUGINFO="$VAL"
+        ;;
     developer-build|commercial|opensource)
         # These switches have been dealt with already
         ;;
@@ -1623,6 +1734,20 @@ while [ "$#" -gt 0 ]; do
             UNKNOWN_OPT=yes
         fi
         ;;
+    linuxfb)
+        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
+            CFG_LINUXFB="$VAL"
+        else
+            UNKNOWN_OPT=yes
+        fi
+        ;;
+    kms)
+        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
+            CFG_KMS="$VAL"
+        else
+            UNKNOWN_OPT=yes
+        fi
+        ;;
     libudev)
         if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
             CFG_LIBUDEV="$VAL"
@@ -1875,7 +2000,8 @@ while [ "$#" -gt 0 ]; do
         fi
         ;;
     add_define)
-        D_FLAGS="$D_FLAGS \"$VAL\""
+        DEFINES="$DEFINES \"$VAL\""
+        D_FLAGS="$D_FLAGS -D\"$VAL\""
         ;;
     add_ipath)
         I_FLAGS="$I_FLAGS -I\"${VAL}\""
@@ -1887,7 +2013,7 @@ while [ "$#" -gt 0 ]; do
         RPATH_FLAGS="$RPATH_FLAGS \"${VAL}\""
         ;;
     add_link)
-        l_FLAGS="$l_FLAGS -l\"${VAL}\""
+        L_FLAGS="$L_FLAGS -l\"${VAL}\""
         ;;
     add_fpath)
         if [ "$BUILD_ON_MAC" = "yes" ]; then
@@ -1899,7 +2025,7 @@ while [ "$#" -gt 0 ]; do
         ;;
     add_framework)
         if [ "$BUILD_ON_MAC" = "yes" ]; then
-            l_FLAGS="$l_FLAGS -framework \"${VAL}\""
+            L_FLAGS="$L_FLAGS -framework \"${VAL}\""
         else
             UNKNOWN_OPT=yes
         fi
@@ -1910,18 +2036,14 @@ while [ "$#" -gt 0 ]; do
     silent)
         CFG_SILENT="$VAL"
         ;;
-    phonon-backend)
-        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
-            CFG_PHONON_BACKEND="$VAL"
-        else
-            UNKNOWN_OPT=yes
-        fi
-        ;;
     dont-process)
-        CFG_NOPROCESS=yes
+        CFG_PROCESS=no
         ;;
     process)
-        CFG_NOPROCESS=no
+        CFG_PROCESS=partial
+        ;;
+    fully-process)
+        CFG_PROCESS=full
         ;;
     audio-backend)
         if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
@@ -1951,6 +2073,13 @@ while [ "$#" -gt 0 ]; do
             UNKNOWN_OPT=yes
         fi
         ;;
+    c++11)
+        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
+            CFG_CXX11="$VAL"
+        else
+            UNKNOWN_OPT=yes
+        fi
+        ;;
     *)
         UNKNOWN_OPT=yes
         ;;
@@ -2080,6 +2209,9 @@ if [ "$OPT_SHADOW" = "yes" ]; then
     # save a pre-existing mkspecs/modules dir
     test -d "$outpath/mkspecs/modules" && \
         mv "$outpath/mkspecs/modules" "$outpath/mkspecs-modules"
+    # ditto for mkspecs/modules-inst
+    test -d "$outpath/mkspecs/modules-inst" && \
+        mv "$outpath/mkspecs/modules-inst" "$outpath/mkspecs-modules-inst"
 
     # symlink the mkspecs directory
     mkdir -p "$outpath/mkspecs"
@@ -2107,6 +2239,12 @@ if [ "$OPT_SHADOW" = "yes" ]; then
         ShadowMkspecs modules
     fi
 
+    # The modules-inst dir is not quite as special, but still.
+    if test -d "$outpath/mkspecs-modules-inst"; then
+        rm -rf "$outpath/mkspecs/modules-inst"
+        mv "$outpath/mkspecs-modules-inst" "$outpath/mkspecs/modules-inst"
+    fi
+
     # symlink the doc directory
     rm -rf "$outpath/doc"
     ln -s "$relpath/doc" "$outpath/doc"
@@ -2311,10 +2449,6 @@ if [ -z "$PLATFORM" ]; then
         ;;
      *)
         if [ "$OPT_HELP" != "yes" ]; then
-            echo
-            for p in $PLATFORMS; do
-                echo "    $relconf $* -platform $p"
-            done
             echo >&2
             echo "   The build script does not currently recognize all" >&2
             echo "   platforms supported by Qt." >&2
@@ -2326,13 +2460,11 @@ if [ -z "$PLATFORM" ]; then
     esac
 fi
 
-PLATFORMS=`find "$relpath/mkspecs/" -type f | grep -v qws | sed "s,$relpath/mkspecs/qws/,,"`
-
 [ -z "$XPLATFORM" ] && XPLATFORM="$PLATFORM"
 
 case `basename "$XPLATFORM"` in win32-g++*) XPLATFORM_MINGW=yes;; esac
-case "$XPLATFORM" in linux-g++-maemo) XPLATFORM_MAEMO=yes;; esac
-case "$XPLATFORM" in qnx-*) XPLATFORM_QNX=yes;; esac
+case "$XPLATFORM" in *-maemo*) XPLATFORM_MAEMO=yes;; esac
+case "$XPLATFORM" in *qnx-*|*blackberry-*) XPLATFORM_QNX=yes;; esac
 
 if [ -d "$PLATFORM" ]; then
   QMAKESPEC="$PLATFORM"
@@ -2389,7 +2521,7 @@ if [ '!' -f "${XQMAKESPEC}/qplatformdefs.h" ]; then
     echo
     echo "      $XQMAKESPEC/qplatformdefs.h"
     echo
-    echo "   Please contact qt-info@nokia.com."
+    echo "   Please use the contact form at http://qt.digia.com/contact-us"
     echo
     exit 2
 fi
@@ -2408,9 +2540,9 @@ if [ "$CFG_RTOS_ENABLED" = "no" ]; then
             echo ""
             echo "You are not licensed for Qt for `basename $XPLATFORM`."
             echo ""
-            echo "Please contact qt-info@nokia.com to upgrade your license to"
-            echo "include this platform, or install the Qt Open Source Edition"
-            echo "if you intend to develop free software."
+            echo "Please use the contact form at http://qt.digia.com/contact-us"
+            echo "to upgrade your license to include this platform, or install"
+            echo "the Qt Open Source Edition if you intend to develop free software."
             exit 1
            ;;
     esac
@@ -2434,12 +2566,18 @@ if [ "$CFG_DEBUG" = "auto" ]; then
     fi
 fi
 if [ "$CFG_DEBUG_RELEASE" = "yes" ]; then
-    QT_CONFIG="$QT_CONFIG build_all"
+    QT_CONFIG="$QT_CONFIG build_all debug_and_release"
 fi
 
-# pass on $CFG_SDK to the configure tests.
-if [ '!' -z "$CFG_SDK" ]; then
-    MAC_CONFIG_TEST_COMMANDLINE="$MAC_CONFIG_TEST_COMMANDLINE -sdk $CFG_SDK"
+if [ "$CFG_FORCEDEBUGINFO" = "yes" ]; then
+    QT_CONFIG="$QT_CONFIG force_debug_info"
+fi
+
+# pass on $CFG_SDK to the arch/configure tests.
+if [ -n "$CFG_SDK" ]; then
+    MAC_SDK_FLAG="-sdk $CFG_SDK"
+else
+    MAC_SDK_FLAG=
 fi
 
 # find the default framework value
@@ -2465,13 +2603,20 @@ if [ "$XPLATFORM_SYMBIAN_SBSV2" = "no" ]; then
         exit 1
     fi
 fi
+TEST_COMPILER_CXXFLAGS=`getXQMakeConf QMAKE_CXXFLAGS`
+
+GCC_MACHINE_DUMP=
+case "$TEST_COMPILER" in *g++) GCC_MACHINE_DUMP=$($TEST_COMPILER -dumpmachine);; esac
+if [ -n "$GCC_MACHINE_DUMP" ]; then
+    DeviceVar set GCC_MACHINE_DUMP $($TEST_COMPILER -dumpmachine)
+fi
 
-if [ -n "$CFG_SYSROOT" ]; then
+if [ -n "$CFG_SYSROOT" ] && [ "$CFG_GCC_SYSROOT" = "yes" ]; then
     SYSROOT_FLAG="--sysroot=$CFG_SYSROOT"
 else
     SYSROOT_FLAG=
 fi
-export SYSROOT_FLAG    # used by config.tests/unix/compile.test
+export SYSROOT_FLAG    # used by config.tests/unix/{compile.test,arch.test}
 
 # auto-detect precompiled header support
 if [ "$CFG_PRECOMPILE" = "auto" ]; then
@@ -2484,11 +2629,8 @@ fi
 
 # auto-detect support for separate debug info in objcopy
 if [ "$CFG_SEPARATE_DEBUG_INFO" != "no" ] && [ "$CFG_SHARED" = "yes" ]; then
-    TEST_COMPILER_CFLAGS=`getXQMakeConf QMAKE_CFLAGS`
-    TEST_COMPILER_CXXFLAGS=`getXQMakeConf QMAKE_CXXFLAGS`
     TEST_OBJCOPY=`getXQMakeConf QMAKE_OBJCOPY`
     COMPILER_WITH_FLAGS="$TEST_COMPILER $TEST_COMPILER_CXXFLAGS"
-    COMPILER_WITH_FLAGS=`echo "$COMPILER_WITH_FLAGS" | sed -e "s%\\$\\$QMAKE_CFLAGS%$TEST_COMPILER_CFLAGS%g"`
     if "$unixtests/objcopy.test" "$COMPILER_WITH_FLAGS" "$TEST_OBJCOPY" "$OPT_VERBOSE"; then
        CFG_SEPARATE_DEBUG_INFO=no
     else
@@ -2551,6 +2693,20 @@ else
     CFG_FRAMEWORK=no
 fi
 
+# auto-detect default include and library search paths
+gccout=`$TEST_COMPILER $SYSROOT_FLAG $TEST_COMPILER_CXXFLAGS -xc++ -E -v - < /dev/null 2>&1 > /dev/null`
+libdirs=`echo "$gccout" | sed -n -e 's/^LIBRARY_PATH=\(.*\)/\1/p'`
+DEFAULT_LIBDIRS=`IFS=:; for i in $libdirs; do test -d "$i" && cd "$i" && pwd; done | sort -u`
+DEFAULT_INCDIRS=`echo "$gccout" | awk '
+/^End of search/ { yup=0 }
+yup { print substr($0, 2) }
+/^\#include </ { yup=1 }
+' | sort -u`
+test -z "$DEFAULT_LIBDIRS" && DEFAULT_LIBDIRS="/lib
+/usr/lib"
+test -z "$DEFAULT_INCDIRS" && DEFAULT_INCDIRS="/usr/include
+/usr/local/include"
+
 #setup the build parts
 if [ -z "$CFG_BUILD_PARTS" ]; then
     CFG_BUILD_PARTS="$QT_DEFAULT_BUILD_PARTS"
@@ -2616,7 +2772,7 @@ if [ -z "$QT_INSTALL_LIBS" ]; then #default
     if [ "$CFG_PREFIX_INSTALL" = "no" ]; then
         if [ "$BUILD_ON_MAC" = "yes" ]; then
             if [ "$CFG_FRAMEWORK" = "yes" ]; then
-                QT_INSTALL_LIBS="/Libraries/Frameworks"
+                QT_INSTALL_LIBS="/Library/Frameworks"
             fi
         fi
     fi
@@ -2794,6 +2950,23 @@ if [ "$OPT_HELP" = "yes" ]; then
         DFBY="*"
         DFBN=" "
     fi
+
+    if [ "$CFG_LINUXFB" = "no" ]; then
+        LFBY=" "
+        LFBN="*"
+    else
+        LFBY="*"
+        LFBN=" "
+    fi
+
+    if [ "$CFG_KMS" = "no" ]; then
+        KMSY=" "
+        KMSN="*"
+    else
+        KMSY="*"
+        KMSN=" "
+    fi
+
     if [ "$CFG_XINPUT2" = "no" ]; then
         X2Y=" "
         X2N="*"
@@ -2827,32 +3000,7 @@ if [ "$OPT_HELP" = "yes" ]; then
     fi
 
     cat <<EOF
-Usage:  $relconf [-h] [-prefix <dir>] [-prefix-install] [-bindir <dir>] [-libdir <dir>]
-        [-docdir <dir>] [-headerdir <dir>] [-plugindir <dir> ] [-importdir <dir>] [-datadir <dir>]
-        [-translationdir <dir>] [-sysconfdir <dir>] [-examplesdir <dir>] [-testsdir <dir>]
-        [-release] [-debug] [-debug-and-release]
-        [-developer-build] [-shared] [-static] [-no-fast] [-fast] [-no-largefile]
-        [-largefile] [-no-accessibility] [-accessibility] [-no-sql-<driver>] [-sql-<driver>]
-        [-plugin-sql-<driver>] [-system-sqlite]
-        [-platform] [-D <string>] [-I <string>] [-L <string>] [-help]
-        [-qt-zlib] [-system-zlib] [-no-gif] [-no-libpng] [-qt-libpng] [-system-libpng]
-        [-no-libjpeg] [-qt-libjpeg] [-system-libjpeg] [-make <part>]
-        [-nomake <part>] [-R <string>]  [-l <string>] [-no-rpath]  [-rpath] [-continue]
-        [-verbose] [-v] [-silent] [-no-nis] [-nis] [-no-cups] [-cups] [-no-iconv]
-        [-iconv] [-no-pch] [-pch] [-no-dbus] [-dbus] [-dbus-linked] [-no-gui]
-        [-no-separate-debug-info] [-no-sse2]
-        [-no-sse3] [-no-ssse3] [-no-sse4.1] [-no-sse4.2] [-no-avx] [-no-neon]
-        [-qtnamespace <namespace>] [-qtlibinfix <infix>] [-separate-debug-info]
-        [-no-phonon-backend] [-phonon-backend] [-no-media-backend] [-media-backend]
-        [-no-audio-backend] [-audio-backend]
-        [-no-javascript-jit] [-javascript-jit] [-no-qml-debug] [-qml-debug]
-        [-no-optimized-qmake] [-optimized-qmake]
-        [-no-openssl] [-openssl] [-openssl-linked]
-        [-no-gtkstyle] [-gtkstyle]
-        [-qt-pcre] [-system-pcre]
-        [-device <name>] [-device-option <key=value>]
-        [additional platform specific options (see below)]
-
+Usage:  $relconf [options]
 
 Installation options:
 
@@ -2870,9 +3018,8 @@ Installation options:
                          Qt. This will install into
                          $QT_INSTALL_PREFIX, if this option is
                          disabled then some platforms will attempt a
-                         "system" install by placing default values to
-                         be placed in a system location other than
-                         PREFIX.
+                         "system" install by placing default values
+                         in a system location other than PREFIX.
 
  You may use these to separate different parts of the install:
 
@@ -2915,15 +3062,23 @@ Configure options:
     -debug-and-release . Compile and link two versions of Qt, with and without
                          debugging turned on (Mac only).
 
+    -force-debug-info .. Create symbol files for release builds.
+
     -developer-build ... Compile and link Qt with Qt developer options (including auto-tests exporting)
 
     -opensource ........ Compile and link the Open-Source Edition of Qt.
     -commercial ........ Compile and link the Commercial Edition of Qt.
 
+    -no-c++11 .......... Do not compile Qt with C++11 support enabled.
+ +  -c++11 ............. Compile Qt with C++11 support enabled.
 
  *  -shared ............ Create and use shared Qt libraries.
     -static ............ Create and use static Qt libraries.
 
+ *  -process ........... Generate only a top-level Makefile.
+    -fully-process ..... Generate Makefiles for the entire Qt tree.
+    -dont-process ...... Do not generate any Makefiles.
+
  *  -no-fast ........... Configure Qt normally by generating Makefiles for all
                          project files.
     -fast .............. Configure Qt quickly by generating Makefiles only for
@@ -2934,7 +3089,7 @@ Configure options:
  +  -largefile ......... Enables Qt to access files larger than 4 GB.
 
     -no-accessibility .. Do not compile Accessibility support.
*  -accessibility ..... Compile Accessibility support.
+  -accessibility ..... Compile Accessibility support.
 
     -no-sql-<driver> ... Disable SQL <driver> entirely.
     -qt-sql-<driver> ... Enable a SQL <driver> in the QtSql library, by default
@@ -2947,9 +3102,6 @@ Configure options:
 
     -system-sqlite ..... Use sqlite from the operating system.
 
-    -no-phonon-backend.. Do not build the platform phonon plugin.
- +  -phonon-backend..... Build the platform phonon plugin.
-
     -no-javascript-jit . Do not build the JavaScriptCore JIT compiler.
  +  -javascript-jit .... Build the JavaScriptCore JIT compiler.
 
@@ -3055,6 +3207,12 @@ Additional options:
  $CIN  -no-iconv .......... Do not compile support for iconv(3).
  $CIY  -iconv ............. Compile support for iconv(3).
 
+    -no-icu ............ Do not compile support for ICU libraries.
+ +  -icu ............... Compile support for ICU libraries.
+
+    -no-strip .......... Do not strip binaries and libraries of unneeded symbols.
+ *  -strip ............. Strip binaries and libraries of unneeded symbols when installing.
+
  $PHN  -no-pch ............ Do not use precompiled header support.
  $PHY  -pch ............... Use precompiled header support.
 
@@ -3084,11 +3242,18 @@ Additional options:
  $DFBN  -no-directfb ....... Do not compile DirectFB support.
  $DFBY  -directfb .......... Compile DirectFB support.
 
+ $LFBN  -no-linuxfb ........ Do not compile Linux Framebuffer support.
+ $LFBY  -linuxfb ........... Compile Linux Framebuffer support.
+
+ $KMSN  -no-kms ............ Do not compile KMS support.
+ $KMSY  -kms ............... Compile KMS support (Requires EGL and OpenGL ES 2 support).
+
     -qpa <name> ......... Sets the default QPA platform (e.g xcb, cocoa, windows).
 
     -xplatform target ... The target platform when cross-compiling.
 
-    -sysroot <dir> ...... Sets <dir> as the target compiler's and qmake's sysroot.
+    -sysroot <dir> ...... Sets <dir> as the target compiler's and qmake's sysroot and also sets pkg-config paths.
+    -no-gcc-sysroot ..... When using -sysroot, it disables the passing of --sysroot to the compiler
 
     -no-feature-<feature> Do not compile in <feature>.
     -feature-<feature> .. Compile in <feature>. The available features
@@ -3233,38 +3398,23 @@ elif [ "$Edition" != "OpenSource" ]; then
         if [ "$Today" -gt "$ExpiryDate" ]; then
             case "$LicenseType" in
             Commercial|Academic|Educational)
-                if [ "$QT_PACKAGEDATE" -gt "$ExpiryDate" ]; then
-                    echo
-                    echo "NOTICE  NOTICE  NOTICE  NOTICE"
-                    echo
-                    echo "  Your support and upgrade period has expired."
-                    echo
-                    echo "  You are no longer licensed to use this version of Qt."
-                    echo "  Please contact qt-info@nokia.com to renew your support"
-                    echo "  and upgrades for this license."
-                    echo
-                    echo "NOTICE  NOTICE  NOTICE  NOTICE"
-                    echo
-                    exit 1
-                else
-                    echo
-                    echo "WARNING  WARNING  WARNING  WARNING"
-                    echo
-                    echo "  Your support and upgrade period has expired."
-                    echo
-                    echo "  You may continue to use your last licensed release"
-                    echo "  of Qt under the terms of your existing license"
-                    echo "  agreement. But you are not entitled to technical"
-                    echo "  support, nor are you entitled to use any more recent"
-                    echo "  Qt releases."
-                    echo
-                    echo "  Please contact qt-info@nokia.com to renew your"
-                    echo "  support and upgrades for this license."
-                    echo
-                    echo "WARNING  WARNING  WARNING  WARNING"
-                    echo
-                    sleep 3
-                fi
+                echo
+                echo "WARNING  WARNING  WARNING  WARNING"
+                echo
+                echo "  Your support and upgrade period has expired."
+                echo
+                echo "  You may continue to use your last licensed release"
+                echo "  of Qt under the terms of your existing license"
+                echo "  agreement. But you are not entitled to technical"
+                echo "  support, nor are you entitled to use any more recent"
+                echo "  Qt releases."
+                echo
+                echo "  Please use the contact form at http://qt.digia.com/contact-us"
+                echo "  to renew your support and upgrades for this license."
+                echo
+                echo "WARNING  WARNING  WARNING  WARNING"
+                echo
+                sleep 3
                 ;;
             Evaluation|*)
                 echo
@@ -3273,9 +3423,9 @@ elif [ "$Edition" != "OpenSource" ]; then
                 echo "  Your Evaluation license has expired."
                 echo
                 echo "  You are no longer licensed to use this software. Please"
-                echo "  contact qt-info@nokia.com to purchase license, or install"
-                echo "  the Qt Open Source Edition if you intend to develop free"
-                echo "  software."
+                echo "  use the contact form at http://qt.digia.com/contact-us to"
+                echo "  purchase license, or install the Qt Open Source Edition"
+                echo "  if you intend to develop free software."
                 echo
                 echo "NOTICE  NOTICE  NOTICE  NOTICE"
                 echo
@@ -3382,7 +3532,7 @@ fi
 # -----------------------------------------------------------------------------
 if [ "$LicenseType" = "Evaluation" ]; then
     EVALKEY=qt_qevalkey=$LicenseKeyExt
-elif echo "$D_FLAGS" | grep QT_EVAL >/dev/null 2>&1; then
+elif echo "$DEFINES" | grep QT_EVAL >/dev/null 2>&1; then
     EVALKEY=qt_qevalkey=
 fi
 
@@ -3402,13 +3552,7 @@ 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 "$relpath" || exit 1
-    elif [ "$CFG_DEV" = "yes" ] || [ ! -d $relpath/include ] || [ -d $relpath/.git ]; then
-        QTDIR="$relpath" perl "$outpath/bin/syncqt" $SYNCQT_OPTS || exit 1
-    fi
+    "$outpath/bin/syncqt" -minimal -module QtCore "$relpath" || exit 1
 fi
 
 # $1: input variable name (awk regexp)
@@ -3425,28 +3569,10 @@ setBootstrapVariable()
 if true; then ###[ '!' -f "$outpath/bin/qmake" ];
     echo "Creating qmake. Please wait..."
 
-    OLD_QCONFIG_H=
-    QCONFIG_H="$outpath/src/corelib/global/qconfig.h"
-    QMAKE_QCONFIG_H="${QCONFIG_H}.qmake"
-    if [ -f "$QCONFIG_H" ]; then
-         OLD_QCONFIG_H=$QCONFIG_H
-         mv -f "$OLD_QCONFIG_H" "${OLD_QCONFIG_H}.old"
-    fi
-
-    # create temporary qconfig.h for compiling qmake, if it doesn't exist
-    # when building qmake, we use #defines for the install paths,
-    # however they are real functions in the library
-    if [ '!' -f "$QMAKE_QCONFIG_H" ]; then
-        mkdir -p "$outpath/src/corelib/global"
-        [ -f "$QCONFIG_H" ] && chmod +w "$QCONFIG_H"
-        echo "/* All features enabled while building qmake */" >"$QMAKE_QCONFIG_H"
-    fi
-
-    mv -f "$QMAKE_QCONFIG_H" "$QCONFIG_H"
-
     #mkspecs/default is used as a (gasp!) default mkspec so QMAKESPEC needn't be set once configured
-    rm -rf mkspecs/default
+    rm -rf mkspecs/default mkspecs/default-host
     ln -s `echo $XQMAKESPEC | sed "s,^${relpath}/mkspecs/,,"` mkspecs/default
+    ln -s `echo $QMAKESPEC | sed "s,^${relpath}/mkspecs/,,"` mkspecs/default-host
     mkdir -p "$outpath/qmake" || exit
     # fix makefiles
     for mkfile in GNUmakefile Makefile; do
@@ -3527,9 +3653,7 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
             fi
         fi
         if [ '!' -z "$D_FLAGS" ]; then
-            for DEF in $D_FLAGS; do
-                EXTRA_CFLAGS="$EXTRA_CFLAGS \"-D${DEF}\""
-            done
+            EXTRA_CFLAGS="$EXTRA_CFLAGS $D_FLAGS"
         fi
         QMAKE_BIN_DIR="$QT_INSTALL_BINS"
         [ -z "$QMAKE_BIN_DIR" ] && QMAKE_BIN_DIR="${QT_INSTALL_PREFIX}/bin"
@@ -3555,19 +3679,36 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
         fi
     done
 
-    QMAKE_BUILD_ERROR=no
-    (cd "$outpath/qmake"; "$MAKE") || QMAKE_BUILD_ERROR=yes
-    [ '!' -z "$QCONFIG_H" ] && mv -f "$QCONFIG_H" "$QMAKE_QCONFIG_H" #move qmake's qconfig.h to qconfig.h.qmake
-    [ '!' -z "$OLD_QCONFIG_H" ] && mv -f "${OLD_QCONFIG_H}.old" "$OLD_QCONFIG_H" #put back qconfig.h
-    [ "$QMAKE_BUILD_ERROR" = "yes" ] && exit 2
+    (cd "$outpath/qmake"; "$MAKE") || exit 2
 fi # Build qmake
 
 #-------------------------------------------------------------------------------
+# create a qt.conf for the Qt build tree itself
+#-------------------------------------------------------------------------------
+
+QTCONFFILE="$outpath/bin/qt.conf"
+cat > "$QTCONFFILE" <<EOF
+[EffectivePaths]
+Prefix=..
+EOF
+
+#-------------------------------------------------------------------------------
+# write out device config before we run the test.
+#-------------------------------------------------------------------------------
+DEVICE_VARS_OUTFILE="$outpath/mkspecs/qdevice.pri"
+if cmp -s "$DEVICE_VARS_FILE" "$DEVICE_VARS_OUTFILE"; then
+    rm -f "$DEVICE_VARS_FILE"
+else
+    mv -f $DEVICE_VARS_FILE "$DEVICE_VARS_OUTFILE"
+    DEVICE_VARS_FILE="$DEVICE_VARS_OUTFILE"
+fi
+
+#-------------------------------------------------------------------------------
 # Detect pkg-config
 #-------------------------------------------------------------------------------
 if [ -z "$PKG_CONFIG" ]; then
     # See if PKG_CONFIG is set in the mkspec:
-    PKG_CONFIG=`getXQMakeConf PKG_CONFIG`
+    PKG_CONFIG="`"$outpath/bin/qmake" -E -nocache -spec "$XQMAKESPEC" "CONFIG=" /dev/null 2>&1 | sed -n -e 's,^PKG_CONFIG = \(.*\),\1,p'`"
 fi
 if [ -z "$PKG_CONFIG" ]; then
     PKG_CONFIG=`"$WHICH" pkg-config 2>/dev/null`
@@ -3587,6 +3728,9 @@ elif [ -n "$PKG_CONFIG" ]; then
         if [ -z "$PKG_CONFIG_LIBDIR" ]; then
             if [ -n "$CFG_SYSROOT" ] && [ -d "$CFG_SYSROOT/usr/lib/pkgconfig" ]; then
                 PKG_CONFIG_LIBDIR=$CFG_SYSROOT/usr/lib/pkgconfig:$CFG_SYSROOT/usr/share/pkgconfig
+                if [ -n "$GCC_MACHINE_DUMP" ]; then
+                    PKG_CONFIG_LIBDIR=$PKG_CONFIG_LIBDIR:$CFG_SYSROOT/usr/lib/$GCC_MACHINE_DUMP/pkgconfig
+                fi
                 export PKG_CONFIG_LIBDIR
                 echo >&2 "Note: PKG_CONFIG_LIBDIR automatically set to $PKG_CONFIG_LIBDIR"
             elif [ "$CFG_PKGCONFIG" = "yes" ]; then
@@ -3627,34 +3771,53 @@ if [ -z "$PKG_CONFIG" ]; then
 fi
 
 #-------------------------------------------------------------------------------
-# write out device config before we run the test.
-#-------------------------------------------------------------------------------
-if cmp -s "$DEVICE_VARS_FILE" "$outpath/mkspecs/qdevice.pri"; then
-    rm -f "$DEVICE_VARS_FILE"
-else
-    mv -f $DEVICE_VARS_FILE "$outpath/mkspecs/qdevice.pri"
-fi
-
-#-------------------------------------------------------------------------------
 # tests that need qmake
 #-------------------------------------------------------------------------------
 
+# parameters: path, name, extra args
+compileTest()
+{
+    path=config.tests/$1
+    name=$2
+    shift 2
+    "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" "$path" "$name" $I_FLAGS $D_FLAGS $L_FLAGS $MAC_SDK_FLAG "$@"
+}
+
 #-------------------------------------------------------------------------------
 # determine the target and host architectures
 #-------------------------------------------------------------------------------
 
-# Use config.tests/arch/arch.pro to has the compiler tell us what the target architecture is
-CFG_ARCH=`OUTDIR="$outpath" "$outpath/bin/qmake" -spec "$XQMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -n -e 's,^Project MESSAGE:.*Architecture: \([a-zA-Z0-9_]*\).*,\1,p'`
-
+# Use config.tests/arch/arch.pro to have the compiler tell us what the target architecture is
+OUTFILE=$outpath/arch.result
+"$unixtests/arch.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "$OUTFILE" "CFG" $MAC_SDK_FLAG
+if [ $? -eq 0 ]; then
+    eval `cat "$OUTFILE"`
+else
+    echo
+    echo "Could not determine the target architecture!"
+    echo "Turn on verbose messaging (-v) to see the final report."
+fi
+rm -f "$OUTFILE" 2>/dev/null
 [ -z "$CFG_ARCH" ] && CFG_ARCH="unknown"
+
 if [ "$QMAKESPEC" != "$XQMAKESPEC" ]; then
     # Do the same test again, using the host compiler
-    CFG_HOST_ARCH=`OUTDIR="$outpath" "$outpath/bin/qmake" -spec "$QMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -n -e 's,^Project MESSAGE:.*Architecture: \([a-zA-Z0-9_]*\).*,\1,p'`
+    SYSROOT_FLAG= "$unixtests/arch.test" "$QMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "$OUTFILE" "CFG_HOST" $MAC_SDK_FLAG
+    if [ $? -eq 0 ]; then
+        eval `cat "$OUTFILE"`
+    else
+        echo
+        echo "Could not determine the host architecture!"
+        echo "Turn on verbose messaging (-v) to see the final report."
+    fi
+    rm -f "$OUTFILE" 2>/dev/null
     [ -z "$CFG_HOST_ARCH" ] && CFG_HOST_ARCH="unknown"
 else
     # not cross compiling, host == target
     CFG_HOST_ARCH="$CFG_ARCH"
+    CFG_HOST_CPUFEATURES="$CFG_CPUFEATURES"
 fi
+unset OUTFILE
 
 if [ "$OPT_VERBOSE" = "yes" ]; then
     echo "System architecture: '$CFG_ARCH'"
@@ -3665,8 +3828,23 @@ fi
 # functionality tests
 #-------------------------------------------------------------------------------
 
+# Detect C++11 support
+if [ "$CFG_CXX11" != "no" ]; then
+    if compileTest common/c++11 "C++11"; then
+        CFG_CXX11="yes"
+    elif [ "$CFG_CXX11" != "auto" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
+        echo "C++11 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_CXX11="no"
+    fi
+fi
+
 # detect availability of float math.h functions
-if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/floatmath "floatmath" $L_FLAGS $I_FLAGS $l_FLAGS; then
+if compileTest unix/floatmath "floatmath"; then
     CFG_USE_FLOATMATH=yes
 else
     CFG_USE_FLOATMATH=no
@@ -3674,7 +3852,7 @@ fi
 
 # detect sse2 support
 if [ "${CFG_SSE2}" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sse2 "sse2" $L_FLAGS $I_FLAGS $l_FLAGS "-msse2"; then
+    if compileTest common/sse2 "sse2"; then
        CFG_SSE2=yes
     else
        CFG_SSE2=no
@@ -3683,7 +3861,7 @@ fi
 
 # detect sse3 support
 if [ "${CFG_SSE3}" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sse3 "sse3" $L_FLAGS $I_FLAGS $l_FLAGS "-msse3"; then
+    if compileTest common/sse3 "sse3"; then
        CFG_SSE3=yes
     else
        CFG_SSE3=no
@@ -3692,7 +3870,7 @@ fi
 
 # detect ssse3 support
 if [ "${CFG_SSSE3}" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/ssse3 "ssse3" $L_FLAGS $I_FLAGS $l_FLAGS "-mssse3"; then
+    if compileTest common/ssse3 "ssse3"; then
        CFG_SSSE3=yes
     else
        CFG_SSSE3=no
@@ -3701,7 +3879,7 @@ fi
 
 # detect sse4.1 support
 if [ "${CFG_SSE4_1}" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sse4_1 "sse4_1" $L_FLAGS $I_FLAGS $l_FLAGS "-msse4.1"; then
+    if compileTest common/sse4_1 "sse4_1"; then
        CFG_SSE4_1=yes
     else
        CFG_SSE4_1=no
@@ -3710,7 +3888,7 @@ fi
 
 # detect sse4.2 support
 if [ "${CFG_SSE4_2}" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sse4_2 "sse4_2" $L_FLAGS $I_FLAGS $l_FLAGS "-msse4.2"; then
+    if compileTest common/sse4_2 "sse4_2"; then
        CFG_SSE4_2=yes
     else
        CFG_SSE4_2=no
@@ -3719,7 +3897,7 @@ fi
 
 # detect avx support
 if [ "${CFG_AVX}" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/avx "avx" $L_FLAGS $I_FLAGS $l_FLAGS "-mavx"; then
+    if compileTest common/avx "avx"; then
        case "$XQMAKESPEC" in
            *g++*|*-clang*)
                # Some clang versions produce internal compiler errors compiling Qt AVX code
@@ -3749,7 +3927,7 @@ if [ "${CFG_AVX}" = "no" ]; then
     CFG_AVX2=no
 fi
 if [ "${CFG_AVX2}" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/avx2 "avx2" $L_FLAGS $I_FLAGS $l_FLAGS "-march=core-avx2"; then
+    if compileTest common/avx2 "avx2"; then
        CFG_AVX2=yes
     else
        CFG_AVX2=no
@@ -3758,7 +3936,7 @@ fi
 
 # check iWMMXt support
 if [ "$CFG_IWMMXT" = "yes" ]; then
-    "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/iwmmxt "iwmmxt" $L_FLAGS $I_FLAGS $l_FLAGS "-mcpu=iwmmxt"
+    compileTest unix/iwmmxt "iwmmxt"
     if [ $? != "0" ]; then
         echo "The iWMMXt functionality test failed!"
        echo " Please make sure your compiler supports iWMMXt intrinsics!"
@@ -3768,7 +3946,7 @@ fi
 
 # detect neon support
 if [ "$CFG_ARCH" = "arm" ] && [ "${CFG_NEON}" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/neon "neon" $L_FLAGS $I_FLAGS $l_FLAGS "-mfpu=neon"; then
+    if compileTest unix/neon "neon"; then
        CFG_NEON=yes
     else
        CFG_NEON=no
@@ -3778,17 +3956,25 @@ elif [ "$CFG_ARCH" != "arm" ]; then
 fi
 
 # detect mips_dsp support
-if [ "${CFG_ARCH}" = "mips" ] && [ "${CFG_MIPS_DSP}" = "yes" ]; then
-  CFG_MIPS_DSP=yes
+if [ "$CFG_ARCH" = "mips" ] && [ "${CFG_MIPS_DSP}" = "auto" ]; then
+    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mips_dsp "mips_dsp" $L_FLAGS $I_FLAGS $D_FLAGS $l_FLAGS; then
+        CFG_MIPS_DSP=yes
     else
-  CFG_MIPS_DSP=no
+        CFG_MIPS_DSP=no
+    fi
+elif [ "$CFG_ARCH" != "mips" ]; then
+    CFG_MIPS_DSP=no
 fi
 
 # detect mips_dspr2 support
-if [ "${CFG_ARCH}" = "mips" ] && [ "${CFG_MIPS_DSPR2}" = "yes" ]; then
-  CFG_MIPS_DSPR2=yes
+if [ "$CFG_ARCH" = "mips" ] && [ "${CFG_MIPS_DSPR2}" = "auto" ]; then
+    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mips_dspr2 "mips_dspr2" $L_FLAGS $I_FLAGS $D_FLAGS $l_FLAGS; then
+        CFG_MIPS_DSPR2=yes
     else
-  CFG_MIPS_DSPR2=no
+        CFG_MIPS_DSPR2=no
+    fi
+elif [ "$CFG_ARCH" != "mips" ]; then
+    CFG_MIPS_DSPR2=no
 fi
 
 [ "$XPLATFORM_MINGW" = "yes" ] && QMakeVar add styles "windowsxp windowsvista"
@@ -3808,7 +3994,7 @@ if [ "$CFG_ZLIB" = "no" ]; then
     ZLIB_FORCED=yes
 fi
 if [ "$CFG_ZLIB" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/zlib "zlib" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    if compileTest unix/zlib "zlib"; then
        CFG_ZLIB=system
     else
        CFG_ZLIB=yes
@@ -3834,7 +4020,7 @@ if [ "$CFG_JPEG" = "auto" ]; then
 fi
 # detect jpeg
 if [ "$CFG_LIBJPEG" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libjpeg "libjpeg" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    if compileTest unix/libjpeg "libjpeg"; then
        CFG_LIBJPEG=system
     else
        CFG_LIBJPEG=qt
@@ -3852,18 +4038,13 @@ fi
 
 # detect png
 if [ "$CFG_LIBPNG" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libpng "libpng" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    if compileTest unix/libpng "libpng"; then
        CFG_LIBPNG=system
     else
        CFG_LIBPNG=qt
     fi
 fi
 
-# detect accessibility
-if [ "$CFG_ACCESSIBILITY" = "auto" ]; then
-    CFG_ACCESSIBILITY=yes
-fi
-
 if [ "$CFG_EGLFS" = "yes" ]; then
     if [ "$CFG_EGL" = "no" ]; then
         echo "The EGLFS plugin requires EGL support and cannot be built"
@@ -3877,6 +4058,17 @@ if [ "$CFG_EGLFS" = "yes" ]; then
     CFG_EGL=yes
 fi
 
+if [ "$CFG_KMS" = "yes" ]; then
+    if [ "$CFG_EGL" = "no" ]; then
+        echo "The KMS plugin requires EGL support and cannot be built"
+        exit 101
+    fi
+    if [ "$CFG_OPENGL" != "es2" ]; then
+        echo "The KMS plugin requires OpenGL ES 2 support and cannot be built"
+        exit 101
+    fi
+fi
+
 # auto-detect SQL-modules support
 for _SQLDR in $CFG_SQL_AVAILABLE; do
         case $_SQLDR in
@@ -3884,9 +4076,9 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do
             if [ "$CFG_SQL_mysql" != "no" ]; then
                [ -z "$CFG_MYSQL_CONFIG" ] && CFG_MYSQL_CONFIG=`"$WHICH" mysql_config`
                 if [ -x "$CFG_MYSQL_CONFIG" ]; then
-                    QT_CFLAGS_MYSQL=`$CFG_MYSQL_CONFIG --include 2>/dev/null`
-                    QT_LFLAGS_MYSQL_R=`$CFG_MYSQL_CONFIG --libs_r 2>/dev/null`
-                    QT_LFLAGS_MYSQL=`$CFG_MYSQL_CONFIG --libs 2>/dev/null`
+                    QT_CFLAGS_MYSQL=`$CFG_MYSQL_CONFIG --include 2>/dev/null | filterIncludeOptions`
+                    QT_LFLAGS_MYSQL_R=`$CFG_MYSQL_CONFIG --libs_r 2>/dev/null | filterLibraryOptions`
+                    QT_LFLAGS_MYSQL=`$CFG_MYSQL_CONFIG --libs 2>/dev/null | filterLibraryOptions`
                    QT_MYSQL_VERSION=`$CFG_MYSQL_CONFIG --version 2>/dev/null`
                     QT_MYSQL_VERSION_MAJOR=`echo $QT_MYSQL_VERSION | cut -d . -f 1`
                 fi
@@ -3904,13 +4096,13 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do
                        QT_CFLAGS_MYSQL=""
                     fi
                 else
-                    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mysql_r "MySQL (thread-safe)" $QT_LFLAGS_MYSQL_R $L_FLAGS $QT_CFLAGS_MYSQL $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+                    if compileTest unix/mysql_r "MySQL (thread-safe)" $QT_LFLAGS_MYSQL_R $QT_CFLAGS_MYSQL; then
                         QMakeVar add CONFIG use_libmysqlclient_r
                         if [ "$CFG_SQL_mysql" = "auto" ]; then
                             CFG_SQL_mysql=plugin
                         fi
                         QT_LFLAGS_MYSQL="$QT_LFLAGS_MYSQL_R"
-                    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mysql "MySQL (thread-unsafe)" $QT_LFLAGS_MYSQL $L_FLAGS $QT_CFLAGS_MYSQL $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+                    elif compileTest unix/mysql "MySQL (thread-unsafe)" $QT_LFLAGS_MYSQL $QT_CFLAGS_MYSQL; then
                         if [ "$CFG_SQL_mysql" = "auto" ]; then
                             CFG_SQL_mysql=plugin
                         fi
@@ -3935,14 +4127,14 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do
             if [ "$CFG_SQL_psql" != "no" ]; then
                 # Be careful not to use native pg_config when cross building.
                 if [ "$XPLATFORM_MINGW" != "yes" ] && "$WHICH" pg_config >/dev/null 2>&1; then
-                    QT_CFLAGS_PSQL=`pg_config --includedir 2>/dev/null`
-                    QT_LFLAGS_PSQL=`pg_config --libdir 2>/dev/null`
+                    QT_CFLAGS_PSQL=`pg_config --includedir 2>/dev/null | filterIncludePath`
+                    QT_LFLAGS_PSQL=`pg_config --libdir 2>/dev/null | filterLibraryPath`
                 fi
                 [ -z "$QT_CFLAGS_PSQL" ] || QT_CFLAGS_PSQL="-I$QT_CFLAGS_PSQL"
                 [ -z "$QT_LFLAGS_PSQL" ] || QT_LFLAGS_PSQL="-L$QT_LFLAGS_PSQL"
                 # But, respect PSQL_LIBS if set
                 [ -z "$PSQL_LIBS" ] || QT_LFLAGS_PSQL="$PSQL_LIBS"
-                if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/psql "PostgreSQL" $QT_LFLAGS_PSQL $L_FLAGS $QT_CFLAGS_PSQL $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+                if compileTest unix/psql "PostgreSQL" $QT_LFLAGS_PSQL $QT_CFLAGS_PSQL; then
                     if [ "$CFG_SQL_psql" = "auto" ]; then
                         CFG_SQL_psql=plugin
                     fi
@@ -3963,12 +4155,12 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do
         ;;
         odbc)
             if [ "$CFG_SQL_odbc" != "no" ]; then
-                if ( [ "$BUILD_ON_MAC" != "yes" ] || [ "$XPLATFORM_MINGW" = "yes" ] ) && "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/odbc "ODBC" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+                if ( [ "$BUILD_ON_MAC" != "yes" ] || [ "$XPLATFORM_MINGW" = "yes" ] ) && compileTest unix/odbc "ODBC"; then
                     if [ "$CFG_SQL_odbc" = "auto" ]; then
                         CFG_SQL_odbc=plugin
                     fi
                 else
-                    if "$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
+                    if compileTest unix/iodbc "iODBC"; then
                         QT_LFLAGS_ODBC="-liodbc"
                         if [ "$CFG_SQL_odbc" = "auto" ]; then
                             CFG_SQL_odbc=plugin
@@ -3989,7 +4181,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do
             ;;
         oci)
             if [ "$CFG_SQL_oci" != "no" ]; then
-                if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/oci "OCI" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+                if compileTest unix/oci "OCI"; then
                     if [ "$CFG_SQL_oci" = "auto" ]; then
                         CFG_SQL_oci=plugin
                     fi
@@ -4010,7 +4202,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do
             if [ "$CFG_SQL_tds" != "no" ]; then
                 [ -z "$SYBASE" ] || QT_LFLAGS_TDS="-L$SYBASE/lib"
                 [ -z "$SYBASE_LIBS" ] || QT_LFLAGS_TDS="$QT_LFLAGS_TDS $SYBASE_LIBS"
-                if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/tds "TDS" $QT_LFLAGS_TDS $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+                if compileTest unix/tds "TDS" $QT_LFLAGS_TDS; then
                     if [ "$CFG_SQL_tds" = "auto" ]; then
                         CFG_SQL_tds=plugin
                     fi
@@ -4029,7 +4221,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do
             ;;
         db2)
             if [ "$CFG_SQL_db2" != "no" ]; then
-                if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/db2 "DB2" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+                if compileTest unix/db2 "DB2"; then
                     if [ "$CFG_SQL_db2" = "auto" ]; then
                         CFG_SQL_db2=plugin
                     fi
@@ -4048,7 +4240,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do
             ;;
         ibase)
             if [ "$CFG_SQL_ibase" != "no" ]; then
-                if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/ibase "InterBase" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+                if compileTest unix/ibase "InterBase"; then
                     if [ "$CFG_SQL_ibase" = "auto" ]; then
                         CFG_SQL_ibase=plugin
                     fi
@@ -4067,7 +4259,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do
             ;;
         sqlite2)
             if [ "$CFG_SQL_sqlite2" != "no" ]; then
-                if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sqlite2 "SQLite2" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+                if compileTest unix/sqlite2 "SQLite2"; then
                     if [ "$CFG_SQL_sqlite2" = "auto" ]; then
                         CFG_SQL_sqlite2=plugin
                     fi
@@ -4091,8 +4283,11 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do
                     if [ -n "$PKG_CONFIG" ]; then
                         QT_CFLAGS_SQLITE=`$PKG_CONFIG --cflags sqlite3 2>/dev/null`
                         QT_LFLAGS_SQLITE=`$PKG_CONFIG --libs sqlite3 2>/dev/null`
+                    else
+                        QT_CFLAGS_SQLITE=
+                        QT_LFLAGS_SQLITE="-lsqlite3 -lz"
                     fi
-                    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sqlite "SQLite" $QT_LFLAGS_SQLITE $L_FLAGS $QT_CFLAGS_SQLITE $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+                    if compileTest unix/sqlite "SQLite" $QT_LFLAGS_SQLITE $QT_CFLAGS_SQLITE; then
                         if [ "$CFG_SQL_sqlite" = "auto" ]; then
                             CFG_SQL_sqlite=plugin
                         fi
@@ -4129,7 +4324,7 @@ done
 
 # auto-detect NIS support
 if [ "$CFG_NIS" != "no" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/nis "NIS" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    if compileTest unix/nis "NIS"; then
         CFG_NIS=yes
     else
         if [ "$CFG_NIS" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
@@ -4146,7 +4341,7 @@ fi
 
 # auto-detect CUPS support
 if [ "$CFG_CUPS" != "no" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/cups "Cups" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    if compileTest unix/cups "Cups"; then
         CFG_CUPS=yes
     else
         if [ "$CFG_CUPS" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
@@ -4165,11 +4360,11 @@ fi
 if [ "$CFG_ICONV" != "no" ]; then
     if [ "$XPLATFORM_MINGW" = "yes" ]; then
         CFG_ICONV=no
-    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/iconv" "POSIX iconv" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    elif compileTest unix/iconv "POSIX iconv"; then
         CFG_ICONV=yes
-    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/sun-libiconv" "SUN libiconv" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    elif compileTest unix/sun-libiconv "SUN libiconv"; then
         CFG_ICONV=sun
-    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/gnu-libiconv" "GNU libiconv" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    elif compileTest unix/gnu-libiconv "GNU libiconv"; then
         CFG_ICONV=gnu
     else
         if [ "$CFG_ICONV" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
@@ -4190,7 +4385,7 @@ if [ "$CFG_DBUS" != "no" ]; then
         QT_CFLAGS_DBUS=`$PKG_CONFIG --cflags dbus-1 2>/dev/null`
         QT_LIBS_DBUS=`$PKG_CONFIG --libs dbus-1 2>/dev/null`
     fi
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/dbus "D-Bus" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_DBUS $QT_LIBS_DBUS $MAC_CONFIG_TEST_COMMANDLINE; then
+    if compileTest unix/dbus "D-Bus" $QT_CFLAGS_DBUS $QT_LIBS_DBUS; then
         [ "$CFG_DBUS" = "auto" ] && CFG_DBUS=yes
         QMakeVar set QT_CFLAGS_DBUS "$QT_CFLAGS_DBUS"
         QMakeVar set QT_LIBS_DBUS "$QT_LIBS_DBUS"
@@ -4215,7 +4410,7 @@ if [ "$CFG_GLIB" != "no" ]; then
         QT_CFLAGS_GLIB=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0 2>/dev/null`
         QT_LIBS_GLIB=`$PKG_CONFIG --libs glib-2.0 gthread-2.0 2>/dev/null`
     fi
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/glib "Glib" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_GLIB $QT_LIBS_GLIB; then
+    if compileTest unix/glib "Glib" $QT_CFLAGS_GLIB $QT_LIBS_GLIB; then
         CFG_GLIB=yes
         QMakeVar set QT_CFLAGS_GLIB "$QT_CFLAGS_GLIB"
         QMakeVar set QT_LIBS_GLIB "$QT_LIBS_GLIB"
@@ -4264,7 +4459,7 @@ if [ "$CFG_GLIB" = "yes" -a "$CFG_GSTREAMER" != "no" ]; then
         QT_CFLAGS_GSTREAMER=`$PKG_CONFIG --cflags gstreamer-0.10 gstreamer-plugins-base-0.10 2>/dev/null`
         QT_LIBS_GSTREAMER=`$PKG_CONFIG --libs gstreamer-0.10 gstreamer-plugins-base-0.10 2>/dev/null`
     fi
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/gstreamer "GStreamer" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_GSTREAMER $QT_LIBS_GSTREAMER; then
+    if compileTest unix/gstreamer "GStreamer" $QT_CFLAGS_GSTREAMER $QT_LIBS_GSTREAMER; then
         CFG_GSTREAMER=yes
         QMakeVar set QT_CFLAGS_GSTREAMER "$QT_CFLAGS_GSTREAMER"
         QMakeVar set QT_LIBS_GSTREAMER "$QT_LIBS_GSTREAMER"
@@ -4285,7 +4480,7 @@ fi
 
 # auto-detect libicu support
 if [ "$CFG_ICU" != "no" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/icu "ICU" $L_FLAGS $I_FLAGS $l_FLAGS; then
+    if compileTest unix/icu "ICU"; then
         [ "$CFG_ICU" = "auto" ] && CFG_ICU=yes
     else
         if [ "$CFG_ICU" = "auto" ]; then
@@ -4308,7 +4503,7 @@ if [ "$CFG_PULSEAUDIO" != "no" ]; then
         QT_CFLAGS_PULSEAUDIO=`$PKG_CONFIG --cflags libpulse '>=' 0.9.10 libpulse-mainloop-glib 2>/dev/null`
         QT_LIBS_PULSEAUDIO=`$PKG_CONFIG --libs libpulse '>=' 0.9.10 libpulse-mainloop-glib 2>/dev/null`
     fi
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/pulseaudio "PulseAudio" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_PULSEAUDIO $QT_LIBS_PULSEAUDIO; then
+    if compileTest unix/pulseaudio "PulseAudio" $QT_CFLAGS_PULSEAUDIO $QT_LIBS_PULSEAUDIO; then
         CFG_PULSEAUDIO=yes
         QMakeVar set QT_CFLAGS_PULSEAUDIO "$QT_CFLAGS_PULSEAUDIO"
         QMakeVar set QT_LIBS_PULSEAUDIO "$QT_LIBS_PULSEAUDIO"
@@ -4339,9 +4534,9 @@ if [ "$XPLATFORM_MINGW" = "yes" ]; then
         fi
     fi
     if [ "$CFG_OPENGL" = "auto" ] || [ "$CFG_OPENGL" = "yes" ]; then
-        if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/opengl "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS; then
+        if compileTest x11/opengl "OpenGL"; then
             CFG_OPENGL=desktop
-        elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS; then
+        elif compileTest unix/opengles2 "OpenGL ES 2.x"; then
             CFG_OPENGL=es2
         else
             if [ "$CFG_OPENGL" = "yes" ]; then
@@ -4357,7 +4552,7 @@ if [ "$XPLATFORM_MINGW" = "yes" ]; then
         hpux*)
             # HP-UX have buggy glx headers; check if we really need to define the GLXFBConfig struct.
             if [ "$CFG_OPENGL" = "desktop" ]; then
-                "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/glxfbconfig "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS
+                compileTest x11/glxfbconfig "OpenGL"
                 if [ $? != "0" ]; then
                     QMakeVar add DEFINES QT_DEFINE_GLXFBCONFIG_STRUCT
                 fi
@@ -4368,7 +4563,7 @@ if [ "$XPLATFORM_MINGW" = "yes" ]; then
         esac
     elif [ "$CFG_OPENGL" = "es2" ]; then
         #OpenGL ES 2.x
-        "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS
+        compileTest unix/opengles2 "OpenGL ES 2.x"
         if [ $? != "0" ]; then
             echo "The OpenGL ES 2.0 functionality test failed!"
             echo " You might need to modify the include and library search paths by editing"
@@ -4378,7 +4573,7 @@ if [ "$XPLATFORM_MINGW" = "yes" ]; then
         fi
     elif [ "$CFG_OPENGL" = "desktop" ]; then
         # Desktop OpenGL support
-        "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/opengl "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS
+        compileTest x11/opengl "OpenGL"
         if [ $? != "0" ]; then
             echo "The OpenGL functionality test failed!"
             echo " You might need to modify the include and library search paths by editing"
@@ -4389,7 +4584,7 @@ if [ "$XPLATFORM_MINGW" = "yes" ]; then
         case "$PLATFORM" in
         hpux*)
             # HP-UX have buggy glx headers; check if we really need to define the GLXFBConfig struct.
-            "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/glxfbconfig "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS
+            compileTest x11/glxfbconfig "OpenGL"
             if [ $? != "0" ]; then
                 QMakeVar add DEFINES QT_DEFINE_GLXFBCONFIG_STRUCT
             fi
@@ -4401,13 +4596,8 @@ if [ "$XPLATFORM_MINGW" = "yes" ]; then
 fi # X11/MINGW OpenGL
 
 if [ "$BUILD_ON_MAC" = "yes" ]; then
-    if [ "$CFG_PHONON" != "no" ]; then
-        # Always enable Phonon (unless it was explicitly disabled)
-        CFG_PHONON=yes
-    fi
-
     if [ "$CFG_COREWLAN" = "auto" ]; then
-        if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/mac/corewlan "CoreWlan" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+        if compileTest mac/corewlan "CoreWlan"; then
             CFG_COREWLAN=yes
         else
             CFG_COREWLAN=no
@@ -4417,9 +4607,9 @@ fi
 
 # auto-detect OpenGL support (es2 = OpenGL ES 2.x)
 if [ "$CFG_OPENGL" = "auto" ] || [ "$CFG_OPENGL" = "yes" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengldesktop "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS; then
+    if compileTest unix/opengldesktop "OpenGL"; then
         CFG_OPENGL=desktop
-    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS; then
+    elif compileTest unix/opengles2 "OpenGL ES 2.x"; then
         CFG_OPENGL=es2
     else
         if [ "$CFG_OPENGL" = "yes" ]; then
@@ -4438,12 +4628,12 @@ elif [ "$CFG_OPENGL" = "es2" ]; then
         QMAKE_LIBDIR_OPENGL_ES2=`$PKG_CONFIG --libs-only-L glesv2 2>/dev/null | sed -e 's,^-L,,g' -e 's, -L, ,g'`
         QMAKE_LIBS_OPENGL_ES2=`$PKG_CONFIG --libs glesv2 2>/dev/null`
         QMAKE_CFLAGS_OPENGL_ES2=`$PKG_CONFIG --cflags glesv2 2>/dev/null`
-        QMakeVar set QMAKE_INCDIR_OPENGL_ES2 "$QMAKE_INCDIR_OPENGL_ES2"
-        QMakeVar set QMAKE_LIBDIR_OPENGL_ES2 "$QMAKE_LIBDIR_OPENGL_ES2"
-        QMakeVar set QMAKE_LIBS_OPENGL_ES2 "$QMAKE_LIBS_OPENGL_ES2"
+        QMakeVar set QMAKE_INCDIR_OPENGL_ES2 "`shellArgumentListToQMakeList "$QMAKE_INCDIR_OPENGL_ES2"`"
+        QMakeVar set QMAKE_LIBDIR_OPENGL_ES2 "`shellArgumentListToQMakeList "$QMAKE_LIBDIR_OPENGL_ES2"`"
+        QMakeVar set QMAKE_LIBS_OPENGL_ES2 "`shellArgumentListToQMakeList "$QMAKE_LIBS_OPENGL_ES2"`"
     fi
 
-    "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS $QMAKE_LIBS_OPENGL_ES2 $QMAKE_CFLAGS_OPENGL_ES2
+    compileTest unix/opengles2 "OpenGL ES 2.x" $QMAKE_LIBS_OPENGL_ES2 $QMAKE_CFLAGS_OPENGL_ES2
     if [ $? != "0" ]; then
         echo "The OpenGL ES 2.0 functionality test failed!"
         echo " You might need to modify the include and library search paths by editing"
@@ -4453,7 +4643,7 @@ elif [ "$CFG_OPENGL" = "es2" ]; then
     fi
 elif [ "$CFG_OPENGL" = "desktop" ]; then
     # Desktop OpenGL support
-    "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengldesktop "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS
+    compileTest unix/opengldesktop "OpenGL"
     if [ $? != "0" ]; then
         echo "The OpenGL functionality test failed!"
         echo " You might need to modify the include and library search paths by editing"
@@ -4472,11 +4662,14 @@ if [ "$CFG_FONTCONFIG" != "no" ]; then
         QT_CFLAGS_FONTCONFIG=
         QT_LIBS_FONTCONFIG="-lfreetype -lfontconfig"
     fi
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/fontconfig "FontConfig" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_FONTCONFIG $QT_LIBS_FONTCONFIG; then
+    if compileTest unix/fontconfig "FontConfig" $QT_CFLAGS_FONTCONFIG $QT_LIBS_FONTCONFIG; then
         QT_CONFIG="$QT_CONFIG fontconfig"
         QMakeVar set QMAKE_CFLAGS_FONTCONFIG "$QT_CFLAGS_FONTCONFIG"
         QMakeVar set QMAKE_LIBS_FONTCONFIG "$QT_LIBS_FONTCONFIG"
+        CFG_FONTCONFIG=yes
         CFG_LIBFREETYPE=system
+    else
+        CFG_FONTCONFIG=no
     fi
 
 fi
@@ -4485,6 +4678,8 @@ fi
 ORIG_CFG_XCB="$CFG_XCB"
 ORIG_CFG_EGLFS="$CFG_EGLFS"
 ORIG_CFG_DIRECTFB="$CFG_DIRECTFB"
+ORIG_CFG_LINUXFB="$CFG_LINUXFB"
+ORIG_CFG_KMS="$CFG_KMS"
 
 if [ "$CFG_LIBUDEV" != "no" ]; then
     if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists libudev 2>/dev/null; then
@@ -4493,7 +4688,7 @@ if [ "$CFG_LIBUDEV" != "no" ]; then
         QMakeVar set QMAKE_INCDIR_LIBUDEV "$QMAKE_INCDIR_LIBUDEV"
         QMakeVar set QMAKE_LIBS_LIBUDEV "$QMAKE_LIBS_LIBUDEV"
     fi
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libudev "libudev" $L_FLAGS $I_FLAGS $l_FLAGS $QMAKE_INCDIR_LIBUDEV $QMAKE_LIBS_LIBUDEV; then
+    if compileTest unix/libudev "libudev" $QMAKE_INCDIR_LIBUDEV $QMAKE_LIBS_LIBUDEV; then
         CFG_LIBUDEV=yes
         QT_CONFIG="$QT_CONFIG libudev"
     elif [ "$CFG_LIBUDEV" = "yes" ]; then
@@ -4501,12 +4696,14 @@ if [ "$CFG_LIBUDEV" != "no" ]; then
         exit 1
     else
         CFG_LIBUDEV=no
-        QMakeVar add DEFINES QT_NO_LIBUDEV
     fi
 fi
+if [ "$CFG_LIBUDEV" = "no" ]; then
+    QMakeVar add DEFINES QT_NO_LIBUDEV
+fi
 
 if [ "$CFG_EVDEV" != "no" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/evdev "evdev" $L_FLAGS $I_FLAGS $l_FLAGS; then
+    if compileTest unix/evdev "evdev"; then
         CFG_EVDEV=yes
         QT_CONFIG="$QT_CONFIG evdev"
     elif [ "$CFG_EVDEV" = "yes" ]; then
@@ -4514,18 +4711,20 @@ if [ "$CFG_EVDEV" != "no" ]; then
         exit 1
     else
         CFG_EVDEV=no
-        QMakeVar add DEFINES QT_NO_EVDEV
     fi
 fi
+if [ "$CFG_EVDEV" = "no" ]; then
+    QMakeVar add DEFINES QT_NO_EVDEV
+fi
 
 # Check we actually have X11 :-)
-if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/xlib "XLib" $L_FLAGS $I_FLAGS $l_FLAGS; then
+if compileTest x11/xlib "XLib"; then
     QT_CONFIG="$QT_CONFIG xlib"
 fi
 
 # auto-detect Xrender support
 if [ "$CFG_XRENDER" != "no" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/xrender "Xrender" $L_FLAGS $I_FLAGS $l_FLAGS; then
+    if compileTest x11/xrender "Xrender"; then
         CFG_XRENDER=yes
         QT_CONFIG="$QT_CONFIG xrender"
     else
@@ -4543,40 +4742,38 @@ fi
 
 if [ "$CFG_XCB" != "no" ]; then
     if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists "xcb >= 1.5" 2>/dev/null; then
-        QMAKE_CFLAGS_XCB="`$PKG_CONFIG --cflags xcb 2>/dev/null`"
-        QMAKE_LIBS_XCB="`$PKG_CONFIG --libs xcb 2>/dev/null`"
+        QMAKE_CFLAGS_XCB="`$PKG_CONFIG --cflags xcb xcb-image xcb-keysyms xcb-icccm xcb-sync xcb-xfixes xcb-randr 2>/dev/null`"
+        QMAKE_LIBS_XCB="`$PKG_CONFIG --libs xcb xcb-image xcb-keysyms xcb-icccm xcb-sync xcb-xfixes xcb-randr 2>/dev/null`"
     fi
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/qpa/xcb "xcb" $L_FLAGS $I_FLAGS $l_FLAGS $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then
+    if compileTest qpa/xcb "xcb" $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then
         CFG_XCB=yes
-        if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/qpa/xcb-render "xcb-render" $L_FLAGS $I_FLAGS $l_FLAGS $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then
+        if compileTest qpa/xcb-render "xcb-render" $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then
             QT_CONFIG="$QT_CONFIG xcb-render"
         fi
 
-        if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/qpa/xcb-poll-for-queued-event "xcb-poll-for-queued-event" $L_FLAGS $I_FLAGS $l_FLAGS $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then
+        if compileTest qpa/xcb-poll-for-queued-event "xcb-poll-for-queued-event" $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then
             CFG_XCB_LIMITED=no
             QT_CONFIG="$QT_CONFIG xcb-poll-for-queued-event"
         fi
 
-        if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/qpa/xcb-xlib "xcb-xlib" $L_FLAGS $I_FLAGS $l_FLAGS $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then
+        if compileTest qpa/xcb-xlib "xcb-xlib" $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then
             QT_CONFIG="$QT_CONFIG xcb-xlib"
         fi
 
-        if [ "$XPLATFORM_MAEMO" = "yes" ]; then
-            # auto-detect XInput2/Xinput support
-            if [ "$CFG_XINPUT2" != "no" ]; then
-                if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/xinput2 "XInput2" $L_FLAGS $I_FLAGS $l_FLAGS; then
-                    CFG_XINPUT2=yes
-                    CFG_XINPUT=no
+        # auto-detect XInput2 support. Needed by xcb too.
+        if [ "$CFG_XINPUT2" != "no" ]; then
+            if compileTest x11/xinput2 "XInput2"; then
+                CFG_XINPUT2=yes
+                CFG_XINPUT=no
+            else
+                if [ "$CFG_XINPUT2" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
+                    echo "XInput2 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
-                    if [ "$CFG_XINPUT2" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
-                        echo "XInput2 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_XINPUT2=no
-                    fi
+                    CFG_XINPUT2=no
                 fi
             fi
         fi
@@ -4588,15 +4785,17 @@ if [ "$CFG_XCB" != "no" ]; then
             exit 1
         fi
         CFG_XCB=no
-        QMakeVar add DEFINES QT_NO_XCB
     fi
 fi
+if [ "$CFG_XCB" = "no" ]; then
+    QMakeVar add DEFINES QT_NO_XCB
+fi
 
 if [ "$CFG_DIRECTFB" != "no" ]; then
     if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists directfb 2>/dev/null; then
         QMAKE_CFLAGS_DIRECTFB=`$PKG_CONFIG --cflags directfb 2>/dev/null`
         QMAKE_LIBS_DIRECTFB=`$PKG_CONFIG --libs directfb 2>/dev/null`
-        if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/directfb" "DirectFB" $L_FLAGS $I_FLAGS $l_FLAGS $QMAKE_CFLAGS_DIRECTFB $QMAKE_LIBS_DIRECTFB; then
+        if compileTest qpa/directfb "DirectFB" $QMAKE_CFLAGS_DIRECTFB $QMAKE_LIBS_DIRECTFB; then
             CFG_DIRECTFB=yes
         elif [ "$CFG_DIRECTFB" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
             echo " DirectFB support cannot be enabled due to functionality tests!"
@@ -4612,6 +4811,34 @@ if [ "$CFG_DIRECTFB" != "no" ]; then
     fi
 fi
 
+if [ "$CFG_LINUXFB" != "no" ]; then
+    if compileTest qpa/linuxfb "LinuxFB"; then
+        CFG_LINUXFB=yes
+    elif [ "$CFG_LINUXFB" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
+        echo " Linux Framebuffer 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_LINUXFB=no
+    fi
+fi
+
+if [ "$CFG_KMS" != "no" ]; then
+    if compileTest qpa/kms "KMS"; then
+        CFG_KMS=yes
+    elif [ "$CFG_KMS" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
+        echo " KMS 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_KMS=no
+    fi
+fi
+
 # Detect libxkbcommon
 if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists xkbcommon 2>/dev/null; then
     QMAKE_CFLAGS_XKBCOMMON="`$PKG_CONFIG --cflags xkbcommon 2>/dev/null`"
@@ -4623,7 +4850,7 @@ else
 fi
 
 # EGL Support
-if [ "$CFG_EGL" != "no" ] && [ "$CFG_OPENGL" != "desktop" ]; then
+if [ "$CFG_EGL" != "no" ]; then
     if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists egl 2>/dev/null; then
         QMAKE_INCDIR_EGL=`$PKG_CONFIG --cflags-only-I egl 2>/dev/null | sed -e 's,^-I,,g' -e 's, -I, ,g'`
         QMAKE_LIBS_EGL=`$PKG_CONFIG --libs egl 2>/dev/null`
@@ -4631,7 +4858,7 @@ if [ "$CFG_EGL" != "no" ] && [ "$CFG_OPENGL" != "desktop" ]; then
         QMakeVar set QMAKE_INCDIR_EGL "$QMAKE_INCDIR_EGL"
         QMakeVar set QMAKE_LIBS_EGL "$QMAKE_LIBS_EGL"
     fi       # detect EGL support
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/qpa/egl" "EGL" $L_FLAGS $I_FLAGS $l_FLAGS $QMAKE_CFLAGS_EGL $QMAKE_LIBS_EGL; then
+    if compileTest qpa/egl "EGL" $QMAKE_CFLAGS_EGL $QMAKE_LIBS_EGL; then
         CFG_EGL=yes
     elif [ "$CFG_EGL" = "yes" ]; then
         echo " The EGL functionality test failed; EGL is required by some QPA plugins to manage contexts & surfaces."
@@ -4651,19 +4878,48 @@ elif [ "$CFG_OPENGL" = "desktop" ]; then
 fi
 
 if [ "$CFG_EGLFS" != "no" ]; then
-    if [ "$CFG_OPENGL" = "es2" ]; then
+    if [ "$CFG_OPENGL" = "es2" ] && [ "$CFG_EVDEV" = "yes" ]; then
         CFG_EGLFS="$CFG_EGL"
     else
         CFG_EGLFS="no"
     fi
 fi
 
+if [ "$CFG_KMS" = "yes" ]; then
+    if [ "$CFG_OPENGL" = "es2" ] && [ "$CFG_EGL" = "yes" ]; then
+        CFG_KMS="yes"
+    else
+        CFG_KMS="no"
+    fi
+fi
+
+# Detect accessibility support
+if [ "$CFG_ACCESSIBILITY" != "no" ]; then
+    if [ "$CFG_XCB" = "no" ]; then
+        CFG_ACCESSIBILITY=yes
+    else
+        # linux/xcb accessibility needs dbus and atspi-2
+        if [ "$CFG_DBUS" != "no" ] && [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists "atspi-2" 2>/dev/null; then
+            CFG_ACCESSIBILITY=yes
+        else
+            if [ "$CFG_ACCESSIBILITY" = "auto" ]; then
+                CFG_ACCESSIBILITY=no
+            else
+                echo "Accessibility support needs pkg-config and libatspi2."
+                exit 101
+            fi
+        fi
+    fi
+fi
+
 # Determine the default QPA platform
 if [ -z "$QT_QPA_DEFAULT_PLATFORM" ]; then
     # check the mkspec
     QT_QPA_DEFAULT_PLATFORM=`getXQMakeConf QT_QPA_DEFAULT_PLATFORM`
     if [ -z "$QT_QPA_DEFAULT_PLATFORM" ]; then
-        if [ "$BUILD_ON_MAC" = "yes" ]; then
+        if [ "$XPLATFORM_MINGW" = "yes" ]; then
+            QT_QPA_DEFAULT_PLATFORM="windows"
+        elif [ "$BUILD_ON_MAC" = "yes" ]; then
             QT_QPA_DEFAULT_PLATFORM="cocoa"
         elif [ "$UNAME_SYSTEM" = "QNX" ]; then
             QT_QPA_DEFAULT_PLATFORM="qnx"
@@ -4683,9 +4939,15 @@ if [ "$CFG_DIRECTFB" = "yes" ]; then
     QMakeVar set QMAKE_CFLAGS_DIRECTFB "$QMAKE_CFLAGS_DIRECTFB"
     QMakeVar set QMAKE_LIBS_DIRECTFB "$QMAKE_LIBS_DIRECTFB"
 fi
+if [ "$CFG_LINUXFB" = "yes" ]; then
+    QT_CONFIG="$QT_CONFIG linuxfb"
+fi
+if [ "$CFG_KMS" = "yes" ]; then
+    QT_CONFIG="$QT_CONFIG kms"
+fi
 
 if [ "$BUILD_ON_MAC" = "yes" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/mac/coreservices "CoreServices" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    if compileTest mac/coreservices "CoreServices"; then
         QT_CONFIG="$QT_CONFIG coreservices"
     else
         QMakeVar add DEFINES QT_NO_CORESERVICES
@@ -4693,9 +4955,9 @@ if [ "$BUILD_ON_MAC" = "yes" ]; then
 fi
 
 if [ "$BUILD_ON_MAC" = "no" ] && [ "$XPLATFORM_MINGW" = "no" ] && [ "$XPLATFORM_QNX" = "no" ]; then
-    if [ "$CFG_XCB" = "no" ] && [ "$CFG_EGLFS" = "no" ] && [ "$CFG_DIRECTFB" = "no" ]; then
+    if [ "$CFG_XCB" = "no" ] && [ "$CFG_EGLFS" = "no" ] && [ "$CFG_DIRECTFB" = "no" ] && [ "$CFG_LINUXFB" = "no" ] && [ "$CFG_KMS" = "no" ]; then
         if [ "$QPA_PLATFORM_GUARD" = "yes" ] &&
-            ( [ "$ORIG_CFG_XCB" = "auto" ] || [ "$ORIG_CFG_EGLFS" = "auto" ] || [ "$ORIG_CFG_DIRECTFB" = "auto" ] ); then
+            ( [ "$ORIG_CFG_XCB" = "auto" ] || [ "$ORIG_CFG_EGLFS" = "auto" ] || [ "$ORIG_CFG_DIRECTFB" = "auto" ] || [ "$ORIG_CFG_LINUXFB" = "auto" ] || [ "$ORIG_CFG_KMS" = "auto" ] ); then
         echo "No QPA platform plugin enabled!"
         echo " If you really want to build without a QPA platform plugin you must pass"
         echo " -no-qpa-platform-guard to configure. Doing this will"
@@ -4707,19 +4969,17 @@ if [ "$BUILD_ON_MAC" = "no" ] && [ "$XPLATFORM_MINGW" = "no" ] && [ "$XPLATFORM_
 fi
     fi
 
-[ "$XPLATFORM_MINGW" = "yes" ] && [ "$CFG_PHONON" != "no" ] && CFG_PHONON="yes"
-
 # freetype support
 [ "$XPLATFORM_MINGW" = "yes" ] && [ "$CFG_LIBFREETYPE" = "auto" ] && CFG_LIBFREETYPE=no
 if [ "$CFG_LIBFREETYPE" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/freetype "FreeType" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    if compileTest unix/freetype "FreeType"; then
         CFG_LIBFREETYPE=system
     else
         CFG_LIBFREETYPE=yes
     fi
 fi
 
-if ! "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/stl "STL" $L_FLAGS $I_FLAGS $l_FLAGS &&
+if ! compileTest unix/stl "STL" &&
     [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
     echo "STL functionality check failed! Cannot build Qt with this STL library."
     echo " Turn on verbose messaging (-v) to $0 to see the final report."
@@ -4729,7 +4989,7 @@ fi
 
 # detect POSIX clock_gettime()
 if [ "$CFG_CLOCK_GETTIME" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/clock-gettime "POSIX clock_gettime()" $L_FLAGS $I_FLAGS $l_FLAGS; then
+    if compileTest unix/clock-gettime "POSIX clock_gettime()"; then
        CFG_CLOCK_GETTIME=yes
     else
        CFG_CLOCK_GETTIME=no
@@ -4738,7 +4998,7 @@ fi
 
 # detect POSIX monotonic clocks
 if [ "$CFG_CLOCK_GETTIME" = "yes" ] && [ "$CFG_CLOCK_MONOTONIC" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/clock-monotonic "POSIX Monotonic Clock" $L_FLAGS $I_FLAGS $l_FLAGS; then
+    if compileTest unix/clock-monotonic "POSIX Monotonic Clock"; then
        CFG_CLOCK_MONOTONIC=yes
     else
        CFG_CLOCK_MONOTONIC=no
@@ -4749,7 +5009,7 @@ fi
 
 # detect mremap
 if [ "$CFG_MREMAP" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mremap "mremap" $L_FLAGS $I_FLAGS $l_FLAGS; then
+    if compileTest unix/mremap "mremap"; then
        CFG_MREMAP=yes
     else
        CFG_MREMAP=no
@@ -4758,7 +5018,7 @@ fi
 
 # find if the platform provides getaddrinfo (ipv6 dns lookups)
 if [ "$CFG_GETADDRINFO" != "no" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/getaddrinfo "getaddrinfo" $L_FLAGS $I_FLAGS $l_FLAGS; then
+    if compileTest unix/getaddrinfo "getaddrinfo"; then
         CFG_GETADDRINFO=yes
     else
        if [ "$CFG_GETADDRINFO" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
@@ -4775,7 +5035,7 @@ fi
 
 # find if the platform provides inotify
 if [ "$CFG_INOTIFY" != "no" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/inotify "inotify" $L_FLAGS $I_FLAGS $l_FLAGS; then
+    if compileTest unix/inotify "inotify"; then
         CFG_INOTIFY=yes
     else
        if [ "$CFG_INOTIFY" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
@@ -4792,7 +5052,7 @@ fi
 
 # find if the platform provides if_nametoindex (ipv6 interface name support)
 if [ "$CFG_IPV6IFNAME" != "no" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/ipv6ifname "IPv6 interface name" $L_FLAGS $I_FLAGS $l_FLAGS; then
+    if compileTest unix/ipv6ifname "IPv6 interface name"; then
         CFG_IPV6IFNAME=yes
     else
         if [ "$CFG_IPV6IFNAME" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
@@ -4809,7 +5069,7 @@ fi
 
 # find if the platform provides getifaddrs (network interface enumeration)
 if [ "$CFG_GETIFADDRS" != "no" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/getifaddrs "getifaddrs" $L_FLAGS $I_FLAGS $l_FLAGS; then
+    if compileTest unix/getifaddrs "getifaddrs"; then
         CFG_GETIFADDRS=yes
     else
         if [ "$CFG_GETIFADDRS" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
@@ -4826,7 +5086,7 @@ fi
 
 # detect OpenSSL
 if [ "$CFG_OPENSSL" != "no" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/openssl "OpenSSL" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
+    if compileTest unix/openssl "OpenSSL"; then
         if [ "$CFG_OPENSSL" = "auto" ]; then
             CFG_OPENSSL=yes
         fi
@@ -4845,7 +5105,7 @@ fi
 
 # detect PCRE
 if [ "$CFG_PCRE" != "qt" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/pcre "PCRE" $L_FLAGS $I_FLAGS $l_FLAGS; then
+    if compileTest unix/pcre "PCRE"; then
         CFG_PCRE=system
     else
         if [ "$CFG_PCRE" = "system" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
@@ -4862,21 +5122,21 @@ fi
 
 # detect OpenVG support
 if [ "$CFG_OPENVG" != "no" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/openvg" "OpenVG" $L_FLAGS $I_FLAGS $l_FLAGS $CONFIG_ARG; then
+    if compileTest unix/openvg "OpenVG"; then
         if [ "$CFG_OPENVG" = "auto" ]; then
             CFG_OPENVG=yes
         fi
-    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG openvg_on_opengl" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/openvg" "OpenVG" $L_FLAGS $I_FLAGS $l_FLAGS $CONFIG_ARG; then
+    elif compileTest unix/openvg "OpenVG" -config openvg_on_opengl; then
         if [ "$CFG_OPENVG" = "auto" ]; then
             CFG_OPENVG=yes
         fi
         CFG_OPENVG_ON_OPENGL=yes
-    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG lower_case_includes" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/openvg" "OpenVG (lc includes)" $L_FLAGS $I_FLAGS $l_FLAGS $CONFIG_ARG; then
+    elif compileTest unix/openvg "OpenVG (lc includes)" -config lower_case_includes; then
         if [ "$CFG_OPENVG" = "auto" ]; then
             CFG_OPENVG=yes
         fi
         CFG_OPENVG_LC_INCLUDES=yes
-    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG openvg_on_opengl lower_case_includes" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/openvg" "OpenVG (lc includes)" $L_FLAGS $I_FLAGS $l_FLAGS $CONFIG_ARG; then
+    elif compileTest unix/openvg "OpenVG (lc includes)" -config "openvg_on_opengl lower_case_includes"; then
         if [ "$CFG_OPENVG" = "auto" ]; then
             CFG_OPENVG=yes
         fi
@@ -4893,13 +5153,13 @@ if [ "$CFG_OPENVG" != "no" ]; then
             CFG_OPENVG=no
         fi
     fi
-    if [ "$CFG_OPENVG" = "yes" ] && "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/shivavg" "ShivaVG" $L_FLAGS $I_FLAGS $l_FLAGS $CONFIG_ARG; then
+    if [ "$CFG_OPENVG" = "yes" ] && compileTest unix/shivavg "ShivaVG"; then
         CFG_OPENVG_SHIVA=yes
     fi
 fi
 
 if [ "$CFG_ALSA" = "auto" ]; then
-    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/alsa "alsa" $L_FLAGS $I_FLAGS $l_FLAGS; then
+    if compileTest unix/alsa "alsa"; then
         CFG_ALSA=yes
     else
         CFG_ALSA=no
@@ -4908,7 +5168,7 @@ fi
 
 if [ "$CFG_JAVASCRIPTCORE_JIT" = "yes" ] || [ "$CFG_JAVASCRIPTCORE_JIT" = "auto" ]; then 
     if [ "$CFG_ARCH" = "arm" ]; then
-       "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/javascriptcore-jit "javascriptcore-jit" $L_FLAGS $I_FLAGS $l_FLAGS
+       compileTest unix/javascriptcore-jit "javascriptcore-jit"
         if [ $? != "0" ]; then
            CFG_JAVASCRIPTCORE_JIT=no
         fi
@@ -4940,10 +5200,7 @@ fi
 # ask for all that hasn't been auto-detected or specified in the arguments
 #-------------------------------------------------------------------------------
 
-# ### Vestige
-if [ "$CFG_PHONON_BACKEND" = "yes" ]; then
-    QT_CONFIG="$QT_CONFIG phonon-backend"
-fi
+[ "$CFG_CXX11" = "yes" ] && QT_CONFIG="$QT_CONFIG c++11"
 
 # disable accessibility
 if [ "$CFG_ACCESSIBILITY" = "no" ]; then
@@ -4999,25 +5256,18 @@ if [ "$CFG_OPENGL" = "es2" ]; then
     QT_CONFIG="$QT_CONFIG opengles2"
 fi
 
-# safe execution environment
-if [ "$CFG_SXE" != "no" ]; then
-    QT_CONFIG="$QT_CONFIG sxe"
-fi
-
 # build up the variables for output
 if [ "$CFG_DEBUG" = "yes" ]; then
     QMAKE_OUTDIR="${QMAKE_OUTDIR}debug"
-    QMAKE_CONFIG="$QMAKE_CONFIG debug"
 elif [ "$CFG_DEBUG" = "no" ]; then
     QMAKE_OUTDIR="${QMAKE_OUTDIR}release"
-    QMAKE_CONFIG="$QMAKE_CONFIG release"
 fi
 if [ "$CFG_SHARED" = "yes" ]; then
     QMAKE_OUTDIR="${QMAKE_OUTDIR}-shared"
-    QMAKE_CONFIG="$QMAKE_CONFIG shared dll"
+    QT_CONFIG="$QT_CONFIG shared"
 elif [ "$CFG_SHARED" = "no" ]; then
     QMAKE_OUTDIR="${QMAKE_OUTDIR}-static"
-    QMAKE_CONFIG="$QMAKE_CONFIG static"
+    QT_CONFIG="$QT_CONFIG static"
 fi
 
 #FIXME: qpa is implicit this should all be removed
@@ -5043,6 +5293,7 @@ if [ "$CFG_USE_GNUMAKE" = "yes" ]; then
 fi
 [ "$CFG_REDUCE_EXPORTS" = "yes" ] && QT_CONFIG="$QT_CONFIG reduce_exports"
 [ "$CFG_REDUCE_RELOCATIONS" = "yes" ] && QT_CONFIG="$QT_CONFIG reduce_relocations"
+[ "$CFG_STRIP" = "no" ] && QMAKE_CONFIG="$QMAKE_CONFIG nostrip"
 [ "$CFG_PRECOMPILE" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG precompile_header"
 if [ "$CFG_SEPARATE_DEBUG_INFO" = "yes" ]; then
     QMakeVar add QMAKE_CFLAGS -g
@@ -5158,15 +5409,12 @@ fi
 [ "$CFG_XCB" = "yes" ] && QT_CONFIG="$QT_CONFIG xcb"
 [ "$CFG_XINPUT2" = "yes" ] && QT_CONFIG="$QT_CONFIG xinput2"
 
-[ '!' -z "$D_FLAGS" ] && QMakeVar add DEFINES "$D_FLAGS"
-[ '!' -z "$L_FLAGS" ] && QMakeVar add QMAKE_LIBDIR_FLAGS "$L_FLAGS"
-[ '!' -z "$l_FLAGS" ] && QMakeVar add LIBS "$l_FLAGS"
+[ '!' -z "$DEFINES" ] && QMakeVar add DEFINES "$DEFINES"
+[ '!' -z "$L_FLAGS" ] && QMakeVar add LIBS "$L_FLAGS"
 
 if [ "$PLATFORM_MAC" = "yes" ] && [ "$QT_CROSS_COMPILE" = "no" ]; then
     if [ "$CFG_RPATH" = "yes" ]; then
        QMAKE_CONFIG="$QMAKE_CONFIG absolute_library_soname"
-       # set the default rpath to the library installation directory
-       RPATH_FLAGS="\"$QT_INSTALL_LIBS\" $RPATH_FLAGS"
     fi
 elif [ -z "`getXQMakeConf 'QMAKE_(LFLAGS_)?RPATH'`" ]; then
     if [ -n "$RPATH_FLAGS" ]; then
@@ -5180,15 +5428,14 @@ elif [ -z "`getXQMakeConf 'QMAKE_(LFLAGS_)?RPATH'`" ]; then
         CFG_RPATH=no
     fi
 else
-    if [ "$CFG_RPATH" = "yes" ]; then
-        # set the default rpath to the library installation directory
-        RPATH_FLAGS="\"$QT_INSTALL_LIBS\" $RPATH_FLAGS"
-    fi
     if [ -n "$RPATH_FLAGS" ]; then
         # add the user defined rpaths
        QMakeVar add QMAKE_RPATHDIR "$RPATH_FLAGS"
     fi
 fi
+if [ "$CFG_RPATH" = "yes" ]; then
+    QT_CONFIG="$QT_CONFIG rpath"
+fi
 
 if [ '!' -z "$I_FLAGS" ]; then
     # add the user define include paths
@@ -5408,8 +5655,8 @@ if [ "$CFG_QML_DEBUG" = "no" ]; then
     QCONFIG_FLAGS="$QCONFIG_FLAGS QT_QML_NO_DEBUGGER"
 fi
 
-case "$COMPILER" in
-g++*)
+case "$QMAKE_CONF_COMPILER" in
+*g++*)
     # GNU C++
     COMPILER_VERSION=`${QMAKE_CONF_COMPILER} -dumpversion 2>/dev/null`
 
@@ -5463,6 +5710,16 @@ EOF
 echo '/* Compile time features */' >>"$outpath/src/corelib/global/qconfig.h.new"
 [ '!' -z "$LicenseKeyExt" ] && echo "#define QT_PRODUCT_LICENSEKEY \"$LicenseKeyExt\"" >>"$outpath/src/corelib/global/qconfig.h.new"
 
+if [ "$CFG_SHARED" = "no" ]; then
+    cat >>"$outpath/src/corelib/global/qconfig.h.new" <<EOF
+/* Qt was configured for a static build */
+#if !defined(QT_SHARED) && !defined(QT_STATIC)
+# define QT_STATIC
+#endif
+
+EOF
+fi
+
 if [ "$CFG_LARGEFILE" = "yes" ] && [ "$XPLATFORM_MINGW" != "yes" ]; then
     echo "#define QT_LARGEFILE_SUPPORT 64" >>"$outpath/src/corelib/global/qconfig.h.new"
 fi
@@ -5489,6 +5746,20 @@ if [ "$CFG_REDUCE_RELOCATIONS" = "yes" ]; then
     echo "#define QT_REDUCE_RELOCATIONS" >>"$outpath/src/corelib/global/qconfig.h.new"
 fi
 
+# Add compiler sub-architecture support
+echo "" >>"$outpath/src/corelib/global/qconfig.h.new"
+echo "// Compiler sub-arch support" >>"$outpath/src/corelib/global/qconfig.h.new"
+for SUBARCH in SSE2 SSE3 SSSE3 SSE4_1 SSE4_2 AVX AVX2 \
+    IWMMXT NEON \
+    MIPS_DSP MIPS_DSPR2; do
+    eval "VAL=\$CFG_$SUBARCH"
+    case "$VAL" in
+        yes)
+            echo "#define QT_COMPILER_SUPPORTS_$SUBARCH" \
+                >>"$outpath/src/corelib/global/qconfig.h.new"
+            ;;
+    esac
+done
 
 echo "" >>"$outpath/src/corelib/global/qconfig.h.new"
 
@@ -5497,7 +5768,7 @@ if [ "$CFG_DEV" = "yes" ]; then
 fi
 
 # Add QPA to config.h
-QCONFIG_FLAGS="$QCONFIG_FLAGS Q_WS_QPA QT_NO_QWS_QPF QT_NO_QWS_QPF2"
+QCONFIG_FLAGS="$QCONFIG_FLAGS"
 
 if [ "${CFG_USE_FLOATMATH}" = "yes" ]; then
     QCONFIG_FLAGS="${QCONFIG_FLAGS} QT_USE_MATH_H_FLOATS"
@@ -5518,7 +5789,6 @@ for DRIVER in $CFG_SQL_AVAILABLE; do
     esac
 done
 
-
 QMakeVar set sql-drivers "$SQL_DRIVERS"
 QMakeVar set sql-plugins "$SQL_PLUGINS"
 
@@ -5527,7 +5797,6 @@ QMakeVar set sql-plugins "$SQL_PLUGINS"
 [ "$CFG_PNG" != "yes" ]      && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_IMAGEFORMAT_PNG"
 [ "$CFG_JPEG" != "yes" ]     && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_IMAGEFORMAT_JPEG"
 [ "$CFG_ZLIB" != "yes" ]     && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_ZLIB"
-[ "$CFG_SXE" = "no" ]        && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SXE"
 [ "$CFG_DBUS" = "no" ]      && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_DBUS"
 
 # X11/Unix/Mac only configs
@@ -5678,6 +5947,10 @@ cat >>"$QTCONFIG.tmp" <<EOF
 CONFIG += $QTCONFIG_CONFIG
 QT_ARCH = $CFG_ARCH
 QT_HOST_ARCH = $CFG_HOST_ARCH
+QT_CPU_FEATURES = $CFG_CPUFEATURES
+QT_HOST_CPU_FEATURES = $CFG_HOST_CPUFEATURES
+QMAKE_DEFAULT_LIBDIRS = `echo "$DEFAULT_LIBDIRS" | sed 's,^,",;s,$,",' | tr '\n' ' '`
+QMAKE_DEFAULT_INCDIRS = `echo "$DEFAULT_INCDIRS" | sed 's,^,",;s,$,",' | tr '\n' ' '`
 QT_EDITION = $Edition
 QT_CONFIG += $QT_CONFIG
 
@@ -5697,12 +5970,12 @@ if [ -n "$PKG_CONFIG_SYSROOT_DIR" ] || [ -n "$PKG_CONFIG_LIBDIR" ]; then
     echo "# pkgconfig" >> "$QTCONFIG.tmp"
     echo "PKG_CONFIG_SYSROOT_DIR = $PKG_CONFIG_SYSROOT_DIR" >> "$QTCONFIG.tmp"
     echo "PKG_CONFIG_LIBDIR = $PKG_CONFIG_LIBDIR" >> "$QTCONFIG.tmp"
-    echo >> $"$QTCONFIG.tmp"
+    echo >> "$QTCONFIG.tmp"
 fi
 
-if [ -n "$CFG_SYSROOT" ]; then
+if [ -n "$CFG_SYSROOT" ] && [ "$CFG_GCC_SYSROOT" = "yes" ]; then
     echo "# sysroot" >>"$QTCONFIG.tmp"
-    echo `basename "$XQMAKESPEC"` \{ >>"$QTCONFIG.tmp"
+    echo "!host_build {" >>"$QTCONFIG.tmp"
     echo "    QMAKE_CFLAGS    += --sysroot=\$\$[QT_SYSROOT]" >>"$QTCONFIG.tmp"
     echo "    QMAKE_CXXFLAGS  += --sysroot=\$\$[QT_SYSROOT]" >>"$QTCONFIG.tmp"
     echo "    QMAKE_LFLAGS    += --sysroot=\$\$[QT_SYSROOT]" >>"$QTCONFIG.tmp"
@@ -5720,7 +5993,7 @@ fi
 
 if [ -n "$QMAKE_INCDIR_OPENGL_ES2" ]; then
     echo "#Qt opengl include path" >> "$QTCONFIG.tmp"
-    echo "QMAKE_INCDIR_OPENGL_ES2 = \"$QMAKE_INCDIR_OPENGL_ES2\"" >> "$QTCONFIG.tmp"
+    echo "QMAKE_INCDIR_OPENGL_ES2 = `shellArgumentListToQMakeList "$QMAKE_INCDIR_OPENGL_ES2"`" >> "$QTCONFIG.tmp"
 fi
 
 # replace qconfig.pri if it differs from the newly created temp file
@@ -5735,12 +6008,9 @@ fi
 #-------------------------------------------------------------------------------
 QTMODULE="$outpath/mkspecs/qmodule.pri"
 
-echo "CONFIG += create_prl link_prl" >> "$QTMODULE.tmp"
+echo "CONFIG += $QMAKE_CONFIG create_prl link_prl" >> "$QTMODULE.tmp"
+echo "QT_BUILD_PARTS += $CFG_BUILD_PARTS" >> "$QTMODULE.tmp"
 
-# Ensure we can link to uninistalled libraries
-if [ "$BUILD_ON_MAC" != "yes" ] && [ "$XPLATFORM_MINGW" != "yes" ] && linkerSupportsFlag -rpath-link "$outpath/lib"; then
-    echo "QMAKE_LFLAGS    = -Wl,-rpath-link,\$\$QT_BUILD_TREE/lib \$\$QMAKE_LFLAGS" >> "$QTMODULE.tmp"
-fi
 if [ -n "$QT_CFLAGS_PSQL" ]; then
     echo "QT_CFLAGS_PSQL   = $QT_CFLAGS_PSQL" >> "$QTMODULE.tmp"
 fi
@@ -5803,24 +6073,12 @@ cat >>"$CACHEFILE.tmp" <<EOF
 #paths
 QT_SOURCE_TREE = \$\$quote($relpath)
 QT_BUILD_TREE = \$\$quote($outpath)
-QT_BUILD_PARTS = $CFG_BUILD_PARTS
-
-#local paths that cannot be queried from the QT_INSTALL_* properties while building QTDIR
-QMAKE_INCDIR_QT  = \$\$QT_BUILD_TREE/include
-QMAKE_LIBDIR_QT  = \$\$QT_BUILD_TREE/lib
 
 include(\$\$PWD/mkspecs/qmodule.pri)
-CONFIG += $QMAKE_CONFIG dylib depend_includepath fix_output_dirs no_private_qt_headers_warning QTDIR_build
+CONFIG += dylib fix_output_dirs no_private_qt_headers_warning QTDIR_build
 
 EOF
 
-#dump the qmake spec
-if [ -d "$outpath/mkspecs/$XPLATFORM" ]; then
-   echo "QMAKESPEC = \$\$QT_BUILD_TREE/mkspecs/$XPLATFORM" >> "$CACHEFILE.tmp"
-else
-   echo "QMAKESPEC = $XPLATFORM" >> "$CACHEFILE.tmp"
-fi
-
 # replace .qmake.cache if it differs from the newly created temp file
 if cmp -s "$CACHEFILE.tmp" "$CACHEFILE"; then
     rm -f "$CACHEFILE.tmp"
@@ -5841,8 +6099,9 @@ else
     echo "Building for:  $XPLATFORM"
 fi
 
-echo "Architecture:  $CFG_ARCH"
-echo "Host architecture: $CFG_HOST_ARCH"
+# the missing space before $CFG_FEATURES is intentional
+echo "Architecture:  $CFG_ARCH, features:$CFG_CPUFEATURES"
+echo "Host architecture: $CFG_HOST_ARCH, features:$CFG_HOST_CPUFEATURES"
 
 if [ -n "$PLATFORM_NOTES" ]; then
     echo "Platform notes:"
@@ -5869,6 +6128,10 @@ if [ "$CFG_DEBUG_RELEASE" = "yes" ]; then
 else
    echo "Debug .................. $CFG_DEBUG"
 fi
+if [ "$CFG_RELEASE" = "yes" ] || [ "$CFG_DEBUG_RELEASE" = "yes" ]; then
+    echo "Force debug info ....... $CFG_FORCEDEBUGINFO"
+fi
+echo "C++11 support .......... $CFG_CXX11"
 if [ -n "$PKG_CONFIG" ]; then
     echo "pkg-config ............. yes"
 else
@@ -5948,6 +6211,7 @@ echo "Xcursor support ........ $CFG_XCURSOR"
 echo "Xfixes support ......... $CFG_XFIXES"
 echo "Xrandr support ......... $CFG_XRANDR"
 echo "Xi support ............. $CFG_XINPUT"
+echo "Xi2 support ............ $CFG_XINPUT2"
 echo "MIT-SHM support ........ $CFG_MITSHM"
 echo "FontConfig support ..... $CFG_FONTCONFIG"
 echo "XKB Support ............ $CFG_XKB"
@@ -5988,6 +6252,8 @@ if [ "$XPLATFORM_MAEMO" = "yes" ] && [ "$CFG_XCB" = "yes" ]; then
 fi
 echo "EGLFS support .......... $CFG_EGLFS"
 echo "DirectFB support ....... $CFG_DIRECTFB"
+echo "LinuxFB support ........ $CFG_LINUXFB"
+echo "KMS support ............ $CFG_KMS"
 echo
 
 # complain about not being able to use dynamic plugins if we are using a static build
@@ -6027,231 +6293,53 @@ EXEC=""
 # build makefiles based on the configuration
 #-------------------------------------------------------------------------------
 
-echo "Finding project files. Please wait..."
-if [ "$CFG_NOPROCESS" != "yes" ]; then
-    "$outpath/bin/qmake" -prl -r "${relpath}/qtbase.pro"
-    if [ -f "${relpath}/qtbase.pro" ]; then
-        mkfile="${outpath}/Makefile"
-        [ -f "$mkfile" ] && chmod +w "$mkfile"
-        QTDIR="$outpath" "$outpath/bin/qmake" -spec "$XQMAKESPEC" "${relpath}/qtbase.pro" -o "$mkfile"
-    fi
-fi
-
-# .projects      -> projects to process
-# .projects.1    -> qt and moc
-# .projects.2    -> subdirs and libs
-# .projects.3    -> the rest
-rm -f .projects .projects.1 .projects.2 .projects.3
-
-QMAKE_PROJECTS=`find "$relpath/." -name '*.pro' -print | sed 's-/\./-/-'`
-if [ -z "$AWK" ]; then
-    for p in `echo $QMAKE_PROJECTS`; do
-        echo "$p" >> .projects
-    done
-else
-    cat >projects.awk <<EOF
-BEGIN {
-    files = 0
-    target_file = ""
-    input_file = ""
-
-    first = "./.projects.1.tmp"
-    second = "./.projects.2.tmp"
-    third = "./.projects.3.tmp"
-}
-
-FNR == 1 {
-    if ( input_file ) {
-        if ( ! target_file )
-            target_file = third
-        print input_file >target_file
-    }
-
-    matched_target = 0
-    template_lib = 0
-    input_file = FILENAME
-    target_file = ""
-}
-
-/^(TARGET.*=)/ {
-    if ( \$3 == "moc" || \$3 ~ /^Qt/ ) {
-        target_file = first
-        matched_target = 1
-    } else if ( \$3 == "lrelease" || \$3 == "qm_phony_target" ) {
-        target_file = second
-        matched_target = 1
-    }
-}
-
-matched_target == 0 && /^(TEMPLATE.*=)/ {
-    if ( \$3 == "subdirs" )
-        target_file = second
-    else if ( \$3 == "lib" )
-        template_lib = 1
-    else
-        target_file = third
-}
+if [ "$CFG_PROCESS" != "no" ]; then
 
-matched_target == 0 && template_lib == 1 && /^(CONFIG.*=)/ {
-    if ( \$0 ~ /plugin/ )
-        target_file = third
+    if [ "$CFG_PROCESS" = "full" ]; then
+        echo "Creating makefiles. Please wait..."
+        "$outpath/bin/qmake" -r "$relpath"
+        echo "Done"
     else
-        target_file = second
-}
-
-END {
-    if ( input_file ) {
-        if ( ! target_file )
-            target_file = third
-        print input_file >>target_file
-    }
-}
-
-EOF
-
-    rm -f .projects.all
-    for p in `echo $QMAKE_PROJECTS`; do
-       echo "$p" >> .projects.all
-    done
-
-    # if you get errors about the length of the command line to awk, change the -l arg
-    # to split below
-    split -l 100 .projects.all .projects.all.
-    for p in .projects.all.*; do
-       "$AWK" -f projects.awk `cat $p`
-       [ -f .projects.1.tmp ] && cat .projects.1.tmp >> .projects.1
-       [ -f .projects.2.tmp ] && cat .projects.2.tmp >> .projects.2
-       [ -f .projects.3.tmp ] && cat .projects.3.tmp >> .projects.3
-       rm -f .projects.1.tmp .projects.2.tmp .projects.3.tmp $p
-    done
-    rm -f .projects.all* projects.awk
-
-    [ -f .projects.1 ] && cat .projects.1 >>.projects
-    [ -f .projects.2 ] && cat .projects.2 >>.projects
-    rm -f .projects.1 .projects.2
-    if [ -f .projects.3 ] && [ "$OPT_FAST" = "no" ]; then
-       cat .projects.3 >>.projects
-       rm -f .projects.3
-    fi
-fi
-# don't sort Qt and MOC in with the other project files
-# also work around a segfaulting uniq(1)
-if [ -f .sorted.projects.2 ]; then
-    sort .sorted.projects.2 > .sorted.projects.2.new
-    mv -f .sorted.projects.2.new .sorted.projects.2
-    cat .sorted.projects.2 >> .sorted.projects.1
-fi
-[ -f .sorted.projects.1 ] && sort .sorted.projects.1 >> .sorted.projects
-rm -f .sorted.projects.2 .sorted.projects.1
-
-NORM_PROJECTS=0
-FAST_PROJECTS=0
-if [ -f .projects ]; then
-   uniq .projects >.tmp
-   mv -f .tmp .projects
-   NORM_PROJECTS=`cat .projects | wc -l | sed -e "s, ,,g"`
-fi
-if [ -f .projects.3 ]; then
-   uniq .projects.3 >.tmp
-   mv -f .tmp .projects.3
-   FAST_PROJECTS=`cat .projects.3 | wc -l | sed -e "s, ,,g"`
-fi
-echo "  `expr $NORM_PROJECTS + $FAST_PROJECTS` projects found."
-echo
-
-PART_ROOTS=
-for part in $CFG_BUILD_PARTS; do
-    case "$part" in
-    tools) PART_ROOTS="$PART_ROOTS tools" ;;
-    libs) PART_ROOTS="$PART_ROOTS src" ;;
-    translations) PART_ROOTS="$PART_ROOTS translations" ;;
-    examples) PART_ROOTS="$PART_ROOTS examples" ;;
-    *) ;;
-    esac
-done
-
-if [ "$CFG_DEV" = "yes" ]; then
-    PART_ROOTS="$PART_ROOTS tests"
-fi
-
-echo "Creating makefiles. Please wait..."
-for file in .projects .projects.3; do
-    [ '!' -f "$file" ] && continue
-    for a in `cat $file`; do
-        IN_ROOT=no
-       for r in $PART_ROOTS; do
-           if echo "$a" | grep "^$r" >/dev/null 2>&1 || echo "$a" | grep "^$relpath/$r" >/dev/null 2>&1; then
-               IN_ROOT=yes
-               break
-            fi
-       done
-        [ "$IN_ROOT" = "no" ] && continue
+        "$outpath/bin/qmake" "$relpath"
+    fi
 
-        case $a in
-        *winmain/winmain.pro)
-            if [ "$CFG_NOPROCESS" = "yes" ] || [ "$XPLATFORM_MINGW" != "yes" ]; then
-                continue
-            fi
-            SPEC=$XQMAKESPEC ;;
-        */qmake/qmake.pro) continue ;;
-        *tools/bootstrap*|*tools/moc*|*tools/rcc*|*tools/uic*|*tools/qdoc*|*tools/qdbusxml2cpp*|*tools/qdbuscpp2xml*) SPEC=$QMAKESPEC ;;
-        *) if [ "$CFG_NOPROCESS" = "yes" ]; then
-              continue
-           else
-              SPEC=$XQMAKESPEC
-           fi;;
-        esac
-        dir=`dirname "$a" | sed -e "s;$sepath;.;g"`
-        test -d "$dir" || mkdir -p "$dir"
-        OUTDIR="$outpath/$dir"
-        if [ -f "${OUTDIR}/Makefile" ] && [ "$OPT_FAST" = "yes" ]; then
-            # fast configure - the makefile exists, skip it
-            # since the makefile exists, it was generated by qmake, which means we
-            # can skip it, since qmake has a rule to regenerate the makefile if the .pro
-            # file changes...
-            [ "$OPT_VERBOSE" = "yes" ] && echo "  skipping $a"
-            continue;
-        fi
-        QMAKE_SPEC_ARGS="-spec $SPEC"
-        echo $ECHO_N "  for $a$ECHO_C"
-
-        QMAKE="$outpath/bin/qmake"
-       QMAKE_ARGS="$QMAKE_SWITCHES $QMAKE_SPEC_ARGS"
-        if [ "$file" = ".projects.3" ]; then
-            echo " (fast)"
-
-            cat >"${OUTDIR}/Makefile" <<EOF
-# ${OUTDIR}/Makefile: generated by configure
+    if [ "$OPT_FAST" = "yes" ]; then
+        PART_ROOTS=
+        for part in $CFG_BUILD_PARTS; do
+            case "$part" in
+            examples|tests) PART_ROOTS="$PART_ROOTS $part" ;;
+            esac
+        done
+        if [ "x$PART_ROOTS" != "x" ]; then
+            echo
+            echo "Creating stub makefiles. Please wait..."
+            QMAKE="$outpath/bin/qmake"
+            [ "$CFG_DEBUG_RELEASE" = "no" ] && first_tgt="first_target: first" || first_tgt=
+            (cd "$relpath" && find $PART_ROOTS -name '*.pro') | grep -v /testdata/ | while read p; do
+                d=${p%/*}
+                test -f "$outpath/$d/Makefile" && continue
+                echo "  for $relpath/$p"
+
+                mkdir -p "$outpath/$d" || exit
+                cat > "$outpath/$d/Makefile" <<EOF || exit
+# $outpath/$d/Makefile: generated by configure
 #
 # WARNING: This makefile will be replaced with a real makefile.
 # All changes made to this file will be lost.
-EOF
-            [ "$CFG_DEBUG_RELEASE" = "no" ] && echo "first_target: first" >>${OUTDIR}/Makefile
 
-            cat >>"${OUTDIR}/Makefile" <<EOF
 QMAKE = "$QMAKE"
+
+$first_tgt
 all clean install qmake first Makefile: FORCE
-       \$(QMAKE) $QMAKE_ARGS -o "$OUTDIR" "$a"
-       cd "$OUTDIR"
+       \$(QMAKE) $QMAKE_SWITCHES "$relpath/$p"
        \$(MAKE) \$@
-
 FORCE:
-
 EOF
-        else
-            if [ "$OPT_VERBOSE" = "yes" ]; then
-                echo " (`basename $SPEC`)"
-                echo "$QMAKE" $QMAKE_ARGS -o "$OUTDIR" "$a"
-           else
-               echo
-            fi
-
-            [ -f "${OUTDIR}/Makefile" ] && chmod +w "${OUTDIR}/Makefile"
-            QTDIR="$outpath" "$QMAKE" $QMAKE_ARGS -o "$OUTDIR" "$a"
-       fi
-    done
-done
-rm -f .projects .projects.3
+            done || exit
+            echo "Done"
+        fi
+    fi
+fi
 
 #-------------------------------------------------------------------------------
 # check for platforms that we don't yet know about