blob: 2d5797f38dcced9d7f085ac4cc7882e5d4643fe3 [file] [log] [blame]
Christian Heimes8b011402007-11-27 21:28:40 +00001"""Script to compile the dependencies of _tkinter
2
3Copyright (c) 2007 by Christian Heimes <christian@cheimes.de>
4
5Licensed to PSF under a Contributor Agreement.
6"""
7
8import os
9import sys
Christian Heimes8b011402007-11-27 21:28:40 +000010
11here = os.path.abspath(os.path.dirname(__file__))
12par = os.path.pardir
13
Martin v. Löwisdb2c9f42008-06-12 18:38:47 +000014TCL = "tcl8.5.2"
15TK = "tk8.5.2"
16TIX = "tix-8.4.0.x"
Christian Heimes8b011402007-11-27 21:28:40 +000017
Christian Heimes8affb5f2007-12-18 03:38:03 +000018ROOT = 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 Heimes3001c542008-01-05 21:35:52 +000021NMAKE = ('nmake /nologo /f %s '
Thomas Hellerd17315f2008-01-11 08:04:03 +000022 'COMPILERFLAGS=\"-DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=NTDDI_WIN2KSP4\" '
Christian Heimes3001c542008-01-05 21:35:52 +000023 '%s %s')
Christian Heimes8affb5f2007-12-18 03:38:03 +000024
25def 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 Heimes8b011402007-11-27 21:28:40 +000029 if os.system(cmd) != 0:
30 raise RuntimeError(cmd)
31
32def build(platform, clean):
33 if platform == "Win32":
34 dest = os.path.join(ROOT, "tcltk")
35 machine = "X86"
Martin v. Löwisdb2c9f42008-06-12 18:38:47 +000036 elif platform == "AMD64":
Christian Heimes8b011402007-11-27 21:28:40 +000037 dest = os.path.join(ROOT, "tcltk64")
Martin v. Löwisdb2c9f42008-06-12 18:38:47 +000038 machine = "AMD64"
Christian Heimes8b011402007-11-27 21:28:40 +000039 else:
40 raise ValueError(platform)
41
42 # TCL
43 tcldir = os.path.join(ROOT, TCL)
Martin v. Löwisa41be1d2008-06-12 19:00:14 +000044 if 1:
Christian Heimes8b011402007-11-27 21:28:40 +000045 os.chdir(os.path.join(tcldir, "win"))
46 if clean:
Christian Heimes8affb5f2007-12-18 03:38:03 +000047 nmake("makefile.vc", "clean")
Martin v. Löwisdb2c9f42008-06-12 18:38:47 +000048 nmake("makefile.vc", MACHINE=machine)
49 nmake("makefile.vc", "install", INSTALLDIR=dest, MACHINE=machine)
Christian Heimes8b011402007-11-27 21:28:40 +000050
51 # TK
Martin v. Löwisa41be1d2008-06-12 19:00:14 +000052 if 1:
Christian Heimes8b011402007-11-27 21:28:40 +000053 os.chdir(os.path.join(ROOT, TK, "win"))
54 if clean:
Martin v. Löwisa63b9952009-02-13 20:26:16 +000055 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 Heimes8b011402007-11-27 21:28:40 +000058
59 # TIX
Christian Heimes8affb5f2007-12-18 03:38:03 +000060 if 1:
Christian Heimes3d2f5642007-12-06 21:13:06 +000061 # python9.mak is available at http://svn.python.org
Christian Heimes8b011402007-11-27 21:28:40 +000062 os.chdir(os.path.join(ROOT, TIX, "win"))
63 if clean:
Martin v. Löwisa63b9952009-02-13 20:26:16 +000064 nmake("python.mak", "clean")
65 nmake("python.mak", MACHINE=machine, INSTALL_DIR=dest)
66 nmake("python.mak", "install", INSTALL_DIR=dest)
Christian Heimes8b011402007-11-27 21:28:40 +000067
68def main():
Martin v. Löwisdb2c9f42008-06-12 18:38:47 +000069 if len(sys.argv) < 2 or sys.argv[1] not in ("Win32", "AMD64"):
70 print("%s Win32|AMD64" % sys.argv[0])
Christian Heimes8b011402007-11-27 21:28:40 +000071 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
81if __name__ == '__main__':
82 main()