diff -r -u a/generators/makefile.cpp b/generators/makefile.cpp
--- a/generators/makefile.cpp	2011-09-12 08:49:28 +0200
+++ b/generators/makefile.cpp	2012-01-03 21:46:54 +0100
@@ -777,6 +777,8 @@
     //all sources and generated sources must be turned into objects at some point (the one builtin compiler)
     v["OBJECTS"] += createObjectList(v["SOURCES"]) + createObjectList(v["GENERATED_SOURCES"]);
 
+    v["OBJECT_DIRS"] = createObjectDirectoryList(v["OBJECTS"]);
+
     //Translation files
     if(!project->isEmpty("TRANSLATIONS")) {
         QStringList &trf = project->values("TRANSLATIONS");
@@ -1471,19 +1473,41 @@
     for(QStringList::ConstIterator it = sources.begin(); it != sources.end(); ++it) {
         QFileInfo fi(fileInfo(Option::fixPathToLocalOS((*it))));
         QString dir;
-        if(objdir.isEmpty() && project->isActiveConfig("object_with_source")) {
-            QString fName = Option::fixPathToTargetOS((*it), false);
-            int dl = fName.lastIndexOf(Option::dir_sep);
-            if(dl != -1)
-                dir = fName.left(dl + 1);
-        } else {
-            dir = objdir;
+
+        QString fName = Option::fixPathToTargetOS((*it), false);
+        int dl = fName.lastIndexOf(Option::dir_sep);
+        if(dl != -1)
+            dir = fName.left(dl + 1);
+
+        if(!(objdir.isEmpty() && project->isActiveConfig("object_with_source"))) {
+            dir = objdir + dir;
         }
         ret.append(dir + fi.completeBaseName() + Option::obj_ext);
     }
     return ret;
 }
 
+QStringList
+MakefileGenerator::createObjectDirectoryList(const QStringList &objects)
+{
+    QSet<QString> dirs;
+
+    for(QStringList::ConstIterator it = objects.begin(); it != objects.end(); ++it) {
+        QFileInfo fi(fileInfo(Option::fixPathToLocalOS((*it))));
+        QString dir;
+
+        QString fName = Option::fixPathToTargetOS((*it), false);
+        int dl = fName.lastIndexOf(Option::dir_sep);
+        if(dl != -1)
+        {
+            dir = fName.left(dl + 1);
+            dirs.insert(dir);
+        }
+    }
+
+    return dirs.toList();
+}
+
 ReplaceExtraCompilerCacheKey::ReplaceExtraCompilerCacheKey(const QString &v, const QStringList &i, const QStringList &o)
 {
     hash = 0;
diff -r -u a/generators/makefile.h b/generators/makefile.h
--- a/generators/makefile.h	2011-09-12 08:49:28 +0200
+++ b/generators/makefile.h	2012-01-03 21:46:54 +0100
@@ -91,6 +91,7 @@
 
 protected:
     QStringList createObjectList(const QStringList &sources);
+    QStringList createObjectDirectoryList(const QStringList &objects);
 
     //makefile style generator functions
     void writeObj(QTextStream &, const QString &src);
diff -r -u a/generators/unix/unixmake2.cpp b/generators/unix/unixmake2.cpp
--- a/generators/unix/unixmake2.cpp	2011-09-12 08:49:28 +0200
+++ b/generators/unix/unixmake2.cpp	2012-01-03 21:55:11 +0100
@@ -190,6 +190,7 @@
         t << "OBJECTS_DIR   = " << var("OBJECTS_DIR") << endl;
     else
         t << "OBJECTS_DIR   = ./" << endl;
+    t << "OBJECT_DIRS   = " << valList(escapeFilePaths(project->values("OBJECT_DIRS"))) << endl;
     t << endl;
 
     /* files */
@@ -421,7 +422,7 @@
                 deps.prepend(incr_target_dir + " ");
                 incr_deps = "$(OBJECTS)";
             }
-            t << "all: " << escapeDependencyPath(deps) <<  " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ") <<  "$(TARGET)"
+            t << "all: " << "mkdirs" << " " << escapeDependencyPath(deps) <<  " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ") <<  "$(TARGET)"
               << endl << endl;
 
             //real target
@@ -507,14 +508,14 @@
                 incr_deps = "$(OBJECTS)";
             }
 
-            t << "all: " << " " << escapeDependencyPath(deps) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ")
+            t << "all: " << "mkdirs" << " " << escapeDependencyPath(deps) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ")
               << " " << destdir << "$(TARGET)" << endl << endl;
 
             //real target
             t << destdir << "$(TARGET): " << var("PRE_TARGETDEPS") << " "
               << incr_deps << " $(SUBLIBS) " << target_deps << " " << var("POST_TARGETDEPS");
         } else {
-            t << "all: " << escapeDependencyPath(deps) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ") << " " <<
+            t << "all: " << "mkdirs" << " " << escapeDependencyPath(deps) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ") << " " <<
                 destdir << "$(TARGET)" << endl << endl;
             t << destdir << "$(TARGET): " << var("PRE_TARGETDEPS")
               << " $(OBJECTS) $(SUBLIBS) $(OBJCOMP) " << target_deps
@@ -614,7 +615,7 @@
         }
     } else {
         QString destdir = project->first("DESTDIR");
-        t << "all: " << escapeDependencyPath(deps) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ") << destdir << "$(TARGET) "
+        t << "all: " << "mkdirs" << " " << escapeDependencyPath(deps) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ") << destdir << "$(TARGET) "
           << varGlue("QMAKE_AR_SUBLIBS", destdir, " " + destdir, "") << "\n\n"
           << "staticlib: " << destdir << "$(TARGET)" << "\n\n";
         if(project->isEmpty("QMAKE_AR_SUBLIBS")) {
@@ -667,6 +668,8 @@
         t << endl << endl;
     }
 
+    t << "mkdirs:\n\t" << "$(MKDIR) $(OBJECT_DIRS)" << endl << endl;
+    
     writeMakeQmake(t);
     if(project->isEmpty("QMAKE_FAILED_REQUIREMENTS") && !project->isActiveConfig("no_autoqmake")) {
         QString meta_files;
diff -r -u a/generators/win32/borland_bmake.cpp b/generators/win32/borland_bmake.cpp
--- a/generators/win32/borland_bmake.cpp	2011-09-12 08:49:28 +0200
+++ b/generators/win32/borland_bmake.cpp	2012-01-03 21:46:54 +0100
@@ -137,7 +137,7 @@
 void BorlandMakefileGenerator::writeBuildRulesPart(QTextStream &t)
 {
     t << "first: all" << endl;
-    t << "all: " << fileFixify(Option::output.fileName()) << " " << varGlue("ALL_DEPS"," "," "," ") << " $(DESTDIR_TARGET)" << endl << endl;
+    t << "all: " << "mkdirs" << " " << fileFixify(Option::output.fileName()) << " " << varGlue("ALL_DEPS"," "," "," ") << " $(DESTDIR_TARGET)" << endl << endl;
     t << "$(DESTDIR_TARGET): " << var("PRE_TARGETDEPS") << " $(OBJECTS) " << var("POST_TARGETDEPS");
     if(!project->isEmpty("QMAKE_PRE_LINK"))
         t << "\n\t" <<var("QMAKE_PRE_LINK");
diff -r -u a/generators/win32/mingw_make.cpp b/generators/win32/mingw_make.cpp
--- a/generators/win32/mingw_make.cpp	2011-09-12 08:49:28 +0200
+++ b/generators/win32/mingw_make.cpp	2012-01-03 21:46:54 +0100
@@ -432,7 +432,7 @@
 void MingwMakefileGenerator::writeBuildRulesPart(QTextStream &t)
 {
     t << "first: all" << endl;
-    t << "all: " << escapeDependencyPath(fileFixify(Option::output.fileName())) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS"))," "," "," ") << " $(DESTDIR_TARGET)" << endl << endl;
+    t << "all: " << "mkdirs" << " " << escapeDependencyPath(fileFixify(Option::output.fileName())) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS"))," "," "," ") << " $(DESTDIR_TARGET)" << endl << endl;
     t << "$(DESTDIR_TARGET): " << var("PRE_TARGETDEPS") << " $(OBJECTS) " << var("POST_TARGETDEPS");
     if(!project->isEmpty("QMAKE_PRE_LINK"))
         t << "\n\t" <<var("QMAKE_PRE_LINK");
diff -r -u a/generators/win32/msvc_nmake.cpp b/generators/win32/msvc_nmake.cpp
--- a/generators/win32/msvc_nmake.cpp	2011-09-12 08:49:28 +0200
+++ b/generators/win32/msvc_nmake.cpp	2012-01-03 21:46:54 +0100
@@ -290,7 +290,7 @@
 void NmakeMakefileGenerator::writeBuildRulesPart(QTextStream &t)
 {
     t << "first: all" << endl;
-    t << "all: " << fileFixify(Option::output.fileName()) << " " << varGlue("ALL_DEPS"," "," "," ") << "$(DESTDIR_TARGET)" << endl << endl;
+    t << "all: " << "mkdirs" << " " << fileFixify(Option::output.fileName()) << " " << varGlue("ALL_DEPS"," "," "," ") << "$(DESTDIR_TARGET)" << endl << endl;
     t << "$(DESTDIR_TARGET): " << var("PRE_TARGETDEPS") << " $(OBJECTS) " << var("POST_TARGETDEPS");
 
     if(!project->isEmpty("QMAKE_PRE_LINK"))
diff -r -u a/generators/win32/winmakefile.cpp b/generators/win32/winmakefile.cpp
--- a/generators/win32/winmakefile.cpp	2011-09-12 08:49:28 +0200
+++ b/generators/win32/winmakefile.cpp	2012-01-03 21:54:22 +0100
@@ -652,6 +652,7 @@
         t << "OBJECTS_DIR   = " << var("OBJECTS_DIR").replace(QRegExp("\\\\$"),"") << endl;
     else
         t << "OBJECTS_DIR   = . " << endl;
+    t << "OBJECT_DIRS   = " << valList(escapeFilePaths(project->values("OBJECT_DIRS"))) << endl;
     t << endl;
 
     t << "####### Files" << endl << endl;
@@ -697,6 +698,8 @@
 
     writeRcFilePart(t);
 
+    t << "mkdirs:\n\t" << "$(MKDIR) $(OBJECT_DIRS)" << endl << endl;
+
     writeMakeQmake(t);
 
     QStringList dist_files = fileFixify(Option::mkfile::project_files);
