From 46060b16fd66e6db9306ea06514fa2f23b38c1f6 Mon Sep 17 00:00:00 2001
From: Jeremy Drake <github@jdrake.com>
Date: Wed, 2 Dec 2020 12:00:03 -0800
Subject: [PATCH 2/3] qmake fixes for mingw.

Mostly want it to act like unix.
---
 phoenix.pro           | 43 +++++++++++++++++++++++++------------------
 pri/libgit2detect.pri |  4 ++--
 2 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/phoenix.pro b/phoenix.pro
index 2abf6d0d..a4482772 100644
--- a/phoenix.pro
+++ b/phoenix.pro
@@ -33,7 +33,7 @@ CONFIG += c++14
 # TODO: Verify flags for clang and msvc builds
 QMAKE_CXXFLAGS += -O3 -fno-omit-frame-pointer
 
-unix:!macx {
+if(unix:!macx)|mingw {
     CONFIG += link_pkgconfig
 }
 
@@ -47,6 +47,9 @@ win32 {
     DEFINES += _CRT_SECURE_NO_DEPRECATE
     DEFINES += _WINDOWS
     RELEASE_SCRIPT = $$(RELEASE_SCRIPT)    # environment variable set from release script
+    mingw:isEmpty(QMAKE_TARGET.arch) {
+        QMAKE_TARGET.arch = $$(MSYSTEM_CARCH)
+    }
 
     message("target arch: $${QMAKE_TARGET.arch}")
     contains(QMAKE_TARGET.arch, x86_64) {
@@ -58,17 +61,19 @@ win32 {
         DEBDIR = ../debug32
     }
 
-    Release:DESTDIR = $${RELDIR}
-    Release:OBJECTS_DIR = $${RELDIR}
-    Release:MOC_DIR = $${RELDIR}
-    Release:RCC_DIR = $${RELDIR}
-    Release:UI_DIR = $${RELDIR}
-
-    Debug:DESTDIR = $${DEBDIR}
-    Debug:OBJECTS_DIR = $${DEBDIR}
-    Debug:MOC_DIR = $${DEBDIR}
-    Debug:RCC_DIR = $${DEBDIR}
-    Debug:UI_DIR = $${DEBDIR}
+    !mingw {
+        Release:DESTDIR = $${RELDIR}
+        Release:OBJECTS_DIR = $${RELDIR}
+        Release:MOC_DIR = $${RELDIR}
+        Release:RCC_DIR = $${RELDIR}
+        Release:UI_DIR = $${RELDIR}
+
+        Debug:DESTDIR = $${DEBDIR}
+        Debug:OBJECTS_DIR = $${DEBDIR}
+        Debug:MOC_DIR = $${DEBDIR}
+        Debug:RCC_DIR = $${DEBDIR}
+        Debug:UI_DIR = $${DEBDIR}
+    }
 }
 macx {
     RELDIR = ../release64
@@ -96,13 +101,15 @@ macx {
     LIBS += /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
     LIBS += -liconv
 }
-unix {
+unix|mingw {
     !macx { # unix is defined on mac
-        HARDWARE_PLATFORM = $$system(uname -m)
-        contains(HARDWARE_PLATFORM, x86_64) {
-            DEFINES += LINUX_64
-        } else {
-            DEFINES += LINUX_32
+        !mingw {
+            HARDWARE_PLATFORM = $$system(uname -m)
+            contains(HARDWARE_PLATFORM, x86_64) {
+                DEFINES += LINUX_64
+            } else {
+                DEFINES += LINUX_32
+            }
         }
         !contains(DEFINES, QUAZIP_INSTALLED) {
             LIBS += -lz
diff --git a/pri/libgit2detect.pri b/pri/libgit2detect.pri
index f8dae314..5fbd177f 100644
--- a/pri/libgit2detect.pri
+++ b/pri/libgit2detect.pri
@@ -34,7 +34,7 @@ if ($$LIBGIT_STATIC) {
     INCLUDEPATH += $$LIBGIT2INCLUDE
 }
 
-win32 {
+win32:!mingw {
     contains(QMAKE_TARGET.arch, x86_64) {
         LIBGIT2LIB = "$$_PRO_FILE_PWD_/../libgit2/build64/Release"
     } else {
@@ -51,7 +51,7 @@ win32 {
     message($$PKGCONFIG)
 }
 
-unix {
+unix|mingw {
     if ($$LIBGIT_STATIC) {
         LIBGIT2LIB = $$_PRO_FILE_PWD_/../libgit2/build
         exists($$LIBGIT2LIB/libgit2.a) {
-- 
2.31.1.windows.1

