diff --git a/configure b/configure
index 7aa8adaa439508614be8e6cb22e1e959d7b5cd5e..de65cdc7bc1f15caffadccd638fc4fe6b729c8b4 100755
--- a/configure
+++ b/configure
@@ -825,7 +825,10 @@ QT_INSTALL_TRANSLATIONS=
 QT_INSTALL_SETTINGS=
 QT_INSTALL_EXAMPLES=
 QT_INSTALL_TESTS=
+CFG_SYSROOT=
 QT_HOST_PREFIX=
+QT_HOST_BINS=
+QT_HOST_DATA=
 
 #flags for SQL drivers
 QT_CFLAGS_PSQL=
@@ -978,7 +981,7 @@ while [ "$#" -gt 0 ]; do
         shift
         VAL=$1
         ;;
-    -prefix|-docdir|-headerdir|-plugindir|-importdir|-datadir|-libdir|-bindir|-translationdir|-sysconfdir|-examplesdir|-testsdir|-depths|-make|-nomake|-platform|-xplatform|-sdk|-arch|-host-arch|-mysql_config|-sysroot)
+    -prefix|-docdir|-headerdir|-plugindir|-importdir|-datadir|-libdir|-bindir|-translationdir|-sysconfdir|-examplesdir|-testsdir|-depths|-make|-nomake|-platform|-xplatform|-sdk|-arch|-host-arch|-mysql_config|-sysroot|-hostdatadir|-hostbindir)
         VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
         shift
         VAL="$1"
@@ -1169,6 +1172,12 @@ while [ "$#" -gt 0 ]; do
     hostprefix)
 	QT_HOST_PREFIX="$VAL"
 	;;
+    hostdatadir)
+        QT_HOST_DATA="$VAL"
+        ;;
+    hostbindir)
+        QT_HOST_BINS="$VAL"
+        ;;
     force-pkg-config)
         QT_FORCE_PKGCONFIG=yes
         ;;
@@ -3116,6 +3125,40 @@ if [ -z "$QT_INSTALL_TESTS" ]; then #default
 fi
 QT_INSTALL_TESTS=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_TESTS"`
 
+#------- host paths --------
+
+if [ -z "$QT_HOST_PREFIX" ]; then
+    QT_HOST_PREFIX=$QT_INSTALL_PREFIX
+    haveHpx=false
+else
+    QT_HOST_PREFIX=`"$relpath/config.tests/unix/makeabs" "$QT_HOST_PREFIX"`
+    haveHpx=true
+fi
+
+if [ -z "$QT_HOST_BINS" ]; then #default
+    if $haveHpx; then
+        if [ "$CFG_PREFIX_INSTALL" = "no" ]; then
+            if [ "$BUILD_ON_MAC" = "yes" ]; then
+                QT_HOST_BINS="/Developer/Applications/Qt"
+            fi
+        fi
+        [ -z "$QT_HOST_BINS" ] && QT_HOST_BINS="$QT_HOST_PREFIX/bin" #fallback
+    else
+        QT_HOST_BINS="$QT_INSTALL_BINS"
+    fi
+fi
+QT_HOST_BINS=`"$relpath/config.tests/unix/makeabs" "$QT_HOST_BINS"`
+
+if [ -z "$QT_HOST_DATA" ]; then #default
+    if $haveHpx; then
+        QT_HOST_DATA="$QT_HOST_PREFIX"
+    else
+        QT_HOST_DATA="$QT_INSTALL_DATA"
+    fi
+else
+    QT_HOST_DATA=`"$relpath/config.tests/unix/makeabs" "$QT_HOST_DATA"`
+fi
+
 #-------------------------------------------------------------------------------
 # help - interactive parts of the script _after_ this section please
 #-------------------------------------------------------------------------------
@@ -3233,6 +3276,7 @@ cat <<EOF
     -hostprefix [dir] .. Tools and libraries needed when developing
                          applications are installed in [dir]. If [dir] is
                          not given, the current build directory will be used.
+                         (default PREFIX)
 EOF
 fi
 cat <<EOF
@@ -3269,6 +3313,17 @@ cat <<EOF
                             (default PREFIX/examples)
     -testsdir <dir> ....... Tests will be installed to <dir>
                             (default PREFIX/tests)
+EOF
+if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then
+cat <<EOF
+
+    -hostbindir <dir> .. Host executables will be installed to <dir>
+                         (default HOSTPREFIX/bin)
+    -hostdatadir <dir> . Data used by qmake will be installed to <dir>
+                         (default HOSTPREFIX)
+EOF
+fi
+cat <<EOF
 
 Configure options:
 
@@ -3987,33 +4042,7 @@ static const char qt_configure_licensed_products_str [256 + 12] = "qt_lcnsprod=$
 
 /* Installation date */
 static const char qt_configure_installation          [12+11]    = "qt_instdate=`date +%Y-%m-%d`";
-EOF
 
-
-if [ ! -z "$QT_HOST_PREFIX" ]; then
-    cat >> "$outpath/src/corelib/global/qconfig.cpp.new" <<EOF
-
-#if defined(QT_BOOTSTRAPPED) || defined(QT_BUILD_QMAKE)
-/* Installation Info */
-static const char qt_configure_prefix_path_strs[][256 + 12] = {
-    "qt_prfxpath=$QT_HOST_PREFIX",
-    "qt_docspath=$QT_HOST_PREFIX/doc",
-    "qt_hdrspath=$QT_HOST_PREFIX/include",
-    "qt_libspath=$QT_HOST_PREFIX/lib",
-    "qt_binspath=$QT_HOST_PREFIX/bin",
-    "qt_plugpath=$QT_HOST_PREFIX/plugins",
-    "qt_impspath=$QT_HOST_PREFIX/IMPORTS",
-    "qt_datapath=$QT_HOST_PREFIX",
-    "qt_trnspath=$QT_HOST_PREFIX/translations",
-    "qt_xmplpath=$QT_INSTALL_EXAMPLES",
-    "qt_tstspath=$QT_INSTALL_TESTS",
-};
-static const char qt_configure_settings_path_str[256 + 12] = "qt_stngpath=$QT_INSTALL_SETTINGS";
-#else // QT_BOOTSTRAPPED
-EOF
-fi
-
-cat >> "$outpath/src/corelib/global/qconfig.cpp.new" <<EOF
 /* Installation Info */
 static const char qt_configure_prefix_path_strs[][256 + 12] = {
     "qt_prfxpath=$QT_INSTALL_PREFIX",
@@ -4027,17 +4056,16 @@ static const char qt_configure_prefix_path_strs[][256 + 12] = {
     "qt_trnspath=$QT_INSTALL_TRANSLATIONS",
     "qt_xmplpath=$QT_INSTALL_EXAMPLES",
     "qt_tstspath=$QT_INSTALL_TESTS",
+#ifdef QT_BUILD_QMAKE
+    "qt_ssrtpath=$CFG_SYSROOT",
+    "qt_hpfxpath=$QT_HOST_PREFIX",
+    "qt_hbinpath=$QT_HOST_BINS",
+    "qt_hdatpath=$QT_HOST_DATA",
+#endif
 };
 static const char qt_configure_settings_path_str[256 + 12] = "qt_stngpath=$QT_INSTALL_SETTINGS";
 EOF
 
-if [ ! -z "$QT_HOST_PREFIX" ]; then
-    cat >> "$outpath/src/corelib/global/qconfig.cpp.new" <<EOF
-#endif // QT_BOOTSTRAPPED
-
-EOF
-fi
-
 cat >> "$outpath/src/corelib/global/qconfig.cpp.new" <<EOF
 
 /* strlen( "qt_lcnsxxxx" ) == 12 */
@@ -6781,10 +6809,9 @@ EOF
 if [ -n "$CFG_SYSROOT" ]; then
     echo "# sysroot" >>"$QTCONFIG.tmp"
     echo `basename "$XQMAKESPEC"` \{ >>"$QTCONFIG.tmp"
-    echo "  QT_SYSROOT      += \$\$quote($CFG_SYSROOT)" >>"$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"
+    echo "    QMAKE_CFLAGS    += --sysroot=\$\$[QT_SYSROOT]" >>"$QTCONFIG.tmp"
+    echo "    QMAKE_CXXFLAGS  += --sysroot=\$\$[QT_SYSROOT]" >>"$QTCONFIG.tmp"
+    echo "    QMAKE_LFLAGS    += --sysroot=\$\$[QT_SYSROOT]" >>"$QTCONFIG.tmp"
     echo "}" >> "$QTCONFIG.tmp"
     echo >> "$QTCONFIG.tmp"
 fi
diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0
index e1f1f07203611cc84f30d648ccbc385d4ba23452..ca9047b6823106397ba48d6c7b568310e28626f3 100644
--- a/dist/changes-5.0.0
+++ b/dist/changes-5.0.0
@@ -202,7 +202,11 @@ information about a particular change.
 
 - qmake
   * Projects which explicitly set an empty TARGET are considered broken now.
-  * several functions and built-in variables were modified to return normalized paths.
+  * Configure's -sysroot and -hostprefix are now handled slightly differently.
+    The QT_INSTALL_... properties are now automatically prefixed with the sysroot;
+    the raw values are available as QT_RAW_INSTALL_... and the sysroot as QT_SYSROOT.
+    The new QT_HOST_... properties can be used to refer to the Qt host tools.
+  * Several functions and built-in variables were modified to return normalized paths.
 
 - QTextCodecPlugin has been removed since it is no longer used. All text codecs
   are now built into QtCore.
diff --git a/mkspecs/features/default_pre.prf b/mkspecs/features/default_pre.prf
index 1a56787d1587e17ea47340352d569f87928beb7e..aa706393a53db71eda0509054161c508a77ae177 100644
--- a/mkspecs/features/default_pre.prf
+++ b/mkspecs/features/default_pre.prf
@@ -26,10 +26,10 @@ CONFIG = lex yacc warn_on debug uic resources $$CONFIG
         # can we tell syncqt to do a -developer-build
         win32 {
             CMP_QDIR = $$upper($$QTDIR)
-            CMP_INSTALL_PREFIX = $$upper($$[QT_INSTALL_PREFIX])
+            CMP_INSTALL_PREFIX = $$upper($$[QT_HOST_PREFIX])
         } else {
             CMP_QDIR = $$QTDIR
-            CMP_INSTALL_PREFIX = $$[QT_INSTALL_PREFIX]
+            CMP_INSTALL_PREFIX = $$[QT_HOST_PREFIX]
         }
         contains(CMP_QDIR, $$CMP_INSTALL_PREFIX):QTFWD = -qtdir $$QTDIR -module-fwd $$QTDIR/mkspecs/modules -developer-build
         unset(CMP_QDIR)
diff --git a/mkspecs/features/module.prf b/mkspecs/features/module.prf
index 85639f03450fc664c42aa21ba0c728a5251aefe2..d95c7a418d6a70a858a5abbf91fa33f6fc57a7d9 100644
--- a/mkspecs/features/module.prf
+++ b/mkspecs/features/module.prf
@@ -1,5 +1,5 @@
 !isEmpty(MODULE_PRI) {
-    pritarget.path = $$[QT_INSTALL_DATA]/mkspecs/modules
+    pritarget.path = $$[QT_HOST_DATA]/mkspecs/modules
     pritarget.files = $$MODULE_PRI
     INSTALLS += pritarget
 } else {
diff --git a/mkspecs/features/qt_config.prf b/mkspecs/features/qt_config.prf
index 844172881594ee6c1ebf07a39b3132ddd697a318..8d0dcce92c06c8ee0312845cdc88a62e11c08ac4 100644
--- a/mkspecs/features/qt_config.prf
+++ b/mkspecs/features/qt_config.prf
@@ -8,7 +8,7 @@ exists($$_QMAKE_CACHE_) {
 isEmpty(QMAKE_QT_CONFIG)|!exists($$QMAKE_QT_CONFIG) {
    !isEmpty(QT_BUILD_TREE):QMAKE_QT_CONFIG = $$QT_BUILD_TREE
    else:exists($$_QMAKE_CACHE_):QMAKE_QT_CONFIG = $$fromfile($$_QMAKE_CACHE_, QT_BUILD_TREE)
-   isEmpty(QMAKE_QT_CONFIG):QMAKE_QT_CONFIG = $$[QT_INSTALL_DATA]
+   isEmpty(QMAKE_QT_CONFIG):QMAKE_QT_CONFIG = $$[QT_HOST_DATA]
    QMAKE_QT_CONFIG = $$QMAKE_QT_CONFIG/mkspecs/qconfig.pri
 }
 !exists($$QMAKE_QT_CONFIG)|!include($$QMAKE_QT_CONFIG, "", true) {
diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf
index 65eec35bfc4167e5e58fda6350779373fbcd5358..31b28156e83e36f925a0ff5cee2c9c3bde6a645b 100644
--- a/mkspecs/features/qt_functions.prf
+++ b/mkspecs/features/qt_functions.prf
@@ -132,7 +132,7 @@ defineTest(qtAddModule) {
 
     isEmpty(LINKAGE) {
        # Make sure we can link to uninstalled libraries
-       !isEqual(MODULE_LIBS, $$[QT_INSTALL_LIBS]) {
+       !isEqual(MODULE_LIBS, $$[QT_INSTALL_LIBS]) { ### XXX
            QMAKE_LIBDIR *= $$MODULE_LIBS
            unix:!mac:QMAKE_LFLAGS *= "-Wl,-rpath-link,$$MODULE_LIBS"
        }
@@ -164,7 +164,7 @@ defineTest(qtAddModule) {
 
 # variable, default
 defineTest(qtPrepareTool) {
-    MODBASE = $$[QT_INSTALL_BINS]
+    MODBASE = $$[QT_HOST_BINS]
     !isEmpty(QT_BUILD_TREE):MODBASE = $$QT_BUILD_TREE/bin
     count(ARGS, 2, greaterThan) {
         isEmpty(QT.$${3}.bins):warning("No QT.$${3}.bins, module path ignored for qtPrepareTool($$1, $$2, $$3)")
diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf
index aee95295e8292e70eb6fa94c8d1c954434ffd8d1..b71ef612525a28325f0fb673d66dc9149d516bb9 100644
--- a/mkspecs/features/qt_module.prf
+++ b/mkspecs/features/qt_module.prf
@@ -8,7 +8,7 @@ isEmpty(QMAKE_QT_MODULE)|!exists($$QMAKE_QT_MODULE) {
    !exists($$QMAKE_QT_MODULE):exists($$QMAKE_CACHE_DIR/mkspecs/qmodule.pri):QMAKE_QT_MODULE = $$QMAKE_CACHE_DIR/mkspecs/qmodule.pri
    !exists($$QMAKE_QT_MODULE):exists($$QMAKE_CACHE_DIR/qtbase/mkspecs/qmodule.pri):QMAKE_QT_MODULE = $$QMAKE_CACHE_DIR/qtbase/mkspecs/qmodule.pri
    !exists($$QMAKE_QT_MODULE):if(!isEmpty(QT_BUILD_TREE) & exists($$QT_BUILD_TREE/mkspecs/qmodule.pri)):QMAKE_QT_MODULE = $$QT_BUILD_TREE/mkspecs/qmodule.pri
-   !exists($$QMAKE_QT_MODULE):exists($$[QT_INSTALL_DATA]/mkspecs/qmodule.pri):QMAKE_QT_MODULE = $$[QT_INSTALL_DATA]/mkspecs/qmodule.pri
+   !exists($$QMAKE_QT_MODULE):exists($$[QT_HOST_DATA]/mkspecs/qmodule.pri):QMAKE_QT_MODULE = $$[QT_HOST_DATA]/mkspecs/qmodule.pri
 }
 
 !contains(QMAKE_INTERNAL_INCLUDED_FILES, .*qmodule\\.pri) {
diff --git a/mkspecs/features/qt_module_config.prf b/mkspecs/features/qt_module_config.prf
index a8439198dfa59a7e6d165a5ee18cc63c2f198420..ad6990657b54fc20deddc600f0182ddda44deda9 100644
--- a/mkspecs/features/qt_module_config.prf
+++ b/mkspecs/features/qt_module_config.prf
@@ -118,18 +118,18 @@ load(qt_installs)
 
 unix {
    CONFIG     += create_libtool create_pc explicitlib
-   QMAKE_LIBTOOL_LIBDIR = $$[QT_INSTALL_LIBS]
-   QMAKE_PRL_LIBDIR = $$[QT_INSTALL_LIBS]
-   QMAKE_PKGCONFIG_LIBDIR = $$[QT_INSTALL_LIBS]
-   QMAKE_PKGCONFIG_INCDIR = $$[QT_INSTALL_HEADERS]/$$TARGET
-   QMAKE_PKGCONFIG_CFLAGS = -I$$[QT_INSTALL_HEADERS]
+   QMAKE_LIBTOOL_LIBDIR = $$[QT_RAW_INSTALL_LIBS]
+   QMAKE_PRL_LIBDIR = $$[QT_RAW_INSTALL_LIBS] ### XXX
+   QMAKE_PKGCONFIG_LIBDIR = $$[QT_RAW_INSTALL_LIBS]
+   QMAKE_PKGCONFIG_INCDIR = $$[QT_RAW_INSTALL_HEADERS]/$$TARGET
+   QMAKE_PKGCONFIG_CFLAGS = -I$$[QT_RAW_INSTALL_HEADERS]
    QMAKE_PKGCONFIG_DESTDIR = pkgconfig
    include_replace.match = $$QMAKE_INCDIR_QT
-   include_replace.replace = $$[QT_INSTALL_HEADERS]
+   include_replace.replace = $$[QT_RAW_INSTALL_HEADERS]
    lib_replace.match = $$QMAKE_LIBDIR_QT
-   lib_replace.replace = $$[QT_INSTALL_LIBS]
+   lib_replace.replace = $$[QT_RAW_INSTALL_LIBS]
    prefix_replace.match = $$QT_BUILD_TREE
-   prefix_replace.replace = $$[QT_INSTALL_PREFIX]
+   prefix_replace.replace = $$[QT_RAW_INSTALL_PREFIX]
    QMAKE_PRL_INSTALL_REPLACE += include_replace lib_replace
    QMAKE_LIBTOOL_INSTALL_REPLACE += include_replace lib_replace
    QMAKE_PKGCONFIG_INSTALL_REPLACE += include_replace lib_replace prefix_replace
@@ -137,9 +137,9 @@ unix {
 
 win32-g++* {
    CONFIG += create_pc
-   QMAKE_PKGCONFIG_LIBDIR = $$[QT_INSTALL_LIBS]
-   QMAKE_PKGCONFIG_INCDIR = $$[QT_INSTALL_HEADERS]/$$TARGET
-   QMAKE_PKGCONFIG_CFLAGS = -I$$[QT_INSTALL_HEADERS]
+   QMAKE_PKGCONFIG_LIBDIR = $$[QT_RAW_INSTALL_LIBS]
+   QMAKE_PKGCONFIG_INCDIR = $$[QT_RAW_INSTALL_HEADERS]/$$TARGET
+   QMAKE_PKGCONFIG_CFLAGS = -I$$[QT_RAW_INSTALL_HEADERS]
    QMAKE_PKGCONFIG_DESTDIR = pkgconfig
 }
 
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index 59a615e63ad9f0c540a9a786a9c10098bcd2b839..45cb250fe16ef742994801f15c481150c348fb9b 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -3178,7 +3178,7 @@ MakefileGenerator::pkgConfigPrefix() const
 {
     if(!project->isEmpty("QMAKE_PKGCONFIG_PREFIX"))
         return project->first("QMAKE_PKGCONFIG_PREFIX");
-    return QLibraryInfo::location(QLibraryInfo::PrefixPath);
+    return QLibraryInfo::rawLocation(QLibraryInfo::PrefixPath);
 }
 
 QString
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index 109b50fd940e30c2b80ef0fdf3975f07a9300c1f..434d4b4559251c883c6f1684fa95e4b7ff890206 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -1575,11 +1575,11 @@ QString VcprojGenerator::findTemplate(QString file)
     QString ret;
     if(!exists((ret = file)) &&
        !exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) &&
-       !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc.net/" + file))) &&
-       !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc2002/" + file))) &&
-       !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc2003/" + file))) &&
-       !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc2005/" + file))) &&
-       !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc2008/" + file))))
+       !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::HostDataPath) + "/win32-msvc.net/" + file))) &&
+       !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::HostDataPath) + "/win32-msvc2002/" + file))) &&
+       !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::HostDataPath) + "/win32-msvc2003/" + file))) &&
+       !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::HostDataPath) + "/win32-msvc2005/" + file))) &&
+       !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::HostDataPath) + "/win32-msvc2008/" + file))))
         return "";
     debug_msg(1, "Generator: MSVC.NET: Found template \'%s\'", ret.toLatin1().constData());
     return ret;
diff --git a/qmake/project.cpp b/qmake/project.cpp
index 52f2206410184f36f5fab39d7446ab4f13fb9f73..bfd4511f2f6ddf21daba735d293f7bbc28439e78 100644
--- a/qmake/project.cpp
+++ b/qmake/project.cpp
@@ -592,7 +592,7 @@ QStringList qmake_feature_paths(QMakeProperty *prop=0)
     }
     for(QStringList::Iterator concat_it = concat.begin();
         concat_it != concat.end(); ++concat_it)
-        feature_roots << (QLibraryInfo::location(QLibraryInfo::DataPath) +
+        feature_roots << (QLibraryInfo::location(QLibraryInfo::HostDataPath) +
                           mkspecs_concat + (*concat_it));
     return feature_roots;
 }
@@ -607,7 +607,7 @@ QStringList qmake_mkspec_paths()
         for(QStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it)
             ret << ((*it) + concat);
     }
-    ret << QLibraryInfo::location(QLibraryInfo::DataPath) + concat;
+    ret << QLibraryInfo::location(QLibraryInfo::HostDataPath) + concat;
 
     return ret;
 }
@@ -3113,7 +3113,7 @@ QStringList &QMakeProject::values(const QString &_var, QHash<QString, QStringLis
             place[var] = QStringList(Option::fixPathToTargetOS(
                 !Option::qmake_abslocation.isEmpty()
                     ? Option::qmake_abslocation
-                    : QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmake",
+                    : QLibraryInfo::location(QLibraryInfo::HostBinariesPath) + "/qmake",
                 false));
     }
 #if defined(Q_OS_WIN32) && defined(Q_CC_MSVC)
diff --git a/qmake/property.cpp b/qmake/property.cpp
index dec204cb9c29c19fd05f116f2698d75d1c0d55cd..7cb689ed7efc12cc52c13107df1cc5a523592077 100644
--- a/qmake/property.cpp
+++ b/qmake/property.cpp
@@ -54,27 +54,45 @@ QStringList qmake_mkspec_paths(); //project.cpp
 static const struct {
     const char *name;
     QLibraryInfo::LibraryLocation loc;
+    bool raw;
 } propList[] = {
-    { "QT_INSTALL_PREFIX", QLibraryInfo::PrefixPath },
-    { "QT_INSTALL_DATA", QLibraryInfo::DataPath },
-    { "QT_INSTALL_DOCS", QLibraryInfo::DocumentationPath },
-    { "QT_INSTALL_HEADERS", QLibraryInfo::HeadersPath },
-    { "QT_INSTALL_LIBS", QLibraryInfo::LibrariesPath },
-    { "QT_INSTALL_BINS", QLibraryInfo::BinariesPath },
-    { "QT_INSTALL_TESTS", QLibraryInfo::TestsPath },
-    { "QT_INSTALL_PLUGINS", QLibraryInfo::PluginsPath },
-    { "QT_INSTALL_IMPORTS", QLibraryInfo::ImportsPath },
-    { "QT_INSTALL_TRANSLATIONS", QLibraryInfo::TranslationsPath },
-    { "QT_INSTALL_CONFIGURATION", QLibraryInfo::SettingsPath },
-    { "QT_INSTALL_EXAMPLES", QLibraryInfo::ExamplesPath },
-    { "QT_INSTALL_DEMOS", QLibraryInfo::ExamplesPath }, // Just backwards compat
+    { "QT_SYSROOT", QLibraryInfo::SysrootPath, true },
+    { "QT_INSTALL_PREFIX", QLibraryInfo::PrefixPath, false },
+    { "QT_INSTALL_DATA", QLibraryInfo::DataPath, false },
+    { "QT_INSTALL_DOCS", QLibraryInfo::DocumentationPath, false },
+    { "QT_INSTALL_HEADERS", QLibraryInfo::HeadersPath, false },
+    { "QT_INSTALL_LIBS", QLibraryInfo::LibrariesPath, false },
+    { "QT_INSTALL_BINS", QLibraryInfo::BinariesPath, false },
+    { "QT_INSTALL_TESTS", QLibraryInfo::TestsPath, false },
+    { "QT_INSTALL_PLUGINS", QLibraryInfo::PluginsPath, false },
+    { "QT_INSTALL_IMPORTS", QLibraryInfo::ImportsPath, false },
+    { "QT_INSTALL_TRANSLATIONS", QLibraryInfo::TranslationsPath, false },
+    { "QT_INSTALL_CONFIGURATION", QLibraryInfo::SettingsPath, false },
+    { "QT_INSTALL_EXAMPLES", QLibraryInfo::ExamplesPath, false },
+    { "QT_INSTALL_DEMOS", QLibraryInfo::ExamplesPath, false }, // Just backwards compat
+    { "QT_RAW_INSTALL_PREFIX", QLibraryInfo::PrefixPath, true },
+    { "QT_RAW_INSTALL_DATA", QLibraryInfo::DataPath, true },
+    { "QT_RAW_INSTALL_DOCS", QLibraryInfo::DocumentationPath, true },
+    { "QT_RAW_INSTALL_HEADERS", QLibraryInfo::HeadersPath, true },
+    { "QT_RAW_INSTALL_LIBS", QLibraryInfo::LibrariesPath, true },
+    { "QT_RAW_INSTALL_BINS", QLibraryInfo::BinariesPath, true },
+    { "QT_RAW_INSTALL_TESTS", QLibraryInfo::TestsPath, true },
+    { "QT_RAW_INSTALL_PLUGINS", QLibraryInfo::PluginsPath, true },
+    { "QT_RAW_INSTALL_IMPORTS", QLibraryInfo::ImportsPath, true },
+    { "QT_RAW_INSTALL_TRANSLATIONS", QLibraryInfo::TranslationsPath, true },
+    { "QT_RAW_INSTALL_CONFIGURATION", QLibraryInfo::SettingsPath, true },
+    { "QT_RAW_INSTALL_EXAMPLES", QLibraryInfo::ExamplesPath, true },
+    { "QT_HOST_PREFIX", QLibraryInfo::HostPrefixPath, true },
+    { "QT_HOST_DATA", QLibraryInfo::HostDataPath, true },
+    { "QT_HOST_BINS", QLibraryInfo::HostBinariesPath, true },
 };
 
 QMakeProperty::QMakeProperty() : settings(0)
 {
     for (int i = 0; i < sizeof(propList)/sizeof(propList[0]); i++)
-        m_values[QString::fromLatin1(propList[i].name)] =
-                QLibraryInfo::location(propList[i].loc);
+        m_values[QString::fromLatin1(propList[i].name)] = propList[i].raw
+                ? QLibraryInfo::rawLocation(propList[i].loc)
+                : QLibraryInfo::location(propList[i].loc);
 }
 
 QMakeProperty::~QMakeProperty()
diff --git a/qtbase.pro b/qtbase.pro
index 5fc9cb3888413ee4d56e2c7a40bb5f56a7e6678d..01a5aa33dc202f1b65f1729d97665956d85719d5 100644
--- a/qtbase.pro
+++ b/qtbase.pro
@@ -98,7 +98,7 @@ CONFIG -= qt
 ### installations ####
 
 #qmake
-qmake.path=$$[QT_INSTALL_BINS]
+qmake.path = $$[QT_HOST_BINS]
 win32 {
    qmake.files=$$QT_BUILD_TREE/bin/qmake.exe
 } else {
@@ -107,18 +107,18 @@ win32 {
 INSTALLS += qmake
 
 #syncqt
-syncqt.path=$$[QT_INSTALL_BINS]
+syncqt.path = $$[QT_HOST_BINS]
 syncqt.files=$$QT_BUILD_TREE/bin/syncqt
 win32:syncqt.files=$$QT_BUILD_TREE/bin/syncqt.bat
 INSTALLS += syncqt
 
 #qtmodule-configtests
-configtests.path=$$[QT_INSTALL_BINS]
+configtests.path = $$[QT_HOST_BINS]
 configtests.files=$$QT_BUILD_TREE/bin/qtmodule-configtests
 INSTALLS += configtests
 
 #mkspecs
-mkspecs.path=$$[QT_INSTALL_DATA]/mkspecs
+mkspecs.path = $$[QT_HOST_DATA]/mkspecs
 mkspecs.files=$$QT_BUILD_TREE/mkspecs/qconfig.pri $$QT_BUILD_TREE/mkspecs/qmodule.pri $$files($$QT_SOURCE_TREE/mkspecs/*)
 mkspecs.files -= $$QT_SOURCE_TREE/mkspecs/modules
 unix { 
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index c7f0cd1c28882f8f305b901b1276b701b98b3a37..4caacece2da77ab55f234b4462d8a86eb70fe03f 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -228,16 +228,43 @@ static const struct {
     { "Translations", "translations" },
     { "Examples", "" },
     { "Tests", "tests" },
+#ifdef QT_BUILD_QMAKE
+    { "Sysroot", "" },
+    { "HostPrefix", "" },
+    { "HostBinaries", "bin" },
+    { "HostData", "" },
+#endif
 };
 
 /*!
   Returns the location specified by \a loc.
 
 */
-
 QString
 QLibraryInfo::location(LibraryLocation loc)
 {
+#ifdef QT_BUILD_QMAKE
+    QString ret = rawLocation(loc);
+
+    // Automatically prepend the sysroot to target paths
+    if (loc < SysrootPath || loc > LastHostPath) {
+        QString sysroot = rawLocation(SysrootPath);
+        if (!sysroot.isEmpty() && ret.length() > 2 && ret.at(1) == QLatin1Char(':')
+            && (ret.at(2) == QLatin1Char('/') || ret.at(2) == QLatin1Char('\\')))
+            ret.replace(0, 2, sysroot); // Strip out the drive on Windows targets
+        else
+            ret.prepend(sysroot);
+    }
+
+    return ret;
+}
+
+QString
+QLibraryInfo::rawLocation(LibraryLocation loc)
+{
+#else
+# define rawLocation location
+#endif
     QString ret;
     if(!QLibraryInfoPrivate::configuration()) {
         const char *path = 0;
@@ -284,11 +311,19 @@ QLibraryInfo::location(LibraryLocation loc)
 
     if (QDir::isRelativePath(ret)) {
         QString baseDir;
-        if (loc == PrefixPath) {
-            // we make the prefix path absolute to the executable's directory
 #ifdef QT_BUILD_QMAKE
+        if (loc == HostPrefixPath || loc == PrefixPath) {
+            // We make the prefix path absolute to the executable's directory.
+            // loc == PrefixPath while a sysroot is set would make no sense here.
             baseDir = QFileInfo(qmake_libraryInfoFile()).absolutePath();
+        } else if (loc == SysrootPath) {
+            // The sysroot is bare
+            return ret;
+        } else if (loc > SysrootPath && loc <= LastHostPath) {
+            // We make any other host path absolute to the host prefix directory.
+            baseDir = rawLocation(HostPrefixPath);
 #else
+        if (loc == PrefixPath) {
             if (QCoreApplication::instance()) {
 #ifdef Q_OS_MAC
                 CFBundleRef bundleRef = CFBundleGetMainBundle();
@@ -300,6 +335,7 @@ QLibraryInfo::location(LibraryLocation loc)
                     }
                 }
 #endif
+                // We make the prefix path absolute to the executable's directory.
                 baseDir = QCoreApplication::applicationDirPath();
             } else {
                 baseDir = QDir::currentPath();
@@ -307,7 +343,7 @@ QLibraryInfo::location(LibraryLocation loc)
 #endif
         } else {
             // we make any other path absolute to the prefix directory
-            baseDir = location(PrefixPath);
+            baseDir = rawLocation(PrefixPath);
         }
         ret = QDir::cleanPath(baseDir + QLatin1Char('/') + ret);
     }
diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h
index f6234d1eb4676c7ee2968d0552a7b50677c7a5b5..d180e6319819cf99fe5e3f549cec4b283c6d5db5 100644
--- a/src/corelib/global/qlibraryinfo.h
+++ b/src/corelib/global/qlibraryinfo.h
@@ -77,9 +77,21 @@ public:
         TranslationsPath,
         ExamplesPath,
         TestsPath,
+        // Insert new values above this line
+#ifdef QT_BUILD_QMAKE
+        // These are not subject to binary compatibility constraints
+        SysrootPath,
+        HostPrefixPath,
+        HostBinariesPath,
+        HostDataPath,
+        LastHostPath = HostDataPath,
+#endif
         SettingsPath = 100
     };
     static QString location(LibraryLocation); // ### Qt 5: consider renaming it to path()
+#ifdef QT_BUILD_QMAKE
+    static QString rawLocation(LibraryLocation);
+#endif
 
 private:
     QLibraryInfo();
diff --git a/src/tools/moc/moc.pro b/src/tools/moc/moc.pro
index 3ee507855c9458e1364d4b7afe75db3e5a132c5f..5c96c96a4c3f851ddeb03f5358778000f175adc5 100644
--- a/src/tools/moc/moc.pro
+++ b/src/tools/moc/moc.pro
@@ -13,6 +13,6 @@ HEADERS += qdatetime_p.h
 SOURCES += main.cpp
 include(../bootstrap/bootstrap.pri)
 
-target.path=$$[QT_INSTALL_BINS]
+target.path = $$[QT_HOST_BINS]
 INSTALLS += target
 load(qt_targets)
diff --git a/src/tools/rcc/rcc.pro b/src/tools/rcc/rcc.pro
index 6c78642406466afcaf46523a0047b8140c09578b..e87ef605b9943853251478b6ed607b3109a30555 100644
--- a/src/tools/rcc/rcc.pro
+++ b/src/tools/rcc/rcc.pro
@@ -11,6 +11,6 @@ HEADERS += ../../corelib/kernel/qcorecmdlineargs_p.h
 SOURCES += main.cpp
 include(../bootstrap/bootstrap.pri)
 
-target.path=$$[QT_INSTALL_BINS]
+target.path = $$[QT_HOST_BINS]
 INSTALLS += target
 load(qt_targets)
diff --git a/src/tools/uic/uic.pro b/src/tools/uic/uic.pro
index 7a95db861f333a0c37a32e3c368449b74646b2e2..0acc6e77c803da9d4d8309a7cb6ad2a7279b42f9 100644
--- a/src/tools/uic/uic.pro
+++ b/src/tools/uic/uic.pro
@@ -22,6 +22,6 @@ linux-g++-maemo {
 
 include(../bootstrap/bootstrap.pri)
 
-target.path=$$[QT_INSTALL_BINS]
+target.path = $$[QT_HOST_BINS]
 INSTALLS += target
 load(qt_targets)
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index e4c9bb2010d02c125dba971a7571f7304c314353..504728abc8fb02f41168effe967e2b111a9a648d 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -1063,11 +1063,33 @@ void Configure::parseCmdLine()
             dictionary[ "QT_INSTALL_TESTS" ] = configCmdLine.at(i);
         }
 
+        else if (configCmdLine.at(i) == "-sysroot") {
+            ++i;
+            if (i == argCount)
+                break;
+            dictionary[ "CFG_SYSROOT" ] = configCmdLine.at(i);
+        }
+
         else if (configCmdLine.at(i) == "-hostprefix") {
+            ++i;
+            if (i == argCount || configCmdLine.at(i).startsWith('-'))
+                dictionary[ "QT_HOST_PREFIX" ] = dictionary[ "QT_BUILD_TREE" ];
+            else
+                dictionary[ "QT_HOST_PREFIX" ] = configCmdLine.at(i);
+        }
+
+        else if (configCmdLine.at(i) == "-hostbindir") {
             ++i;
             if (i == argCount)
                 break;
-            dictionary[ "QT_HOST_PREFIX" ] = configCmdLine.at(i);
+            dictionary[ "QT_HOST_BINS" ] = configCmdLine.at(i);
+        }
+
+        else if (configCmdLine.at(i) == "-hostdatadir") {
+            ++i;
+            if (i == argCount)
+                break;
+            dictionary[ "QT_HOST_DATA" ] = configCmdLine.at(i);
         }
 
         else if (configCmdLine.at(i) == "-make") {
@@ -2381,6 +2403,16 @@ void Configure::generateOutputVars()
     if (!dictionary[ "QT_INSTALL_TESTS" ].size())
         dictionary[ "QT_INSTALL_TESTS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/tests");
 
+    bool haveHpx = false;
+    if (dictionary[ "QT_HOST_PREFIX" ].isEmpty())
+        dictionary[ "QT_HOST_PREFIX" ] = dictionary[ "QT_INSTALL_PREFIX" ];
+    else
+        haveHpx = true;
+    if (dictionary[ "QT_HOST_BINS" ].isEmpty())
+        dictionary[ "QT_HOST_BINS" ] = haveHpx ? fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/bin") : dictionary[ "QT_INSTALL_BINS" ];
+    if (dictionary[ "QT_HOST_DATA" ].isEmpty())
+        dictionary[ "QT_HOST_DATA" ] = haveHpx ? dictionary[ "QT_HOST_PREFIX" ] : dictionary[ "QT_INSTALL_DATA" ];
+
     if (dictionary.contains("XQMAKESPEC") && dictionary[ "XQMAKESPEC" ].startsWith("linux"))
         dictionary[ "QMAKE_RPATHDIR" ] = dictionary[ "QT_INSTALL_LIBS" ];
 
@@ -2599,6 +2631,17 @@ void Configure::generateCachefile()
                      << "QT_MINOR_VERSION = " << dictionary["VERSION_MINOR"] << endl
                      << "QT_PATCH_VERSION = " << dictionary["VERSION_PATCH"] << endl;
 
+        if (!dictionary["CFG_SYSROOT"].isEmpty()) {
+            QString targetSpec = dictionary.contains("XQMAKESPEC") ? dictionary[ "XQMAKESPEC" ] : dictionary[ "QMAKESPEC" ];
+            configStream << endl
+                         << "# sysroot" << endl
+                         << targetSpec << " {" << endl
+                         << "    QMAKE_CFLAGS    += --sysroot=$$[QT_SYSROOT]" << endl
+                         << "    QMAKE_CXXFLAGS  += --sysroot=$$[QT_SYSROOT]" << endl
+                         << "    QMAKE_LFLAGS    += --sysroot=$$[QT_SYSROOT]" << endl
+                         << "}" << endl;
+        }
+
         configStream.flush();
         configFile.close();
     }
@@ -2854,10 +2897,8 @@ void Configure::generateConfigfiles()
                   << endl
                   << "/* Build date */" << endl
                   << "static const char qt_configure_installation          [11  + 12] = \"qt_instdate=" << QDate::currentDate().toString(Qt::ISODate) << "\";" << endl
-                  << endl;
-        if (!dictionary[ "QT_HOST_PREFIX" ].isNull())
-            tmpStream << "#if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE)" << endl;
-        tmpStream << "static const char qt_configure_prefix_path_strs[][12 + 512] = {" << endl
+                  << endl
+                  << "static const char qt_configure_prefix_path_strs[][12 + 512] = {" << endl
                   << "    \"qt_prfxpath=" << escapeSeparators(dictionary["QT_INSTALL_PREFIX"]) << "\"," << endl
                   << "    \"qt_docspath=" << escapeSeparators(dictionary["QT_INSTALL_DOCS"]) << "\","  << endl
                   << "    \"qt_hdrspath=" << escapeSeparators(dictionary["QT_INSTALL_HEADERS"]) << "\","  << endl
@@ -2869,27 +2910,16 @@ void Configure::generateConfigfiles()
                   << "    \"qt_trnspath=" << escapeSeparators(dictionary["QT_INSTALL_TRANSLATIONS"]) << "\"," << endl
                   << "    \"qt_xmplpath=" << escapeSeparators(dictionary["QT_INSTALL_EXAMPLES"]) << "\","  << endl
                   << "    \"qt_tstspath=" << escapeSeparators(dictionary["QT_INSTALL_TESTS"]) << "\","  << endl
+                  << "#ifdef QT_BUILD_QMAKE" << endl
+                  << "    \"qt_ssrtpath=" << escapeSeparators(dictionary["CFG_SYSROOT"]) << "\"," << endl
+                  << "    \"qt_hpfxpath=" << escapeSeparators(dictionary["QT_HOST_PREFIX"]) << "\"," << endl
+                  << "    \"qt_hbinpath=" << escapeSeparators(dictionary["QT_HOST_BINS"]) << "\"," << endl
+                  << "    \"qt_hdatpath=" << escapeSeparators(dictionary["QT_HOST_DATA"]) << "\"," << endl
+                  << "#endif" << endl
                   << "};" << endl
                   //<< "static const char qt_configure_settings_path_str [256] = \"qt_stngpath=" << escapeSeparators(dictionary["QT_INSTALL_SETTINGS"]) << "\";" << endl
-                  ;
-        if (!dictionary[ "QT_HOST_PREFIX" ].isNull()) {
-             tmpStream << "#else" << endl
-                       << "static const char qt_configure_prefix_path_strs[][12 + 512] = {" << endl
-                       << "    \"qt_prfxpath=" << escapeSeparators(dictionary[ "QT_HOST_PREFIX" ]) << "\";" << endl
-                       << "    \"qt_docspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/doc", true) <<"\","  << endl
-                       << "    \"qt_hdrspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/include", true) <<"\","  << endl
-                       << "    \"qt_libspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/lib", true) <<"\","  << endl
-                       << "    \"qt_binspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/bin", true) <<"\","  << endl
-                       << "    \"qt_plugpath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/plugins", true) <<"\","  << endl
-                       << "    \"qt_impspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/imports", true) <<"\","  << endl
-                       << "    \"qt_datapath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ], true) <<"\","  << endl
-                       << "    \"qt_trnspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/translations", true) <<"\"," << endl
-                       << "    \"qt_xmplpath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/example", true) <<"\","  << endl
-                       << "    \"qt_tstspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/tests", true) <<"\","  << endl
-                       << "};" << endl
-                       << "#endif //QT_BOOTSTRAPPED" << endl;
-        }
-        tmpStream << "/* strlen( \"qt_lcnsxxxx\") == 12 */" << endl
+                  << endl
+                  << "/* strlen( \"qt_lcnsxxxx\") == 12 */" << endl
                   << "#define QT_CONFIGURE_LICENSEE qt_configure_licensee_str + 12;" << endl
                   << "#define QT_CONFIGURE_LICENSED_PRODUCTS qt_configure_licensed_products_str + 12;" << endl
                   //<< "#define QT_CONFIGURE_SETTINGS_PATH qt_configure_settings_path_str + 12;" << endl