Blame 0250-MINGW-compiler-customize-mingw-cygwin-compilers.patch

ddb6764
diff -rupN Python-2.7.13/Lib/distutils/sysconfig.py Python-2.7.13-new/Lib/distutils/sysconfig.py
ddb6764
--- Python-2.7.13/Lib/distutils/sysconfig.py	2016-12-17 21:05:05.000000000 +0100
ddb6764
+++ Python-2.7.13-new/Lib/distutils/sysconfig.py	2017-01-21 01:46:06.137611495 +0100
ddb6764
@@ -154,7 +154,23 @@ def customize_compiler(compiler):
ddb6764
     Mainly needed on Unix, so we can plug in the information that
ddb6764
     varies across Unices and is stored in Python's Makefile.
ddb6764
     """
ddb6764
-    if compiler.compiler_type == "unix":
ddb6764
+    global _config_vars
ddb6764
+    if compiler.compiler_type in ["cygwin", "mingw32"]:
ddb6764
+        # Note that cygwin use posix build and 'unix' compiler.
ddb6764
+        # If build is not based on posix then we must predefine
ddb6764
+        # some environment variables corresponding to posix
ddb6764
+        # build rules and defaults.
ddb6764
+        if not 'GCC' in sys.version:
ddb6764
+            _config_vars['CC'] = "gcc"
ddb6764
+            _config_vars['CXX'] = "g++"
ddb6764
+            _config_vars['OPT'] = "-fwrapv -O3 -Wall -Wstrict-prototypes"
ddb6764
+            _config_vars['CFLAGS'] = ""
ddb6764
+            _config_vars['CCSHARED'] = ""
ddb6764
+            _config_vars['LDSHARED'] = "gcc -shared -Wl,--enable-auto-image-base"
ddb6764
+            _config_vars['AR'] = "ar"
ddb6764
+            _config_vars['ARFLAGS'] = "rc"
ddb6764
+
ddb6764
+    if compiler.compiler_type in ["unix", "cygwin", "mingw32"]:
ddb6764
         if sys.platform == "darwin":
ddb6764
             # Perform first-time customization of compiler-related
ddb6764
             # config vars on OS X now that we know we need a compiler.
ddb6764
@@ -164,7 +180,6 @@ def customize_compiler(compiler):
ddb6764
             # that Python itself was built on.  Also the user OS
ddb6764
             # version and build tools may not support the same set
ddb6764
             # of CPU architectures for universal builds.
ddb6764
-            global _config_vars
ddb6764
             # Use get_config_var() to ensure _config_vars is initialized.
ddb6764
             if not get_config_var('CUSTOMIZED_OSX_COMPILER'):
ddb6764
                 import _osx_support