Index: /trunk/mkspecs/features/os2/default_post.prf
===================================================================
--- /trunk/mkspecs/features/os2/default_post.prf	(revision 672)
+++ /trunk/mkspecs/features/os2/default_post.prf	(revision 673)
@@ -1,7 +1,7 @@
 !CONFIG(windows):!CONFIG(console) {
     CONFIG(release, debug|release):CONFIG(qt):contains(QT, gui) {
-    	CONFIG *= windows
+        CONFIG *= windows
     } else {
-    	CONFIG *= console
+        CONFIG *= console
     }
 }
@@ -12,78 +12,65 @@
 build_pass|isEmpty(BUILDS) {
 
-    dll {
-        # create the import library target
-        make_implib.target = $(TARGET_IMPLIB)
-        make_implib.commands = $$QMAKE_RUN_IMPLIB
-        export_all {
-            make_implib.depends = $(DEF_FILE)
-            POST_TARGETDEPS += $$make_implib.target
-        } else {
-            make_implib.depends = $(DESTDIR_TARGET)
-            ALL_DEPS += $$make_implib.target
-        }
-        QMAKE_EXTRA_TARGETS += make_implib
-        QMAKE_CLEAN += $$make_implib.target
-
-		export_all:QMAKE_RUN_GENDEF = $$QMAKE_RUN_GENDEF_EXPORT_ALL
-    }
-
     # convert QMAKE_TARGET_ variables to DEF_FILE_ ones
     isEmpty(DEF_FILE_VERSION) {
         DEF_FILE_VERSION = $$VERSION
-	}
-	isEmpty(DEF_FILE_DESCRIPTION) {
-		!isEmpty(QMAKE_TARGET_PRODUCT):DEF_FILE_DESCRIPTION = $$QMAKE_TARGET_PRODUCT
-		!isEmpty(QMAKE_TARGET_DESCRIPTION) {
-			!isEmpty(DEF_FILE_DESCRIPTION):DEF_FILE_DESCRIPTION = $${DEF_FILE_DESCRIPTION}: $$QMAKE_TARGET_DESCRIPTION
-			else:DEF_FILE_DESCRIPTION = $$QMAKE_TARGET_DESCRIPTION
-		}
-		!isEmpty(QMAKE_TARGET_COPYRIGHT) {
-			!isEmpty(DEF_FILE_DESCRIPTION):DEF_FILE_DESCRIPTION = $${DEF_FILE_DESCRIPTION} $$QMAKE_TARGET_COPYRIGHT
-			else:DEF_FILE_DESCRIPTION = $$QMAKE_TARGET_COPYRIGHT
-		}
-	}
-	isEmpty(DEF_FILE_VENDOR):!isEmpty(QMAKE_TARGET_COMPANY):DEF_FILE_VENDOR = $$QMAKE_TARGET_COMPANY
+    }
+    isEmpty(DEF_FILE_DESCRIPTION) {
+        !isEmpty(QMAKE_TARGET_PRODUCT):DEF_FILE_DESCRIPTION = $$QMAKE_TARGET_PRODUCT
+        !isEmpty(QMAKE_TARGET_DESCRIPTION) {
+            !isEmpty(DEF_FILE_DESCRIPTION):DEF_FILE_DESCRIPTION = $${DEF_FILE_DESCRIPTION}: $$QMAKE_TARGET_DESCRIPTION
+            else:DEF_FILE_DESCRIPTION = $$QMAKE_TARGET_DESCRIPTION
+        }
+        !isEmpty(QMAKE_TARGET_COPYRIGHT) {
+            !isEmpty(DEF_FILE_DESCRIPTION):DEF_FILE_DESCRIPTION = $${DEF_FILE_DESCRIPTION} $$QMAKE_TARGET_COPYRIGHT
+            else:DEF_FILE_DESCRIPTION = $$QMAKE_TARGET_COPYRIGHT
+        }
+    }
+    isEmpty(DEF_FILE_VENDOR):!isEmpty(QMAKE_TARGET_COMPANY):DEF_FILE_VENDOR = $$QMAKE_TARGET_COMPANY
 
-    # handle .DEF file creation for executables
-    contains(TEMPLATE, ".*app"):isEmpty(DEF_FILE) {
-        DEF_FILE_DESCR =
-        !isEmpty(DEF_FILE_VERSION)|!isEmpty(DEF_FILE_DESCRIPTION)|!isEmpty(DEF_FILE_VENDOR) {
-            QMAKESPEC_DIR = $$dirname(QMAKESPEC)
-            isEmpty(QMAKESPEC_DIR):QMAKESPEC_DIR = $$[QT_INSTALL_DATA]/mkspecs
-            exists($$QMAKESPEC_DIR/os2-g++/emxexpw.cmd) {
-                DEF_FILE_DESCR = -printbldlevel
-                !isEmpty(DEF_FILE_VERSION):DEF_FILE_DESCR += -version \"$$DEF_FILE_VERSION\"
-                !isEmpty(DEF_FILE_DESCRIPTION):DEF_FILE_DESCR += -desc \"$$DEF_FILE_DESCRIPTION\"
-                !isEmpty(DEF_FILE_VENDOR):DEF_FILE_DESCR += -vendor \"$$DEF_FILE_VENDOR\"
-                DEF_FILE_DESCR = "$$system($$QMAKESPEC_DIR/os2-g++/emxexpw.cmd $$DEF_FILE_DESCR)"
-            } else {
-                warning($$QMAKESPEC_DIR/os2-g++/emxexpw.cmd is not found!)
-                warning(BLDLEVEL string in .DEF will not contain all info!)
-                DEF_FILE_DESCR = "@$${LITERAL_HASH}vendor:version$${LITERAL_HASH}@ description"
-                DEF_FILE_DESCR = $$replace(DEF_FILE_DESCR, vendor, $$DEF_FILE_VENDOR)
-                DEF_FILE_DESCR = $$replace(DEF_FILE_DESCR, version, $$DEF_FILE_VERSION)
-                DEF_FILE_DESCR = $$replace(DEF_FILE_DESCR, description, $$DEF_FILE_DESCRIPTION)
+    contains(TEMPLATE, ".*lib"):dll {
+        # create the import library target (assumes that the generator puts
+        # puts 'TARGET_IMPLIB... = ' to the Makefile)
+        make_implib.target = $(TARGET_IMPLIB)
+        make_implib.commands = $$QMAKE_RUN_IMPLIB
+        export_all:make_implib.depends = $(DEF_FILE)
+        else:make_implib.depends = $(DESTDIR_TARGET)
+        ALL_DEPS += $$make_implib.target
+        QMAKE_CLEAN += $$make_implib.target
+        QMAKE_EXTRA_TARGETS += make_implib
+
+        isEmpty(DEF_FILE) {
+            # create a .DEF file if not supplied (assumes that the generator
+            # puts 'DEF_FILE_... = ' $$DEF_FILE... to the Makefile)
+            make_def.target = $(DEF_FILE)
+            make_def.depends = $(MAKEFILE)
+            !isEmpty(DEF_FILE_TEMPLATE):make_def.depends += $(DEF_FILE_TEMPLATE)
+            !isEmpty(DEF_FILE_MAP):make_def.depends += $(DEF_FILE_MAP)
+            export_all:make_def.depends += $(OBJECTS)
+            export_all:make_def.commands = $$QMAKE_RUN_GENDEF_EXPORT_ALL
+            else:make_def.commands = $$QMAKE_RUN_GENDEF
+            QMAKE_CLEAN += $$make_def.target
+            QMAKE_EXTRA_TARGETS += make_def
+        }
+        POST_TARGETDEPS += $(DEF_FILE)
+    }
+
+    contains(TEMPLATE, ".*app") {
+        isEmpty(DEF_FILE) {
+            # handle .DEF file creation for executables
+            !isEmpty(DEF_FILE_VERSION)|!isEmpty(DEF_FILE_DESCRIPTION)|\
+            !isEmpty(DEF_FILE_VENDOR)|!isEmpty(DEF_FILE_TEMPLATE) {
+                windows:DEF_FILE_EXETYPE = WINDOWAPI
+                else:DEF_FILE_EXETYPE = WINDOWCOMPAT
+                make_def.target = $(DEF_FILE)
+                make_def.depends = $(MAKEFILE)
+                !isEmpty(DEF_FILE_TEMPLATE):make_def.depends += $(DEF_FILE_TEMPLATE)
+                make_def.commands = $$QMAKE_RUN_GENDEF_EXE
+                QMAKE_CLEAN += $$make_def.target
+                QMAKE_EXTRA_TARGETS += make_def
+                POST_TARGETDEPS += $$make_def.target
             }
-        }
-        !isEmpty(DEF_FILE_DESCR)|wlink {
-            # Note: neither WLINK nor EMXOMFLD allows to specify the app type of
-            # the .EXE on the command line. For this reason, we need an implicit
-            # .DEF which we create if no explicit .DEF file is provided in .pro,
-            # even if DEF_FILE_DESCR is actually empty.
-
-            DEF_FILE = $(OBJECTS_DIR)/$(TARGET).def
-
-            windows:DEF_FILE_APPTYPE = WINDOWAPI
-            else::DEF_FILE_APPTYPE = WINDOWCOMPAT
-
-            make_exe_def.target = $(DEF_FILE)
-            make_exe_def.depends = $(call q,$(MAKEFILE))
-            make_exe_def.commands = \
-                @echo NAME $(QMAKE_TARGET) $$DEF_FILE_APPTYPE > $(DEF_FILE)
-            !isEmpty(DEF_FILE_DESCR):make_exe_def.commands += $$escape_expand(\n\t) \
-                @echo DESCRIPTION \'$${DEF_FILE_DESCR}\' >> $(DEF_FILE)
-            QMAKE_EXTRA_TARGETS += make_exe_def
-            QMAKE_CLEAN += $$make_exe_def.target
+        } else {
+            POST_TARGETDEPS += $(DEF_FILE)
         }
     }
Index: /trunk/mkspecs/features/os2/default_pre.prf
===================================================================
--- /trunk/mkspecs/features/os2/default_pre.prf	(revision 672)
+++ /trunk/mkspecs/features/os2/default_pre.prf	(revision 673)
@@ -110,5 +110,5 @@
                     else:tgt = Part$${next}
                 }
-                eval(ALL_DEPS += $(call q,$(TARGET_IMPLIB)) $${tgt})
+                eval(ALL_DEPS += $(TARGET_IMPLIB) $${tgt})
             	export(ALL_DEPS)
 
Index: /trunk/mkspecs/os2-g++/qmake.conf
===================================================================
--- /trunk/mkspecs/os2-g++/qmake.conf	(revision 672)
+++ /trunk/mkspecs/os2-g++/qmake.conf	(revision 673)
@@ -116,11 +116,12 @@
         $(if $(DEF_FILE_DESCRIPTION),-desc \"$(DEF_FILE_DESCRIPTION)\") \
         $(if $(DEF_FILE_VENDOR),-vendor \"$(DEF_FILE_VENDOR)\") \
-        $(if $(DEF_FILE_TEMPLATE),-template $(DEF_FILE_TEMPLATE))
+        $(if $(DEF_FILE_TEMPLATE),-template \"$(DEF_FILE_TEMPLATE)\")
 
 QMAKE_RUN_GENDEF_EXPORT_ALL = $$QMAKE_RUN_GENDEF \
-        $(if $(DEF_FILE_MAP),-map $(DEF_FILE_MAP)) \
+        $(if $(DEF_FILE_MAP),-map \"$(DEF_FILE_MAP)\") \
         $$QMAKE_OBJECTS_REF
 
-QMAKE_GENDEF_DEPS       = $(OBJECTS) $(MAKEFILE)
+QMAKE_RUN_GENDEF_EXE    = $$QMAKE_RUN_GENDEF \
+        $(if $(DEF_FILE_EXETYPE),-exe \"$(DEF_FILE_EXETYPE)\")
 
 QMAKE_LIBS              =
Index: /trunk/qmake/generators/os2/gnumake.cpp
===================================================================
--- /trunk/qmake/generators/os2/gnumake.cpp	(revision 672)
+++ /trunk/qmake/generators/os2/gnumake.cpp	(revision 673)
@@ -558,33 +558,45 @@
     }
 
-    if (project->isEmpty("DEF_FILE")) {
-        /* no DEF file supplied, we will generate one */
-        if (mode == DLL) {
-            t << "DEF_FILE      = $(basename $(DESTDIR_TARGET)).def" << endl;
-            project->values("QMAKE_CLEAN").append("$(DEF_FILE)");
-            project->values("POST_TARGETDEPS") += escapeFileVars("$(DEF_FILE)");
-            if (!project->isEmpty("DEF_FILE_VERSION"))
-                t << "DEF_FILE_VERSION = " << var("DEF_FILE_VERSION") << endl;
-            if (!project->isEmpty("DEF_FILE_DESCRIPTION"))
-                t << "DEF_FILE_DESCRIPTION = " << var("DEF_FILE_DESCRIPTION") << endl;
-            if (!project->isEmpty("DEF_FILE_VENDOR"))
-                t << "DEF_FILE_VENDOR = " << var("DEF_FILE_VENDOR") << endl;
+    if (mode != StaticLib) {
+        if (project->isEmpty("DEF_FILE")) {
+            /* no DEF file supplied, emit handy variable definitions to simplify
+             * DEF generation rules defined somewhere in default_post.prf */
+            bool haveSomething = false;
+            if (!project->isEmpty("DEF_FILE_VERSION")) {
+                t << "DEF_FILE_VERSION        = " << var("DEF_FILE_VERSION") << endl;
+                haveSomething = true;
+            }
+            if (!project->isEmpty("DEF_FILE_DESCRIPTION")) {
+                t << "DEF_FILE_DESCRIPTION    = " << var("DEF_FILE_DESCRIPTION") << endl;
+                haveSomething = true;
+            }
+            if (!project->isEmpty("DEF_FILE_VENDOR")) {
+                t << "DEF_FILE_VENDOR         = " << var("DEF_FILE_VENDOR") << endl;
+                haveSomething = true;
+            }
             if (!project->isEmpty("DEF_FILE_TEMPLATE")) {
-                t << "DEF_FILE_TEMPLATE = " << escapeFilePath(var("DEF_FILE_TEMPLATE")) << endl;
-                project->values("QMAKE_GENDEF_DEPS") += "$(DEF_FILE_TEMPLATE)";
+                t << "DEF_FILE_TEMPLATE       = " << escapeFilePath(var("DEF_FILE_TEMPLATE")) << endl;
+                haveSomething = true;
             }
             if (!project->isEmpty("DEF_FILE_MAP")) {
-                t << "DEF_FILE_MAP  = " << escapeFilePath(var("DEF_FILE_MAP")) << endl;
-                project->values("QMAKE_GENDEF_DEPS") += "$(DEF_FILE_MAP)";
-            }
-        }
-    } else {
-        if (!project->isEmpty("DEF_FILE_TEMPLATE")) {
-            fprintf(stderr, "Both DEF_FILE and DEF_FILE_TEMPLATE are specified.\n");
-            fprintf(stderr, "Please specify one of them, not both.");
-            exit(1);
-        }
-        t << "DEF_FILE      = " << escapeFilePath(var("DEF_FILE")) << endl;
-        project->values("POST_TARGETDEPS") += "$(DEF_FILE)";
+                t << "DEF_FILE_MAP            = " << escapeFilePath(var("DEF_FILE_MAP")) << endl;
+                haveSomething = true;
+            }
+            if (mode == DLL) {
+                // the DLL needs a file in any case
+                t << "DEF_FILE      = $(basename $(DESTDIR_TARGET)).def" << endl;
+            } else if (haveSomething) {
+                // the EXE needs it only if there's a description info
+                t << "DEF_FILE_EXETYPE        = " << escapeFilePath(var("DEF_FILE_EXETYPE")) << endl;
+                t << "DEF_FILE      = $(OBJECTS_DIR)\\$(TARGET).def" << endl;
+            }
+        } else {
+            if (!project->isEmpty("DEF_FILE_TEMPLATE")) {
+                fprintf(stderr, "Both DEF_FILE and DEF_FILE_TEMPLATE are specified.\n");
+                fprintf(stderr, "Please specify one of them, not both.");
+                exit(1);
+            }
+            t << "DEF_FILE      = " << escapeFilePath(var("DEF_FILE")) << endl;
+        }
     }
 
@@ -601,12 +613,4 @@
         t << escapeFileVars("$(RES_FILE): $(RC_FILE)\n\t");
         t << var("QMAKE_RUN_RC2RES") << endl;
-    }
-
-    if (mode == DLL) {
-        if (project->isEmpty("DEF_FILE")) {
-            /* generate a DEF file for the DLL when not supplied */
-            t << escapeFileVars("$(DEF_FILE): ") << escapeFileVars(var("QMAKE_GENDEF_DEPS"));
-            t << valGlue(var("QMAKE_RUN_GENDEF").split(";;"), "\n\t", "\n\t", "") << endl;
-        }
     }
 }
