diff -uNr sip-4.16.2/configure.py sip-4.16.2-mingw/configure.py
--- sip-4.16.2/configure.py	2014-07-03 12:08:46.000000000 +0200
+++ sip-4.16.2-mingw/configure.py	2014-07-30 10:41:38.510622892 +0200
@@ -20,6 +20,7 @@
 import glob
 import optparse
 from distutils import sysconfig
+from sysconfig import _POSIX_BUILD
 
 try:
     from importlib import invalidate_caches
@@ -157,7 +158,9 @@
     build_platform = "none"
 
     if py_platform == "win32":
-        if py_version >= 0x030500:
+        if _POSIX_BUILD:
+            build_platform = "win32-g++"
+        elif py_version >= 0x030500:
             build_platform = "win32-msvc2015"
         elif py_version >= 0x030300:
             build_platform = "win32-msvc2010"
@@ -219,7 +219,7 @@
     plat_py_venv_inc_dir = sysconfig.get_python_inc(prefix=sys.prefix)
     plat_py_conf_inc_dir = os.path.dirname(sysconfig.get_config_h_filename())
 
-    if sys.platform == "win32":
+    if sys.platform == "win32" and not _POSIX_BUILD:
         bin_dir = sys.exec_prefix
 
         try:
@@ -245,9 +245,22 @@
     else:
         lib_dir = sysconfig.get_python_lib(plat_specific=1, standard_lib=1)
 
-        plat_py_lib_dir = lib_dir + "/config"
-        plat_bin_dir = sys.exec_prefix + "/bin"
-        plat_sip_dir = sys.prefix + "/share/sip"
+        if "MSYSTEM" in os.environ:
+            plat_py_site_dir = os.popen(' '.join(['cygpath', '--unix', plat_py_site_dir])).readline().strip()
+            plat_py_inc_dir = os.popen(' '.join(['cygpath', '--unix', plat_py_inc_dir])).readline().strip()
+            plat_py_conf_inc_dir = os.popen(' '.join(['cygpath', '--unix', plat_py_conf_inc_dir])).readline().strip()
+            lib_dir = os.popen(' '.join(['cygpath', '--unix', lib_dir])).readline().strip()
+            
+            plat_py_lib_dir = lib_dir + "/config"
+            temp_sys_exec_prefix = os.popen(' '.join(['cygpath', '--unix', sys.exec_prefix])).readline().strip()
+            plat_bin_dir = temp_sys_exec_prefix + "/bin"
+            temp_sys_prefix = os.popen(' '.join(['cygpath', '--unix', sys.prefix])).readline().strip()
+            plat_sip_dir = temp_sys_prefix + "/share/sip"
+            plat_py_venv_inc_dir = os.popen(' '.join(['cygpath', '--unix', plat_py_venv_inc_dir])).readline().strip()
+        else:
+            plat_py_lib_dir = lib_dir + "/config"
+            plat_bin_dir = sys.exec_prefix + "/bin"
+            plat_sip_dir = sys.prefix + "/share/sip"
 
 
 def patch_files():
@@ -398,7 +413,10 @@
         if not opts.static:
             # These only need to be correct for Windows.
             debug_suffix = "_d" if opts.debug else ""
-            link_lib_dir = quote("-L" + cfg.py_lib_dir)
+            if "MSYSTEM" in os.environ:
+              link_lib_dir = quote("-L" + sys.prefix + "/" + cfg.py_lib_dir)
+            else:
+              link_lib_dir = quote("-L" + cfg.py_lib_dir)
 
             pro.write("""
 win32 {
diff -uNr sip-4.16.2/siputils.py sip-4.16.2-mingw/siputils.py
--- sip-4.16.2/siputils.py	2014-05-10 17:00:48.000000000 +0200
+++ sip-4.16.2-mingw/siputils.py	2014-07-30 10:41:24.250623520 +0200
@@ -22,7 +22,8 @@
 import stat
 import string
 import re
-
+from distutils import sysconfig
+from sysconfig import _POSIX_BUILD
 
 # These are installation specific values created when SIP was configured.
 # @SIP_CONFIGURATION@
@@ -321,7 +322,7 @@
         self.extra_libs = []
 
         # Get these once and make them available to sub-classes.
-        if sys.platform == "win32":
+        if sys.platform == "win32" and not "MSYSTEM" in os.environ:
             def_copy = "copy"
             def_rm = "del"
             def_mkdir = "mkdir"
@@ -440,7 +441,7 @@
             incdir.append(self.config.py_inc_dir)
             incdir.append(self.config.py_conf_inc_dir)
 
-            if sys.platform == "cygwin":
+            if sys.platform == "cygwin" or _POSIX_BUILD:
                 libdir.append(self.config.py_lib_dir)
 
                 py_lib = "python%u.%u" % ((self.config.py_version >> 16), ((self.config.py_version >> 8) & 0xff))
@@ -1625,7 +1626,7 @@
         mfile is the file object.
         """
         if self.static:
-            if sys.platform == "win32":
+            if sys.platform == "win32" and not _POSIX_BUILD:
                 ext = "lib"
             else:
                 ext = "a"
@@ -2021,7 +2026,7 @@
     s is the string.
     """
     # On Qt5 paths often includes forward slashes so convert them.
-    if sys.platform == "win32":
+    if sys.platform == "win32" and not _POSIX_BUILD:
         s = s.replace("/", "\\")
 
     if s.find(" ") >= 0:
diff -uNr sip-4.16.2/specs/win32-g++ sip-4.16.2-mingw/specs/win32-g++
--- sip-4.16.2/specs/win32-g++	2011-05-11 20:39:21.000000000 +0200
+++ sip-4.16.2-mingw/specs/win32-g++	2014-07-30 10:41:24.250623520 +0200
@@ -69,23 +69,16 @@
 QMAKE_LIBS_COMPAT       = -ladvapi32 -lshell32 -lcomdlg32 -luser32 -lgdi32 -lws2_32
 QMAKE_LIBS_QT_ENTRY     = -lmingw32 -lqtmain
 
-MINGW_IN_SHELL = $$(MINGW_IN_SHELL)
-isEqual(MINGW_IN_SHELL, 1) {
-	QMAKE_DIR_SEP		= /
-	QMAKE_COPY		= cp
-	QMAKE_COPY_DIR		= xcopy /s /q /y /i
-	QMAKE_MOVE		= mv
-	QMAKE_DEL_FILE		= rm
-	QMAKE_MKDIR		= mkdir
-	QMAKE_DEL_DIR		= rmdir
-} else {
-	QMAKE_COPY		= copy /y
-	QMAKE_COPY_DIR		= xcopy /s /q /y /i
-	QMAKE_MOVE		= move
-	QMAKE_DEL_FILE		= del
-	QMAKE_MKDIR		= mkdir
-	QMAKE_DEL_DIR		= rmdir
-}
+MAKEFILE_GENERATOR	= UNIX
+QMAKE_DIR_SEP		= /
+QMAKE_COPY		= cp
+QMAKE_COPY_DIR		= cp -r
+QMAKE_MOVE		= mv
+QMAKE_DEL_FILE		= rm
+QMAKE_MKDIR		= mkdir -p
+QMAKE_DEL_DIR		= rmdir
+QMAKE_CHK_DIR_EXISTS	= test -d
+
 QMAKE_MOC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc.exe
 QMAKE_UIC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe
 QMAKE_IDC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc.exe
@@ -98,5 +91,4 @@
 
 QMAKE_STRIP		= strip
 QMAKE_STRIPFLAGS_LIB 	+= --strip-unneeded
-QMAKE_CHK_DIR_EXISTS	= if not exist
 load(qt_config)
