diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp
index 067303a9cc3c7534abb173d4244f751261bfb340..20c22123d3fc66407b32623451ebabd248a514b8 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.cpp
+++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp
@@ -696,9 +696,9 @@ QString QtVersionManager::findQMakeBinaryFromMakefile(const QString &directory)
     QFile makefile(directory + "/Makefile" );
     if (makefile.exists() && makefile.open(QFile::ReadOnly)) {
         QTextStream ts(&makefile);
+        QRegExp r1("QMAKE\\s*=(.*)");
         while (!ts.atEnd()) {
             QString line = ts.readLine();
-            QRegExp r1("QMAKE\\s*=(.*)");
             if (r1.exactMatch(line)) {
                 if (debugAdding)
                     qDebug()<<"#~~ QMAKE is:"<<r1.cap(1).trimmed();
@@ -737,7 +737,7 @@ QPair<QtVersion::QmakeBuildConfigs, QStringList> QtVersionManager::scanMakeFile(
 {
     if (debug)
         qDebug()<<"ScanMakeFile, the gory details:";
-    QtVersion::QmakeBuildConfigs result = QtVersion::NoBuild;
+    QtVersion::QmakeBuildConfigs result = defaultBuildConfig;
     QStringList result2;
 
     QString line = findQMakeLine(directory);