From c2773ce6b4efb3f8f8d516c29750dd25c802f60b Mon Sep 17 00:00:00 2001
From: axis <qt-info@nokia.com>
Date: Fri, 18 Feb 2011 15:20:00 +0100
Subject: Changed various qmake constructs to support Windows.

RevBy:    Thomas Zander

Conflicts:

	mkspecs/features/symbian/symbian_building.prf
---
 mkspecs/features/symbian/def_files.prf                | 18 ++++++++++++++++--
 mkspecs/features/symbian/symbian_building.prf         | 19 ++++++++++++-------
 .../sqldrivers/sqlite_symbian/sqlite_symbian.pri      | 10 ++++++++--
 3 files changed, 36 insertions(+), 11 deletions(-)

diff --git a/mkspecs/features/symbian/def_files.prf b/mkspecs/features/symbian/def_files.prf
index 4a59116..746de6a 100644
--- a/mkspecs/features/symbian/def_files.prf
+++ b/mkspecs/features/symbian/def_files.prf
@@ -7,6 +7,18 @@ CONFIG -= def_files_disabled
 equals(QMAKE_TARGET_PRODUCT, Qt4)|equals(QMAKE_TARGET_PRODUCT, QTestLib):clean_TARGET = $$replace(TARGET, "$${QT_LIBINFIX}$", "")
 else:clean_TARGET = $$TARGET
 
+defineTest(qtTestIfDirExists) {
+    contains(QMAKE_HOST.os,Windows) {
+        dirToTest = $$1
+        $$dirToTest ~= s,/,\\,
+        # Windows trick. Test for existence of nul, which every directory has.
+        retValue = $$system("if exist $$dirToTest\\nul echo true")
+        contains(retValue, true):return(true)|return(false)
+    } else {
+        system("test -d $$1"):return(true)|return(false)
+    }
+}
+
 symbian-abld|symbian-sbsv2 {
     # Firstly, if the MMP_RULES already contain a defBlock variable, don't generate another one
     # (this bit is slightly magic, because it depends upon everyone creating their DEFFILE statements
@@ -52,9 +64,11 @@ symbian-abld|symbian-sbsv2 {
     } else {
         defFile = .
     }
-    system("$$QMAKE_CHK_DIR_EXISTS $$_PRO_FILE_PWD_/$$defFile") {
+    qtTestIfDirExists($$_PRO_FILE_PWD_/$$defFile) {
         !exists("$$_PRO_FILE_PWD_/$$defFile/eabi") {
-            system("$$QMAKE_MKDIR $$_PRO_FILE_PWD_/$$defFile/eabi")
+            dirToCreate = $$_PRO_FILE_PWD_/$$defFile/eabi
+            contains(QMAKE_HOST.os,Windows):dirToCreate ~= s,/,\\,
+            system("$$QMAKE_MKDIR $$dirToCreate")
         }
         elf2e32FileToAdd = $$_PRO_FILE_PWD_/$$defFile/eabi/$$basename(clean_TARGET)u.def
     } else {
diff --git a/mkspecs/features/symbian/symbian_building.prf b/mkspecs/features/symbian/symbian_building.prf
index f5df68b..8a0cc9b 100644
--- a/mkspecs/features/symbian/symbian_building.prf
+++ b/mkspecs/features/symbian/symbian_building.prf
@@ -89,12 +89,13 @@ count(splitVersion, 0) {
     decVersion = "10.0"
 } else {
     count(splitVersion, 3) {
-        hexVersion = $$system("sh -c 'printf %02x $$member(splitVersion, 0)'")
-        hexPart2 = $$system("sh -c 'printf %02x $$member(splitVersion, 1)'")
-        hexPart2 = $$hexPart2$$system("sh -c 'printf %02x $$member(splitVersion, 2)'")
-        decVersion = $$system("sh -c 'printf %1d 0x$$hexVersion'").
+        hexVersion = $$system("perl -e \"printf (\\\"%02x\\\", $$member(splitVersion, 0))\"")
+        hexPart2 = $$system("perl -e \"printf (\\\"%02x\\\", $$member(splitVersion, 1))\"")
+        hexPart2 = $$hexPart2$$system("perl -e \"printf (\\\"%02x\\\", $$member(splitVersion, 2))\"")
+        decVersion = $$system("perl -e \"printf (\\\"%1d\\\", 0x$$hexVersion)\"").
         hexVersion = $$hexVersion$$hexPart2
-        decVersion = $$decVersion$$system("sh -c 'printf %d 0x$$hexPart2'")
+        decVersion = $$decVersion$$system("perl -e \"printf (\\\"%d\\\", 0x$$hexPart2)\"")
+
         !contains(hexVersion, "[0-9a-f]{8}"):hexVersion = "00$${hexVersion}"
     } else {  # app code may have different numbering...
         hexVersion = $$VERSION
@@ -117,7 +118,9 @@ contains(TEMPLATE, lib):!contains(CONFIG, static):!contains(CONFIG, staticlib) {
     contains(CONFIG, plugin):QMAKE_ELF2E32_FLAGS += --definput=plugin_commonu.def
 
     !isEmpty(QMAKE_POST_LINK):QMAKE_POST_LINK = $$escape_expand(\\n\\t)$$QMAKE_POST_LINK
-    QMAKE_POST_LINK = $$QMAKE_MOVE $$symbianDestdir/$${baseTarget}.dll $$symbianDestdir/$${baseTarget}.sym \
+    moveCmd = $$QMAKE_MOVE $$symbianDestdir/$${baseTarget}.dll $$symbianDestdir/$${baseTarget}.sym
+    contains(QMAKE_HOST.os,Windows):moveCmd = $$replace(moveCmd, /, \\)
+    QMAKE_POST_LINK = $$moveCmd \
                       && $$QMAKE_ELF2E32_WRAPPER --version=$$decVersion \
                       --sid=$$TARGET.SID \
                       --uid1=0x10000079 \
@@ -168,7 +171,9 @@ contains(TEMPLATE, lib):!contains(CONFIG, static):!contains(CONFIG, staticlib) {
 
 contains(TEMPLATE, app):!contains(QMAKE_LINK, "^@:.*") {
     !isEmpty(QMAKE_POST_LINK):QMAKE_POST_LINK = $$escape_expand(\\n\\t)$$QMAKE_POST_LINK
-    QMAKE_POST_LINK = $$QMAKE_MOVE $$symbianDestdir/$${baseTarget} $$symbianDestdir/$${baseTarget}.sym \
+    moveCmd = $$QMAKE_MOVE $$symbianDestdir/$${baseTarget} $$symbianDestdir/$${baseTarget}.sym
+    contains(QMAKE_HOST.os,Windows):moveCmd = $$replace(moveCmd, /, \\)
+    QMAKE_POST_LINK = $$moveCmd \
                       && $$QMAKE_ELF2E32_WRAPPER --version $$decVersion \
                       --sid=$$TARGET.SID \
                       --uid1=0x1000007a \
diff --git a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pri b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pri
index 494c64c..ebeccc9 100644
--- a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pri
+++ b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pri
@@ -1,6 +1,12 @@
 # We just want to include the sqlite3 binaries for Symbian for platforms that do not have them.
 !symbian-abld:!symbian-sbsv2 {
     !symbian_no_export_sqlite:!exists($${EPOCROOT}epoc32/release/armv5/lib/sqlite3.dso) {
+        contains(QMAKE_HOST.os,Windows) {
+            # Trick on Windows to do a touch on the file, since copy keeps the timestamp.
+            copyWithTouch = copy /y /b NUL+
+        } else {
+            copyWithTouch = "$$QMAKE_COPY "
+        }
         symbian_sqlite3_zip_file = $$PWD/SQLite3_v9.2.zip
 
         # The QMAKE_COPY section is to update timestamp on the file.
@@ -10,7 +16,7 @@
         symbian_sqlite3_header.CONFIG = combine no_link
         symbian_sqlite3_header.dependency_type = TYPE_C
         symbian_sqlite3_header.commands = $$QMAKE_UNZIP -j ${QMAKE_FILE_NAME} epoc32/include/stdapis/${QMAKE_FILE_OUT_BASE}.h \
-                                          && $$QMAKE_COPY ${QMAKE_FILE_OUT_BASE}.h ${QMAKE_FILE_OUT}.tmp \
+                                          && $${copyWithTouch}${QMAKE_FILE_OUT_BASE}.h ${QMAKE_FILE_OUT}.tmp \
                                           && $$QMAKE_DEL_FILE ${QMAKE_FILE_OUT_BASE}.h \
                                           && $$QMAKE_MOVE ${QMAKE_FILE_OUT}.tmp ${QMAKE_FILE_OUT}
         silent:symbian_sqlite3_header.commands = @echo unzipping $@ && $$symbian_sqlite3_header.commands
@@ -22,7 +28,7 @@
         !isEmpty(OBJECTS_DIR):symbian_sqlite3_dso.output = $$OBJECTS_DIR/$$symbian_sqlite3_dso.output
         symbian_sqlite3_dso.CONFIG = combine no_link target_predeps
         symbian_sqlite3_dso.commands = $$QMAKE_UNZIP -j ${QMAKE_FILE_NAME} epoc32/release/armv5/lib/${QMAKE_FILE_OUT_BASE}.dso \
-                                       && $$QMAKE_COPY ${QMAKE_FILE_OUT_BASE}.dso ${QMAKE_FILE_OUT}.tmp \
+                                       && $${copyWithTouch}${QMAKE_FILE_OUT_BASE}.dso ${QMAKE_FILE_OUT}.tmp \
                                        && $$QMAKE_DEL_FILE ${QMAKE_FILE_OUT_BASE}.dso \
                                        && $$QMAKE_MOVE ${QMAKE_FILE_OUT}.tmp ${QMAKE_FILE_OUT}
         silent:symbian_sqlite3_dso.commands = @echo unzipping $@ && $$symbian_sqlite3_dso.commands
-- 
cgit v0.12