diff --git a/src/plugins/projectexplorer/debugginghelper.cpp b/src/plugins/projectexplorer/debugginghelper.cpp
index ef1f9a9363a37707485d7ffd26e78b652f876be1..495996e4506c8353df7805e6fbc557659b9f0fc8 100644
--- a/src/plugins/projectexplorer/debugginghelper.cpp
+++ b/src/plugins/projectexplorer/debugginghelper.cpp
@@ -130,15 +130,6 @@ QString DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(const QStrin
     return QString();
 }
 
-QString DebuggingHelperLibrary::buildDebuggingHelperLibrary(const QString &qmakePath, const QString &make, const Environment &env)
-{
-    QString errorMessage;
-    const QString directory = copyDebuggingHelperLibrary(qtInstallDataDir(qmakePath), &errorMessage);
-    if (directory.isEmpty())
-        return errorMessage;
-    return buildDebuggingHelperLibrary(directory, make, qmakePath, QString(), env);
-}
-
 // Copy helper source files to a target directory, replacing older files.
 static bool copyDebuggingHelperFiles(const QStringList &files,
                                      const QString &targetDirectory,
@@ -192,7 +183,9 @@ QString DebuggingHelperLibrary::copyDebuggingHelperLibrary(const QString &qtInst
     return QString();
 }
 
-QString DebuggingHelperLibrary::buildDebuggingHelperLibrary(const QString &directory, const QString &makeCommand, const QString &qmakeCommand, const QString &mkspec, const Environment &env)
+QString DebuggingHelperLibrary::buildDebuggingHelperLibrary(const QString &directory, const QString &makeCommand,
+                                                            const QString &qmakeCommand, const QString &mkspec,
+                                                            const Environment &env, const QString &targetMode)
 {
     QString output;
     const QChar newline = QLatin1Char('\n');
@@ -222,7 +215,7 @@ QString DebuggingHelperLibrary::buildDebuggingHelperLibrary(const QString &direc
     output += QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary", "Running %1 ...\n").arg(qmakeCommand);
 
     QStringList makeArgs;
-    makeArgs << QLatin1String("-spec")<< (mkspec.isEmpty() ? QString(QLatin1String("default")) : mkspec) << QLatin1String("gdbmacros.pro");
+    makeArgs << targetMode << QLatin1String("-spec") << (mkspec.isEmpty() ? QString(QLatin1String("default")) : mkspec) << QLatin1String("gdbmacros.pro");
     proc.start(qmakeCommand, makeArgs);
     proc.waitForFinished();
 
diff --git a/src/plugins/projectexplorer/debugginghelper.h b/src/plugins/projectexplorer/debugginghelper.h
index 1017751f51935ac7162673e8c09d958a06365e27..ddb6a296b886ecf69e316c1fee56cad3dc0e427a 100644
--- a/src/plugins/projectexplorer/debugginghelper.h
+++ b/src/plugins/projectexplorer/debugginghelper.h
@@ -52,8 +52,8 @@ public:
     static QStringList debuggingHelperLibraryLocationsByInstallData(const QString &qtInstallData);
 
     // Build the helpers and return the output log/errormessage.
-    static QString buildDebuggingHelperLibrary(const QString &qmakePath, const QString &make, const Environment &env);
-    static QString buildDebuggingHelperLibrary(const QString &directory, const QString &makeCommand, const QString &qmakeCommand, const QString &mkspec, const Environment &env);
+    static QString buildDebuggingHelperLibrary(const QString &directory, const QString &makeCommand,
+        const QString &qmakeCommand, const QString &mkspec, const Environment &env, const QString &targetMode);
 
     // Copy the source files to a target location and return the chosen target location.
     static QString copyDebuggingHelperLibrary(const QString &qtInstallData, QString *errorMessage);
diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp
index 62587205d94726e6e40fede01a4ade7f889ed72c..b84098ad3c5b868c4fe4bbdcb8fb6dcc73f64797 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.cpp
+++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp
@@ -1657,8 +1657,11 @@ QString QtVersion::buildDebuggingHelperLibrary()
     tc->addToEnvironment(env);
     QString output;
     QString directory = DebuggingHelperLibrary::copyDebuggingHelperLibrary(qtInstallData, &output);
-    if (!directory.isEmpty())
-        output += DebuggingHelperLibrary::buildDebuggingHelperLibrary(directory, tc->makeCommand(), qmakeCommand(), mkspec(), env);
+    if (!directory.isEmpty()) {
+        output += DebuggingHelperLibrary::buildDebuggingHelperLibrary(directory, tc->makeCommand(),
+            qmakeCommand(), mkspec(), env,
+            (tc->type() == ToolChain::GCC_MAEMO ? QLatin1String("-unix") : QLatin1String("")));
+    }
     m_hasDebuggingHelper = !debuggingHelperLibrary().isEmpty();
     return output;
 }