From ffa44aca0f4f16a75719bcb70cca2a4c25af0f73 Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Sun, 18 Sep 2016 18:26:18 +0200
Subject: [PATCH 19/32] Use *.dll.a as import lib extension

The variables used here are provided by
g++-win32.conf

Change-Id: I40acb56685628ed52b3e6b89aab7f53f9a872b1a
---
 mkspecs/features/create_cmake.prf      |  5 +++--
 mkspecs/features/qt.prf                | 15 ++++++++++++---
 qmake/generators/win32/winmakefile.cpp | 15 +++++++++++----
 3 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
index 593161f362..37689938eb 100644
--- a/mkspecs/features/create_cmake.prf
+++ b/mkspecs/features/create_cmake.prf
@@ -332,8 +332,9 @@ mac {
         CMAKE_WINMAIN_FILE_LOCATION_DEBUG = libqt5main$${QT_LIBINFIX}$${debug_suffix}.a
         CMAKE_WINMAIN_FILE_LOCATION_RELEASE = libqt5main$${QT_LIBINFIX}.a
 
-        CMAKE_IMPLIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}$${debug_suffix}.a
-        CMAKE_IMPLIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a
+        isEmpty(QMAKE_EXTENSION_IMPORTLIB): QMAKE_EXTENSION_IMPORTLIB = a
+        CMAKE_IMPLIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}$${debug_suffix}.$${QMAKE_EXTENSION_IMPORTLIB}
+        CMAKE_IMPLIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.$${QMAKE_EXTENSION_IMPORTLIB}
     } else {
         CMAKE_WINMAIN_FILE_LOCATION_DEBUG = qt5main$${QT_LIBINFIX}$${debug_suffix}.lib
         CMAKE_WINMAIN_FILE_LOCATION_RELEASE = qt5main$${QT_LIBINFIX}.lib
diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf
index 2bc7b1dedd..b79b324b88 100644
--- a/mkspecs/features/qt.prf
+++ b/mkspecs/features/qt.prf
@@ -216,12 +216,21 @@ for(ever) {
                 LIBS$$var_sfx += -framework $$framework
             } else {
                 lib = $$MODULE_MODULE$$qtPlatformTargetSuffix()
-                win32|contains(MODULE_CONFIG, staticlib) {
+                contains(MODULE_CONFIG, staticlib) {
                     lib = $$MODULE_LIBS/$$QMAKE_PREFIX_STATICLIB$${lib}.$$QMAKE_EXTENSION_STATICLIB
                     PRE_TARGETDEPS += $$lib
                 } else {
-                    lib = $$MODULE_LIBS/$$QMAKE_PREFIX_SHLIB$${lib}.$$QMAKE_EXTENSION_SHLIB
-                }
+                    win32 {
+                        shared|actually_a_shared_build {
+                            lib = $$MODULE_LIBS/$$QMAKE_PREFIX_STATICLIB$${lib}.$$QMAKE_EXTENSION_IMPORTLIB
+                        } else {
+                            lib = $$MODULE_LIBS/$$QMAKE_PREFIX_STATICLIB$${lib}.$$QMAKE_EXTENSION_STATICLIB
+                        }
+                        PRE_TARGETDEPS += $$lib
+                    } else {
+                        lib = $$MODULE_LIBS/$$QMAKE_PREFIX_SHLIB$${lib}.$$QMAKE_EXTENSION_SHLIB
+                    }
+		}
                 LIBS$$var_sfx += $$lib
             }
         }
diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
index 183cef2908..03732df4a8 100644
--- a/qmake/generators/win32/winmakefile.cpp
+++ b/qmake/generators/win32/winmakefile.cpp
@@ -99,9 +99,13 @@ private:
 bool
 Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
 {
-    ProStringList impexts = project->values("QMAKE_LIB_EXTENSIONS");
-    if (impexts.isEmpty())
-        impexts = project->values("QMAKE_EXTENSION_STATICLIB");
+    ProStringList impexts;
+    if (project->isActiveConfig("staticlib")) {
+      impexts.append(project->values("QMAKE_EXTENSION_STATICLIB"));
+    } else {
+      impexts.append(project->values("QMAKE_EXTENSION_IMPORTLIB"));
+      impexts.append(project->values("QMAKE_EXTENSION_STATICLIB"));
+    }
     QVector<LibrarySearchPath> dirs;
     int libidx = 0;
     for (const ProString &dlib : project->values("QMAKE_DEFAULT_LIBDIRS"))
@@ -283,9 +287,12 @@ void Win32MakefileGenerator::fixTargetExt()
     if (!project->values("QMAKE_APP_FLAG").isEmpty()) {
         project->values("TARGET_EXT").append(".exe");
     } else if (project->isActiveConfig("shared")) {
+        ProString impext = project->first("QMAKE_EXTENSION_IMPORTLIB");
+        if (impext.isEmpty())
+          impext = project->first("QMAKE_PREFIX_STATICLIB");
         project->values("LIB_TARGET").prepend(project->first("QMAKE_PREFIX_STATICLIB")
                                               + project->first("TARGET") + project->first("TARGET_VERSION_EXT")
-                                              + '.' + project->first("QMAKE_EXTENSION_STATICLIB"));
+                                              + '.' + impext);
         project->values("TARGET_EXT").append(project->first("TARGET_VERSION_EXT") + "."
                 + project->first("QMAKE_EXTENSION_SHLIB"));
         project->values("TARGET").first() = project->first("QMAKE_PREFIX_SHLIB") + project->first("TARGET");
-- 
2.33.0

