Index: trunk/qmake/generators/os2/gnumake.cpp
===================================================================
--- trunk/qmake/generators/os2/gnumake.cpp	(revision 29)
+++ trunk/qmake/generators/os2/gnumake.cpp	(revision 31)
@@ -80,5 +80,5 @@
 QString GNUMakefileGenerator::getLibTarget()
 {
-    return QString("lib" + project->first("TARGET") + project->first("TARGET_VERSION_EXT") + ".a");
+    return QString("lib" + project->first("TARGET") + project->first("TARGET_VERSION_EXT") + ".lib");
 }
 
@@ -104,11 +104,11 @@
             for (QList<QMakeLocalFileName>::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
                 QString extension;
-                int ver = findHighestVersion((*dir_it).local(), steam, "dll.a|a");
+                int ver = findHighestVersion((*dir_it).local(), steam, "dll.lib|lib");
                 if (ver != -1)
                     extension += QString::number(ver);
                 extension += suffix;
                 if(QMakeMetaInfo::libExists((*dir_it).local() + Option::dir_sep + steam) ||
-                    exists((*dir_it).local() + Option::dir_sep + steam + extension + ".a") ||
-                    exists((*dir_it).local() + Option::dir_sep + steam + extension + ".dll.a")) {
+                    exists((*dir_it).local() + Option::dir_sep + steam + extension + ".lib") ||
+                    exists((*dir_it).local() + Option::dir_sep + steam + extension + ".dll.lib")) {
                         out = (*it) + extension;
                         break;
@@ -162,62 +162,24 @@
  }
 
-/* @todo remove
-void createLdObjectScriptFile(const QString &fileName, const QStringList &objList)
-{
-    QString filePath = Option::output_dir + QDir::separator() + fileName;
-    QFile file(filePath);
-    if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
-        QTextStream t(&file);
-        t << "INPUT(" << endl;
-        for (QStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
-            if (QDir::isRelativePath(*it))
-		t << "./" << *it << endl;
-	    else
-		t << *it << endl;
-        }
-        t << ");" << endl;
-	t.flush();
-        file.close();
-    }
-}
-
-void createArObjectScriptFile(const QString &fileName, const QString &target, const QStringList &objList)
-{
-    QString filePath = Option::output_dir + QDir::separator() + fileName;
-    QFile file(filePath);
-    if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
-        QTextStream t(&file);
-        t << "CREATE " << target << endl;
-        for (QStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
-            if (QDir::isRelativePath(*it))
-		t << "ADDMOD " << *it << endl;
-	    else
-		t << *it << endl;
-        }
-        t << "SAVE" << endl;
-	t.flush();
-        file.close();
-    }
-}
-*/
-
 void GNUMakefileGenerator::writeGNUParts(QTextStream &t)
 {
+    t << "QMAKESPECDIR  = " << quote << specdir() << quote << endl << endl;
+
     writeStandardParts(t);
 
     if (!preCompHeaderOut.isEmpty()) {
-	QString header = project->first("PRECOMPILED_HEADER");
-	QString cHeader = preCompHeaderOut + Option::dir_sep + "c";
-	t << escapeDependencyPath(cHeader) << ": " << escapeDependencyPath(header) << " "
-          << escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")
-	  << "\n\t" << mkdir_p_asstring(preCompHeaderOut)
-	  << "\n\t" << "$(CC) -x c-header -c $(CFLAGS) $(INCPATH) -o " << cHeader << " " << header
-          << endl << endl;
-	QString cppHeader = preCompHeaderOut + Option::dir_sep + "c++";
-	t << escapeDependencyPath(cppHeader) << ": " << escapeDependencyPath(header) << " "
-          << escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")
-	  << "\n\t" << mkdir_p_asstring(preCompHeaderOut)
-	  << "\n\t" << "$(CXX) -x c++-header -c $(CXXFLAGS) $(INCPATH) -o " << cppHeader << " " << header
-          << endl << endl;
+        QString header = project->first("PRECOMPILED_HEADER");
+        QString cHeader = preCompHeaderOut + Option::dir_sep + "c";
+        t << escapeDependencyPath(cHeader) << ": " << escapeDependencyPath(header) << " "
+            << escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")
+            << "\n\t" << mkdir_p_asstring(preCompHeaderOut)
+            << "\n\t" << "$(CC) -x c-header -c $(CFLAGS) $(INCPATH) -o " << cHeader << " " << header
+            << endl << endl;
+        QString cppHeader = preCompHeaderOut + Option::dir_sep + "c++";
+        t << escapeDependencyPath(cppHeader) << ": " << escapeDependencyPath(header) << " "
+            << escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")
+            << "\n\t" << mkdir_p_asstring(preCompHeaderOut)
+            << "\n\t" << "$(CXX) -x c++-header -c $(CXXFLAGS) $(INCPATH) -o " << cppHeader << " " << header
+            << endl << endl;
     }
 }
@@ -275,7 +237,4 @@
         if(!project->first("DESTDIR").isEmpty())
             destDir = Option::fixPathToTargetOS(project->first("DESTDIR") + Option::dir_sep, false, false);
-        project->values("MINGW_IMPORT_LIB").prepend(destDir + "lib" + project->first("TARGET")
-                                                         + project->first("TARGET_VERSION_EXT") + ".a");
-	project->values("QMAKE_LFLAGS").append(QString("-Wl,--out-implib,") + project->first("MINGW_IMPORT_LIB"));
     }
 
@@ -307,8 +266,4 @@
                                                          " $(CXXFLAGS) $(INCPATH) -o $@ $<");
     }
-
-    if(project->isActiveConfig("dll")) {
-        project->values("QMAKE_CLEAN").append(project->first("MINGW_IMPORT_LIB"));
-    }
 }
 
@@ -316,5 +271,5 @@
 {
     if (project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
-        project->values("TARGET_EXT").append(".a");
+        project->values("TARGET_EXT").append(".lib");
         project->values("QMAKE_LFLAGS").append("-static");
         project->values("TARGET").first() =  "lib" + project->first("TARGET");
@@ -326,15 +281,17 @@
 void GNUMakefileGenerator::writeIncPart(QTextStream &t)
 {
-    t << "INCPATH       = ";
-
+    t << "INCPATH       =";
+
+    QString opt = var("QMAKE_CFLAGS_INCDIR");
     QStringList &incs = project->values("INCLUDEPATH");
+    QString incsSemicolon;
     for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
-        QString inc = (*incit);
-        inc.replace(QRegExp("\\\\$"), "");
-        inc.replace(QRegExp("\""), "");
-        t << "-I" << quote << inc << quote << " ";
-    }
-    t << "-I" << quote << specdir() << quote
-      << endl;
+        QString inc = maybeQuotePath(*incit);
+        t << " " << opt << inc;
+        incsSemicolon += inc + Option::dirlist_sep;
+    }
+    t << " " << opt << "$(QMAKESPECDIR)" << endl;
+    incsSemicolon += "$(QMAKESPECDIR)";
+    t << "INCLUDEPATH   = " << incsSemicolon << endl;
 }
 
@@ -342,12 +299,18 @@
 {
     if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
-        t << "LIB        =        " << var("QMAKE_LIB") << endl;
+        t << "LIB           = " << var("QMAKE_LIB") << endl;
     } else {
-        t << "LINK        =        " << var("QMAKE_LINK") << endl;
-        t << "LFLAGS        =        " << var("QMAKE_LFLAGS") << endl;
-        t << "LIBS        =        ";
+        t << "LINK          = " << var("QMAKE_LINK") << endl;
+        t << "LFLAGS        = " << var("QMAKE_LFLAGS") << endl;
+        t << "LIBS          =";
         if(!project->values("QMAKE_LIBDIR").isEmpty())
             writeLibDirPart(t);
-        t << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << endl;
+        QString opt = var("QMAKE_LFLAGS_LIB");
+        QStringList libs = project->values("QMAKE_LIBS");
+        for(QStringList::Iterator it = libs.begin(); it != libs.end(); ++it) {
+            QString lib = maybeQuotePath(*it);
+            t << " " << opt << lib;
+        }
+        t << endl;
     }
 }
@@ -355,33 +318,16 @@
 void GNUMakefileGenerator::writeLibDirPart(QTextStream &t)
 {
+    QString opt = var("QMAKE_LFLAGS_LIBDIR");
     QStringList libDirs = project->values("QMAKE_LIBDIR");
-    for (int i = 0; i < libDirs.size(); ++i)
-        libDirs[i].remove("\"");
-    t << valGlue(libDirs,"-L"+quote,quote+" -L" +quote,quote) << " ";
+    for(QStringList::Iterator it = libDirs.begin(); it != libDirs.end(); ++it) {
+        QString libDir = maybeQuotePath(*it);
+        t << " " << opt << libDir;
+    }
 }
 
 void GNUMakefileGenerator::writeObjectsPart(QTextStream &t)
 {
-    if (project->values("OBJECTS").count() < var("QMAKE_LINK_OBJECT_MAX").toInt()) {
-        objectsLinkLine = "$(OBJECTS)";
-    } else if (project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
-	QString ar_script_file = var("QMAKE_LINK_OBJECT_SCRIPT") + "." + var("TARGET");
-	if (!var("BUILD_NAME").isEmpty()) {
-	    ar_script_file += "." + var("BUILD_NAME");
-	}
-/* @todo remove
-	createArObjectScriptFile(ar_script_file, var("DEST_TARGET"), project->values("OBJECTS"));
-*/
-        objectsLinkLine = "ar -M < " + ar_script_file;
-    } else {
-        QString ld_script_file = var("QMAKE_LINK_OBJECT_SCRIPT") + "." + var("TARGET");
-	if (!var("BUILD_NAME").isEmpty()) {
-	    ld_script_file += "." + var("BUILD_NAME");
-	}
-/* @todo remove
-	createLdObjectScriptFile(ld_script_file, project->values("OBJECTS"));
-*/
-        objectsLinkLine = ld_script_file;
-    }
+    /* @todo generate response files for the linker to overcome the 1024 chars
+     * CMD.EXE limitation */
     Win32MakefileGenerator::writeObjectsPart(t);
 }
@@ -395,11 +341,7 @@
         t << "\n\t" <<var("QMAKE_PRE_LINK");
     if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
-	if (project->values("OBJECTS").count() < var("QMAKE_LINK_OBJECT_MAX").toInt()) {
-            t << "\n\t" << "$(LIB) $(DESTDIR_TARGET) " << objectsLinkLine << " " ;
-        } else {
-            t << "\n\t" << objectsLinkLine << " " ;
-        }
+        t << "\n\t" << "$(LIB) $(DESTDIR_TARGET) $(OBJECTS)";
     } else {
-        t << "\n\t" << "$(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) " << objectsLinkLine << " " << " $(LIBS)";
+        t << "\n\t" << "$(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) $(OBJECTS) $(LIBS)";
     }
     if(!project->isEmpty("QMAKE_POST_LINK"))
@@ -466,3 +408,13 @@
 }
 
+QString GNUMakefileGenerator::maybeQuotePath(const QString &path)
+{
+    QString quoted = path;
+    quoted.replace(QRegExp("\\\\$"), "");
+    quoted.replace(QRegExp("\""), "");
+    if (quoted.contains(QRegExp("[ +&;$%()]")))
+        quoted = quote + quoted + quote;
+    return quoted;
+}
+
 QT_END_NAMESPACE
Index: trunk/qmake/generators/os2/gnumake.h
===================================================================
--- trunk/qmake/generators/os2/gnumake.h	(revision 29)
+++ trunk/qmake/generators/os2/gnumake.h	(revision 31)
@@ -77,6 +77,7 @@
     void fixTargetExt();
 
+    QString maybeQuotePath(const QString &path);
+
     bool init_flag;
-    QString objectsLinkLine;
     QString quote;
 };
