0006-MINGW-static-tcltk.patch

Used to be local patch in platform/ndk.git 4ec84cccdda14ab4ebcafbc6f3200a2cd2868586

Change-Id: I31e0c5c9ede5b0892b35a0f761ae7e880e5e6203
diff --git a/Python-2.7.3/setup.py b/Python-2.7.3/setup.py
index 44be418..91fd56e 100644
--- a/Python-2.7.3/setup.py
+++ b/Python-2.7.3/setup.py
@@ -504,7 +504,7 @@
         if host_platform in ['osf1', 'unixware7', 'openunix8']:
             lib_dirs += ['/usr/ccs/lib']
 
-        if host_platform == 'darwin':
+        if host_platform in ['darwin', 'mingw', 'win32']:
             # This should work on any unixy platform ;-)
             # If the user has bothered specifying additional -I and -L flags
             # in OPT and LDFLAGS we might as well use them here.
@@ -514,6 +514,8 @@
             # FIXME: Why LDFLAGS again ?
             cflags, ldflags = sysconfig.get_config_vars(
                     'CFLAGS', 'LDFLAGS')
+            cflags = cflags + ' ' + ('',os.environ.get('CC'))[os.environ.get('CC') != None]
+            ldflags = ldflags + ' ' + ('',os.environ.get('LDSHARED'))[os.environ.get('LDSHARED') != None]
             for item in cflags.split():
                 if item.startswith('-I'):
                     inc_dirs.append(item[2:])
@@ -1851,14 +1853,19 @@
         # The versions with dots are used on Unix, and the versions without
         # dots on Windows, for detection by cygwin.
         tcllib = tklib = tcl_includes = tk_includes = None
-        for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83',
-                        '8.2', '82', '8.1', '81', '8.0', '80']:
-            tklib = self.compiler.find_library_file(lib_dirs,
-                                                        'tk' + version)
-            tcllib = self.compiler.find_library_file(lib_dirs,
-                                                         'tcl' + version)
-            if tklib and tcllib:
-                # Exit the loop when we've found the Tcl/Tk libraries
+        tcltk_suffix = None
+        for suffix in ['', 's']:
+            for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83',
+                            '8.2', '82', '8.1', '81', '8.0', '80', '']:
+                tklib = self.compiler.find_library_file(lib_dirs,
+                                                            'tk' + version + suffix)
+                tcllib = self.compiler.find_library_file(lib_dirs,
+                                                             'tcl' + version + suffix)
+                if tklib and tcllib:
+                    # Exit the loop when we've found the Tcl/Tk libraries
+                    tcltk_suffix = suffix
+                    break
+            if tcltk_suffix != None:
                 break
 
         # Now check for the header files
@@ -1927,15 +1934,21 @@
             libs.append('BLT')
 
         # Add the Tcl/Tk libraries
-        libs.append('tk'+ version)
-        libs.append('tcl'+ version)
+        libs.append('tk'+ version + tcltk_suffix)
+        libs.append('tcl'+ version + tcltk_suffix)
+        if host_platform in ['mingw', 'win32']:
+            for winlib in ['ws2_32','gdi32','comctl32','comdlg32','imm32','uuid','oleaut32','ole32']:
+                libs.append( winlib )
 
         if host_platform in ['aix3', 'aix4']:
             libs.append('ld')
 
         # Finally, link with the X11 libraries (not appropriate on cygwin, mingw)
+        # ...on those platforms, define STATIC_BUILD if linking to static tcl/tk.
         if not host_platform in ['cygwin', 'mingw', 'win32']:
             libs.append('X11')
+        elif tcllib.endswith('s.a'):
+            defs.append( ('STATIC_BUILD',1) )
 
         ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
                         define_macros=[('WITH_APPINIT', 1)] + defs,