Blame 0690-allow-static-tcltk.patch

ddb6764
diff -rupN Python-2.7.13/setup.py Python-2.7.13-new/setup.py
ddb6764
--- Python-2.7.13/setup.py	2017-01-21 01:46:11.753551536 +0100
ddb6764
+++ Python-2.7.13-new/setup.py	2017-01-21 01:46:12.038548493 +0100
ddb6764
@@ -554,7 +554,7 @@ class PyBuildExt(build_ext):
ddb6764
         if host_platform == 'hp-ux11':
ddb6764
             lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32']
ddb6764
 
ddb6764
-        if host_platform == 'darwin':
ddb6764
+        if host_platform in ['darwin', 'mingw', 'win32']:
ddb6764
             # This should work on any unixy platform ;-)
ddb6764
             # If the user has bothered specifying additional -I and -L flags
ddb6764
             # in OPT and LDFLAGS we might as well use them here.
ddb6764
@@ -563,6 +563,8 @@ class PyBuildExt(build_ext):
ddb6764
             # with whitespace in the name to store libraries.
ddb6764
             cflags, ldflags = sysconfig.get_config_vars(
ddb6764
                     'CFLAGS', 'LDFLAGS')
ddb6764
+            cflags = cflags + ' ' + ('',os.environ.get('CC'))[os.environ.get('CC') != None]
ddb6764
+            ldflags = ldflags + ' ' + ('',os.environ.get('LDSHARED'))[os.environ.get('LDSHARED') != None]
ddb6764
             for item in cflags.split():
ddb6764
                 if item.startswith('-I'):
ddb6764
                     inc_dirs.append(item[2:])
ddb6764
@@ -1957,14 +1959,19 @@ class PyBuildExt(build_ext):
ddb6764
         # The versions with dots are used on Unix, and the versions without
ddb6764
         # dots on Windows, for detection by cygwin.
ddb6764
         tcllib = tklib = tcl_includes = tk_includes = None
ddb6764
-        for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83',
ddb6764
-                        '8.2', '82', '8.1', '81', '8.0', '80']:
ddb6764
-            tklib = self.compiler.find_library_file(lib_dirs,
ddb6764
-                                                        'tk' + version)
ddb6764
-            tcllib = self.compiler.find_library_file(lib_dirs,
ddb6764
-                                                         'tcl' + version)
ddb6764
-            if tklib and tcllib:
ddb6764
-                # Exit the loop when we've found the Tcl/Tk libraries
ddb6764
+        tcltk_suffix = None
ddb6764
+        for suffix in ['', 's']:
ddb6764
+            for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83',
ddb6764
+                            '8.2', '82', '8.1', '81', '8.0', '80', '']:
ddb6764
+                tklib = self.compiler.find_library_file(lib_dirs,
ddb6764
+                                                            'tk' + version + suffix)
ddb6764
+                tcllib = self.compiler.find_library_file(lib_dirs,
ddb6764
+                                                             'tcl' + version + suffix)
ddb6764
+                if tklib and tcllib:
ddb6764
+                    # Exit the loop when we've found the Tcl/Tk libraries
ddb6764
+                    tcltk_suffix = suffix
ddb6764
+                    break
ddb6764
+            if tcltk_suffix != None:
ddb6764
                 break
ddb6764
 
ddb6764
         # Now check for the header files
ddb6764
@@ -2035,13 +2042,21 @@ class PyBuildExt(build_ext):
ddb6764
         # Add the Tcl/Tk libraries
ddb6764
         libs.append('tk'+ version)
ddb6764
         libs.append('tcl'+ version)
ddb6764
+        libs.append('tk'+ version + tcltk_suffix)
ddb6764
+        libs.append('tcl'+ version + tcltk_suffix)
ddb6764
+        if host_platform in ['mingw', 'win32']:
ddb6764
+            for winlib in ['ws2_32','gdi32','comctl32','comdlg32','imm32','uuid','oleaut32','ole32']:
ddb6764
+                libs.append( winlib )
ddb6764
 
ddb6764
         if host_platform in ['aix3', 'aix4']:
ddb6764
             libs.append('ld')
ddb6764
 
ddb6764
         # Finally, link with the X11 libraries (not appropriate on cygwin)
ddb6764
-        if host_platform != "cygwin":
ddb6764
+        # ...on those platforms, define STATIC_BUILD if linking to static tcl/tk.
ddb6764
+        if not host_platform in ['cygwin', 'mingw', 'win32']:
ddb6764
             libs.append('X11')
ddb6764
+        elif tcllib.endswith('s.a'):
ddb6764
+            defs.append( ('STATIC_BUILD',1) )
ddb6764
 
ddb6764
         ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
ddb6764
                         define_macros=[('WITH_APPINIT', 1)] + defs,