diff --git a/src/plugins/qt4projectmanager/profilereader.cpp b/src/plugins/qt4projectmanager/profilereader.cpp
index 3781fc37d057ba98342cee419e01f17bf080a3c4..ecd53ee51c88946fff9beb499448f2c2ce635023 100644
--- a/src/plugins/qt4projectmanager/profilereader.cpp
+++ b/src/plugins/qt4projectmanager/profilereader.cpp
@@ -48,7 +48,8 @@ ProFileReader::~ProFileReader()
 bool ProFileReader::readProFile(const QString &fileName)
 {
     if (ProFile *pro = parsedProFile(fileName)) {
-        aboutToEval(pro);
+        m_ignoreLevel = 0;
+        aboutToEval(0, pro, EvalIncludeFile);
         bool ok = accept(pro);
         pro->deref();
         return ok;
@@ -56,15 +57,23 @@ bool ProFileReader::readProFile(const QString &fileName)
     return false;
 }
 
-void ProFileReader::aboutToEval(ProFile *pro)
+void ProFileReader::aboutToEval(ProFile *, ProFile *pro, EvalFileType type)
 {
-    if (!m_includeFiles.contains(pro->fileName())) {
+    if (m_ignoreLevel || type == EvalFeatureFile) {
+        m_ignoreLevel++;
+    } else if (!m_includeFiles.contains(pro->fileName())) {
         m_includeFiles.insert(pro->fileName(), pro);
         m_proFiles.append(pro);
         pro->ref();
     }
 }
 
+void ProFileReader::doneWithEval(ProFile *)
+{
+    if (m_ignoreLevel)
+        m_ignoreLevel--;
+}
+
 QList<ProFile*> ProFileReader::includeFiles() const
 {
     QString qmakeMkSpecDir = QFileInfo(propertyValue("QMAKE_MKSPECS")).absoluteFilePath();
diff --git a/src/plugins/qt4projectmanager/profilereader.h b/src/plugins/qt4projectmanager/profilereader.h
index b749bc3e569455525a0bf536e2123da1aa672c5d..1019be7870af6c07622e0dc1261bdb973f7bb071 100644
--- a/src/plugins/qt4projectmanager/profilereader.h
+++ b/src/plugins/qt4projectmanager/profilereader.h
@@ -58,7 +58,8 @@ signals:
     void errorFound(const QString &error);
 
 private:
-    virtual void aboutToEval(ProFile *proFile);
+    virtual void aboutToEval(ProFile *parent, ProFile *proFile, EvalFileType type);
+    virtual void doneWithEval(ProFile *parent);
     virtual void logMessage(const QString &msg);
     virtual void fileMessage(const QString &msg);
     virtual void errorMessage(const QString &msg);
@@ -66,6 +67,7 @@ private:
 private:
     QMap<QString, ProFile *> m_includeFiles;
     QList<ProFile *> m_proFiles;
+    int m_ignoreLevel;
 };
 
 class ProFileCacheManager : public QObject
diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp
index b4788904b0dbeab1799a28e41e687e9feb398680..2da92571166e48400ba44045c3af867c73358136 100644
--- a/src/shared/proparser/profileevaluator.cpp
+++ b/src/shared/proparser/profileevaluator.cpp
@@ -260,6 +260,7 @@ public:
     ProItem::ProItemReturn evaluateConditionalFunction(const QString &function, const QString &arguments);
     ProFile *parsedProFile(const QString &fileName, bool cache,
                            const QString &contents = QString());
+    bool evaluateFileDirect(const QString &fileName, ProFileEvaluator::EvalFileType type);
     bool evaluateFile(const QString &fileName);
     bool evaluateFeatureFile(const QString &fileName,
                              QHash<QString, QStringList> *values = 0, FunctionDefs *defs = 0);
@@ -3120,6 +3121,20 @@ ProFile *ProFileEvaluator::Private::parsedProFile(const QString &fileName, bool
     return pro;
 }
 
+bool ProFileEvaluator::Private::evaluateFileDirect(
+        const QString &fileName, ProFileEvaluator::EvalFileType type)
+{
+    if (ProFile *pro = parsedProFile(fileName, true)) {
+        q->aboutToEval(currentProFile(), pro, type);
+        bool ok = (visitProFile(pro) == ProItem::ReturnTrue);
+        q->doneWithEval(currentProFile());
+        pro->deref();
+        return ok;
+    } else {
+        return false;
+    }
+}
+
 bool ProFileEvaluator::Private::evaluateFile(const QString &fileName)
 {
     if (fileName.isEmpty())
@@ -3129,14 +3144,7 @@ bool ProFileEvaluator::Private::evaluateFile(const QString &fileName)
             errorMessage(format("circular inclusion of %1").arg(fileName));
             return false;
         }
-    if (ProFile *pro = parsedProFile(fileName, true)) {
-        q->aboutToEval(pro);
-        bool ok = (visitProFile(pro) == ProItem::ReturnTrue);
-        pro->deref();
-        return ok;
-    } else {
-        return false;
-    }
+    return evaluateFileDirect(fileName, ProFileEvaluator::EvalIncludeFile);
 }
 
 bool ProFileEvaluator::Private::evaluateFeatureFile(
@@ -3183,13 +3191,8 @@ bool ProFileEvaluator::Private::evaluateFeatureFile(
         bool cumulative = m_cumulative;
         m_cumulative = false;
 
-        // Don't use evaluateFile() here to avoid calling aboutToEval().
         // The path is fully normalized already.
-        bool ok = false;
-        if (ProFile *pro = parsedProFile(fn, true)) {
-            ok = (visitProFile(pro) == ProItem::ReturnTrue);
-            pro->deref();
-        }
+        bool ok = evaluateFileDirect(fn, ProFileEvaluator::EvalFeatureFile);
 
         m_cumulative = cumulative;
         return ok;
@@ -3371,7 +3374,11 @@ QString ProFileEvaluator::propertyValue(const QString &name) const
     return d->propertyValue(name);
 }
 
-void ProFileEvaluator::aboutToEval(ProFile *)
+void ProFileEvaluator::aboutToEval(ProFile *, ProFile *, EvalFileType)
+{
+}
+
+void ProFileEvaluator::doneWithEval(ProFile *)
 {
 }
 
diff --git a/src/shared/proparser/profileevaluator.h b/src/shared/proparser/profileevaluator.h
index 57df396d5a0e8c54708e9d8bf00c944533647edf..d8202b65f78a9cc3667861db89f2cf38d0e4e9f5 100644
--- a/src/shared/proparser/profileevaluator.h
+++ b/src/shared/proparser/profileevaluator.h
@@ -94,7 +94,9 @@ public:
     QString propertyValue(const QString &val) const;
 
     // for our descendents
-    virtual void aboutToEval(ProFile *proFile); // only .pri, but not .prf. or .pro
+    enum EvalFileType { EvalFeatureFile, EvalIncludeFile };
+    virtual void aboutToEval(ProFile *parent, ProFile *proFile, EvalFileType type);
+    virtual void doneWithEval(ProFile *parent);
     virtual void logMessage(const QString &msg);
     virtual void errorMessage(const QString &msg); // .pro parse errors
     virtual void fileMessage(const QString &msg); // error() and message() from .pro file