--- pivy-0.6.5/setup.py	2020-01-13 00:51:59.000000000 +0300
+++ python-build-i686/setup.py	2021-01-04 23:22:27.837958100 +0300
@@ -499,7 +499,7 @@
         def quote(s): return '"' + s + '"'
 
         def win_quote(s):
-            if sys.platform == 'win32':
+            if sys.platform == 'win32' and "MSYSTEM" not in os.environ:
                 return '"' + s + '"'
             return s
 
@@ -551,12 +551,15 @@
                     _INCLUDE_DIR = INCLUDE_DIR.replace('"', "")
                 CPP_FLAGS += ' -I' + _INCLUDE_DIR
                 CPP_FLAGS += ' -I' + os.path.join(_INCLUDE_DIR, 'Inventor', 'annex')
-                if sys.platform == 'win32': 
+                if sys.platform == 'win32' and "MSYSTEM" not in os.environ:
                     CPP_FLAGS += " /DCOIN_DLL /wd4244 /wd4049"
                     LDFLAGS_LIBS = quote(max(glob.glob(os.path.join(LIB_DIR, "Coin?.lib")))) + " "
                 else:
                     CPP_FLAGS += " -Wno-unused -Wno-maybe-uninitialized"
                     LDFLAGS_LIBS = ' -L' + self.cmake_config_dict[config_cmd + '_LIB_DIR']
+                    if "MSYSTEM" in os.environ:
+                        CPP_FLAGS += ' -DCOIN_DLL'
+                        LDFLAGS_LIBS += ' -lCoin'
 
                 if module == "soqt":
                     CPP_FLAGS += ' -I' + win_quote(self.QTINFO.getHeadersPath())
@@ -564,14 +567,16 @@
                     CPP_FLAGS += ' -I' + win_quote(os.path.join(self.QTINFO.getHeadersPath(), 'QtGui'))
                     CPP_FLAGS += ' -I' + win_quote(os.path.join(self.QTINFO.getHeadersPath(), 'QtOpenGL'))
                     CPP_FLAGS += ' -I' + win_quote(os.path.join(self.QTINFO.getHeadersPath(), 'QtWidgets'))
-                    if sys.platform == 'win32':
+                    if sys.platform == 'win32' and "MSYSTEM" not in os.environ:
                         LDFLAGS_LIBS += " " + quote(max(glob.glob(os.path.join(LIB_DIR, "SoQt?.lib")))) + " "
-                        CPP_FLAGS += " /DSOQT_DLL"
+                        CPP_FLAGS += ' /DSOQT_DLL'
                     else:
+                        if "MSYSTEM" in os.environ:
+                            CPP_FLAGS += ' -DSOQT_DLL'
                         LDFLAGS_LIBS += ' -lSoQt'
                 
                 if module == "coin":
-                    if sys.platform == 'win32':
+                    if sys.platform == 'win32' and "MSYSTEM" not in os.environ:
                         pass
                     else:
                         LDFLAGS_LIBS += ' -lCoin'
