Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 1 | """Script to compile the dependencies of _tkinter |
| 2 | |
| 3 | Copyright (c) 2007 by Christian Heimes <christian@cheimes.de> |
| 4 | |
| 5 | Licensed to PSF under a Contributor Agreement. |
| 6 | """ |
| 7 | |
| 8 | import os |
| 9 | import sys |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 10 | |
| 11 | here = os.path.abspath(os.path.dirname(__file__)) |
| 12 | par = os.path.pardir |
| 13 | |
Martin v. Löwis | f38e0d0 | 2008-06-13 14:11:59 +0000 | [diff] [blame] | 14 | TCL = "tcl8.5.2" |
| 15 | TK = "tk8.5.2" |
| 16 | TIX = "tix-8.4.0.x" |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 17 | |
Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 18 | ROOT = os.path.abspath(os.path.join(here, par, par)) |
| 19 | # Windows 2000 compatibility: WINVER 0x0500 |
| 20 | # http://msdn2.microsoft.com/en-us/library/aa383745.aspx |
Christian Heimes | faf2f63 | 2008-01-06 16:59:19 +0000 | [diff] [blame] | 21 | NMAKE = ('nmake /nologo /f %s ' |
Christian Heimes | 25bb783 | 2008-01-11 16:17:00 +0000 | [diff] [blame] | 22 | 'COMPILERFLAGS=\"-DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=NTDDI_WIN2KSP4\" ' |
Christian Heimes | faf2f63 | 2008-01-06 16:59:19 +0000 | [diff] [blame] | 23 | '%s %s') |
Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 24 | |
| 25 | def nmake(makefile, command="", **kw): |
| 26 | defines = ' '.join(k+'='+v for k, v in kw.items()) |
| 27 | cmd = NMAKE % (makefile, defines, command) |
| 28 | print("\n\n"+cmd+"\n") |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 29 | if os.system(cmd) != 0: |
| 30 | raise RuntimeError(cmd) |
| 31 | |
| 32 | def build(platform, clean): |
| 33 | if platform == "Win32": |
| 34 | dest = os.path.join(ROOT, "tcltk") |
| 35 | machine = "X86" |
Martin v. Löwis | f38e0d0 | 2008-06-13 14:11:59 +0000 | [diff] [blame] | 36 | elif platform == "AMD64": |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 37 | dest = os.path.join(ROOT, "tcltk64") |
Martin v. Löwis | f38e0d0 | 2008-06-13 14:11:59 +0000 | [diff] [blame] | 38 | machine = "AMD64" |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 39 | else: |
| 40 | raise ValueError(platform) |
| 41 | |
| 42 | # TCL |
| 43 | tcldir = os.path.join(ROOT, TCL) |
Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 44 | if 1: |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 45 | os.chdir(os.path.join(tcldir, "win")) |
| 46 | if clean: |
Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 47 | nmake("makefile.vc", "clean") |
Martin v. Löwis | f38e0d0 | 2008-06-13 14:11:59 +0000 | [diff] [blame] | 48 | nmake("makefile.vc", MACHINE=machine) |
| 49 | nmake("makefile.vc", "install", INSTALLDIR=dest, MACHINE=machine) |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 50 | |
| 51 | # TK |
Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 52 | if 1: |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 53 | os.chdir(os.path.join(ROOT, TK, "win")) |
| 54 | if clean: |
Benjamin Peterson | 247a9b8 | 2009-02-20 04:09:19 +0000 | [diff] [blame] | 55 | nmake("makefile.vc", "clean", DEBUG=0, TCLDIR=tcldir) |
| 56 | nmake("makefile.vc", DEBUG=0, MACHINE=machine) |
| 57 | nmake("makefile.vc", "install", DEBUG=0, INSTALLDIR=dest, MACHINE=machine) |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 58 | |
| 59 | # TIX |
Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 60 | if 1: |
Christian Heimes | 255f53b | 2007-12-08 15:33:56 +0000 | [diff] [blame] | 61 | # python9.mak is available at http://svn.python.org |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 62 | os.chdir(os.path.join(ROOT, TIX, "win")) |
| 63 | if clean: |
Benjamin Peterson | 247a9b8 | 2009-02-20 04:09:19 +0000 | [diff] [blame] | 64 | nmake("python.mak", "clean") |
| 65 | nmake("python.mak", MACHINE=machine, INSTALL_DIR=dest) |
| 66 | nmake("python.mak", "install", INSTALL_DIR=dest) |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 67 | |
| 68 | def main(): |
Martin v. Löwis | f38e0d0 | 2008-06-13 14:11:59 +0000 | [diff] [blame] | 69 | if len(sys.argv) < 2 or sys.argv[1] not in ("Win32", "AMD64"): |
| 70 | print("%s Win32|AMD64" % sys.argv[0]) |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 71 | sys.exit(1) |
| 72 | |
| 73 | if "-c" in sys.argv: |
| 74 | clean = True |
| 75 | else: |
| 76 | clean = False |
| 77 | |
| 78 | build(sys.argv[1], clean) |
| 79 | |
| 80 | |
| 81 | if __name__ == '__main__': |
| 82 | main() |