annotate PCbuild/build_ssl.py @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents 749f5045ce59
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
65035
87f4b32905df Cosmetic fix to use print function.
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 64881
diff changeset
1 from __future__ import with_statement, print_function
39516
798becab3903 Build _hashlib on Windows. Build OpenSSL with masm assembler code.
Martin v. Löwis <martin@v.loewis.de>
parents: 39082
diff changeset
2 # Script for building the _ssl and _hashlib modules for Windows.
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
3 # Uses Perl to setup the OpenSSL environment correctly
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
4 # and build OpenSSL, then invokes a simple nmake session
39516
798becab3903 Build _hashlib on Windows. Build OpenSSL with masm assembler code.
Martin v. Löwis <martin@v.loewis.de>
parents: 39082
diff changeset
5 # for the actual _ssl.pyd and _hashlib.pyd DLLs.
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
6
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
7 # THEORETICALLY, you can:
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
8 # * Unpack the latest SSL release one level above your main Python source
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
9 # directory. It is likely you will already find the zlib library and
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
10 # any other external packages there.
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
11 # * Install ActivePerl and ensure it is somewhere on your path.
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
12 # * Run this script from the PCBuild directory.
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
13 #
39516
798becab3903 Build _hashlib on Windows. Build OpenSSL with masm assembler code.
Martin v. Löwis <martin@v.loewis.de>
parents: 39082
diff changeset
14 # it should configure and build SSL, then build the _ssl and _hashlib
798becab3903 Build _hashlib on Windows. Build OpenSSL with masm assembler code.
Martin v. Löwis <martin@v.loewis.de>
parents: 39082
diff changeset
15 # Python extensions without intervention.
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
16
43981
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
17 # Modified by Christian Heimes
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
18 # Now this script supports pre-generated makefiles and assembly files.
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
19 # Developers don't need an installation of Perl anymore to build Python. A svn
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
20 # checkout from our svn repository is enough.
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
21 #
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
22 # In Order to create the files in the case of an update you still need Perl.
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
23 # Run build_ssl in this order:
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
24 # python.exe build_ssl.py Release x64
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
25 # python.exe build_ssl.py Release Win32
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
26
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
27 import os, sys, re, shutil
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
28
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
29 # Find all "foo.exe" files on the PATH.
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
30 def find_all_on_path(filename, extras = None):
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
31 entries = os.environ["PATH"].split(os.pathsep)
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
32 ret = []
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
33 for p in entries:
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
34 fname = os.path.abspath(os.path.join(p, filename))
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
35 if os.path.isfile(fname) and fname not in ret:
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
36 ret.append(fname)
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
37 if extras:
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
38 for p in extras:
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
39 fname = os.path.abspath(os.path.join(p, filename))
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
40 if os.path.isfile(fname) and fname not in ret:
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
41 ret.append(fname)
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
42 return ret
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
43
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
44 # Find a suitable Perl installation for OpenSSL.
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
45 # cygwin perl does *not* work. ActivePerl does.
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
46 # Being a Perl dummy, the simplest way I can check is if the "Win32" package
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
47 # is available.
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
48 def find_working_perl(perls):
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
49 for perl in perls:
66800
b84261bd6d4a Merged revisions 85071-85072,85894,87132 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 65035
diff changeset
50 fh = os.popen('"%s" -e "use Win32;"' % perl)
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
51 fh.read()
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
52 rc = fh.close()
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
53 if rc:
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
54 continue
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
55 return perl
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
56 print("Can not find a suitable PERL:")
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
57 if perls:
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
58 print(" the following perl interpreters were found:")
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
59 for p in perls:
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
60 print(" ", p)
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
61 print(" None of these versions appear suitable for building OpenSSL")
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
62 else:
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
63 print(" NO perl interpreters were found on this machine at all!")
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
64 print(" Please install ActivePerl and ensure it appears on your path")
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
65 return None
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
66
77019
749f5045ce59 Use SSL directory from properties file.
Martin v. Löwis <martin@v.loewis.de>
parents: 68256
diff changeset
67 # Fetch SSL directory from VC properties
749f5045ce59 Use SSL directory from properties file.
Martin v. Löwis <martin@v.loewis.de>
parents: 68256
diff changeset
68 def get_ssl_dir():
749f5045ce59 Use SSL directory from properties file.
Martin v. Löwis <martin@v.loewis.de>
parents: 68256
diff changeset
69 propfile = (os.path.join(os.path.dirname(__file__), 'pyproject.vsprops'))
749f5045ce59 Use SSL directory from properties file.
Martin v. Löwis <martin@v.loewis.de>
parents: 68256
diff changeset
70 with open(propfile) as f:
749f5045ce59 Use SSL directory from properties file.
Martin v. Löwis <martin@v.loewis.de>
parents: 68256
diff changeset
71 m = re.search('openssl-([^"]+)"', f.read())
749f5045ce59 Use SSL directory from properties file.
Martin v. Löwis <martin@v.loewis.de>
parents: 68256
diff changeset
72 return "..\..\openssl-"+m.group(1)
749f5045ce59 Use SSL directory from properties file.
Martin v. Löwis <martin@v.loewis.de>
parents: 68256
diff changeset
73
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
74
43981
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
75 def create_makefile64(makefile, m32):
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
76 """Create and fix makefile for 64bit
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
77
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
78 Replace 32 with 64bit directories
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
79 """
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
80 if not os.path.isfile(m32):
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
81 return
57875
4d3b9b4caff0 Drop 2.4 compatibility.
Martin v. Löwis <martin@v.loewis.de>
parents: 45575
diff changeset
82 with open(m32) as fin:
4d3b9b4caff0 Drop 2.4 compatibility.
Martin v. Löwis <martin@v.loewis.de>
parents: 45575
diff changeset
83 with open(makefile, 'w') as fout:
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
84 for line in fin:
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
85 line = line.replace("=tmp32", "=tmp64")
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
86 line = line.replace("=out32", "=out64")
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
87 line = line.replace("=inc32", "=inc64")
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
88 # force 64 bit machine
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
89 line = line.replace("MKLIB=lib", "MKLIB=lib /MACHINE:X64")
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
90 line = line.replace("LFLAGS=", "LFLAGS=/MACHINE:X64 ")
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
91 # don't link against the lib on 64bit systems
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
92 line = line.replace("bufferoverflowu.lib", "")
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
93 fout.write(line)
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
94 os.unlink(m32)
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
95
43981
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
96 def fix_makefile(makefile):
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
97 """Fix some stuff in all makefiles
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
98 """
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
99 if not os.path.isfile(makefile):
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
100 return
45575
89cfb38a4b98 Port build_ssl.py to 2.4; support HOST_PYTHON variable
Martin v. Löwis <martin@v.loewis.de>
parents: 44395
diff changeset
101 # 2.4 compatibility
89cfb38a4b98 Port build_ssl.py to 2.4; support HOST_PYTHON variable
Martin v. Löwis <martin@v.loewis.de>
parents: 44395
diff changeset
102 fin = open(makefile)
89cfb38a4b98 Port build_ssl.py to 2.4; support HOST_PYTHON variable
Martin v. Löwis <martin@v.loewis.de>
parents: 44395
diff changeset
103 if 1: # with open(makefile) as fin:
43981
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
104 lines = fin.readlines()
45575
89cfb38a4b98 Port build_ssl.py to 2.4; support HOST_PYTHON variable
Martin v. Löwis <martin@v.loewis.de>
parents: 44395
diff changeset
105 fin.close()
89cfb38a4b98 Port build_ssl.py to 2.4; support HOST_PYTHON variable
Martin v. Löwis <martin@v.loewis.de>
parents: 44395
diff changeset
106 fout = open(makefile, 'w')
89cfb38a4b98 Port build_ssl.py to 2.4; support HOST_PYTHON variable
Martin v. Löwis <martin@v.loewis.de>
parents: 44395
diff changeset
107 if 1: # with open(makefile, 'w') as fout:
43981
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
108 for line in lines:
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
109 if line.startswith("PERL="):
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
110 continue
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
111 if line.startswith("CP="):
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
112 line = "CP=copy\n"
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
113 if line.startswith("MKDIR="):
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
114 line = "MKDIR=mkdir\n"
43999
b9b94785b2c7 Backport of fixes from py3k branch
Christian Heimes <christian@cheimes.de>
parents: 43981
diff changeset
115 if line.startswith("CFLAG="):
b9b94785b2c7 Backport of fixes from py3k branch
Christian Heimes <christian@cheimes.de>
parents: 43981
diff changeset
116 line = line.strip()
b9b94785b2c7 Backport of fixes from py3k branch
Christian Heimes <christian@cheimes.de>
parents: 43981
diff changeset
117 for algo in ("RC5", "MDC2", "IDEA"):
b9b94785b2c7 Backport of fixes from py3k branch
Christian Heimes <christian@cheimes.de>
parents: 43981
diff changeset
118 noalgo = " -DOPENSSL_NO_%s" % algo
b9b94785b2c7 Backport of fixes from py3k branch
Christian Heimes <christian@cheimes.de>
parents: 43981
diff changeset
119 if noalgo not in line:
b9b94785b2c7 Backport of fixes from py3k branch
Christian Heimes <christian@cheimes.de>
parents: 43981
diff changeset
120 line = line + noalgo
b9b94785b2c7 Backport of fixes from py3k branch
Christian Heimes <christian@cheimes.de>
parents: 43981
diff changeset
121 line = line + '\n'
43981
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
122 fout.write(line)
45575
89cfb38a4b98 Port build_ssl.py to 2.4; support HOST_PYTHON variable
Martin v. Löwis <martin@v.loewis.de>
parents: 44395
diff changeset
123 fout.close()
43981
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
124
39080
2a84b46ad64c Extend build_ssl to Win64, using VSExtComp.
Martin v. Löwis <martin@v.loewis.de>
parents: 32737
diff changeset
125 def run_configure(configure, do_script):
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
126 print("perl Configure "+configure)
39080
2a84b46ad64c Extend build_ssl to Win64, using VSExtComp.
Martin v. Löwis <martin@v.loewis.de>
parents: 32737
diff changeset
127 os.system("perl Configure "+configure)
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
128 print(do_script)
39080
2a84b46ad64c Extend build_ssl to Win64, using VSExtComp.
Martin v. Löwis <martin@v.loewis.de>
parents: 32737
diff changeset
129 os.system(do_script)
2a84b46ad64c Extend build_ssl to Win64, using VSExtComp.
Martin v. Löwis <martin@v.loewis.de>
parents: 32737
diff changeset
130
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
131 def main():
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
132 build_all = "-a" in sys.argv
39082
0de58bce47ef Fix Debug build of _ssl.
Martin v. Löwis <martin@v.loewis.de>
parents: 39080
diff changeset
133 if sys.argv[1] == "Release":
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
134 debug = False
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
135 elif sys.argv[1] == "Debug":
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
136 debug = True
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
137 else:
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
138 raise ValueError(str(sys.argv))
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
139
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
140 if sys.argv[2] == "Win32":
39080
2a84b46ad64c Extend build_ssl to Win64, using VSExtComp.
Martin v. Löwis <martin@v.loewis.de>
parents: 32737
diff changeset
141 arch = "x86"
2a84b46ad64c Extend build_ssl to Win64, using VSExtComp.
Martin v. Löwis <martin@v.loewis.de>
parents: 32737
diff changeset
142 configure = "VC-WIN32"
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
143 do_script = "ms\\do_nasm"
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
144 makefile="ms\\nt.mak"
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
145 m32 = makefile
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
146 elif sys.argv[2] == "x64":
39080
2a84b46ad64c Extend build_ssl to Win64, using VSExtComp.
Martin v. Löwis <martin@v.loewis.de>
parents: 32737
diff changeset
147 arch="amd64"
2a84b46ad64c Extend build_ssl to Win64, using VSExtComp.
Martin v. Löwis <martin@v.loewis.de>
parents: 32737
diff changeset
148 configure = "VC-WIN64A"
2a84b46ad64c Extend build_ssl to Win64, using VSExtComp.
Martin v. Löwis <martin@v.loewis.de>
parents: 32737
diff changeset
149 do_script = "ms\\do_win64a"
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
150 makefile = "ms\\nt64.mak"
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
151 m32 = makefile.replace('64', '')
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
152 #os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON"
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
153 else:
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
154 raise ValueError(str(sys.argv))
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
155
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
156 make_flags = ""
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
157 if build_all:
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
158 make_flags = "-a"
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
159 # perl should be on the path, but we also look in "\perl" and "c:\\perl"
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
160 # as "well known" locations
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
161 perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"])
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
162 perl = find_working_perl(perls)
66800
b84261bd6d4a Merged revisions 85071-85072,85894,87132 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 65035
diff changeset
163 if perl:
b84261bd6d4a Merged revisions 85071-85072,85894,87132 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 65035
diff changeset
164 print("Found a working perl at '%s'" % (perl,))
b84261bd6d4a Merged revisions 85071-85072,85894,87132 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 65035
diff changeset
165 else:
43981
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
166 print("No Perl installation was found. Existing Makefiles are used.")
39516
798becab3903 Build _hashlib on Windows. Build OpenSSL with masm assembler code.
Martin v. Löwis <martin@v.loewis.de>
parents: 39082
diff changeset
167 sys.stdout.flush()
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
168 # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live.
77019
749f5045ce59 Use SSL directory from properties file.
Martin v. Löwis <martin@v.loewis.de>
parents: 68256
diff changeset
169 ssl_dir = get_ssl_dir()
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
170 if ssl_dir is None:
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
171 sys.exit(1)
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
172
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
173 old_cd = os.getcwd()
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
174 try:
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
175 os.chdir(ssl_dir)
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
176 # rebuild makefile when we do the role over from 32 to 64 build
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
177 if arch == "amd64" and os.path.isfile(m32) and not os.path.isfile(makefile):
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
178 os.unlink(m32)
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
179
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
180 # If the ssl makefiles do not exist, we invoke Perl to generate them.
39542
edb162100979 Merge 51340 and 51341 from 2.5 branch:
Martin v. Löwis <martin@v.loewis.de>
parents: 39516
diff changeset
181 # Due to a bug in this script, the makefile sometimes ended up empty
edb162100979 Merge 51340 and 51341 from 2.5 branch:
Martin v. Löwis <martin@v.loewis.de>
parents: 39516
diff changeset
182 # Force a regeneration if it is.
edb162100979 Merge 51340 and 51341 from 2.5 branch:
Martin v. Löwis <martin@v.loewis.de>
parents: 39516
diff changeset
183 if not os.path.isfile(makefile) or os.path.getsize(makefile)==0:
43981
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
184 if perl is None:
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
185 print("Perl is required to build the makefiles!")
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
186 sys.exit(1)
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
187
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
188 print("Creating the makefiles...")
39516
798becab3903 Build _hashlib on Windows. Build OpenSSL with masm assembler code.
Martin v. Löwis <martin@v.loewis.de>
parents: 39082
diff changeset
189 sys.stdout.flush()
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
190 # Put our working Perl at the front of our path
39516
798becab3903 Build _hashlib on Windows. Build OpenSSL with masm assembler code.
Martin v. Löwis <martin@v.loewis.de>
parents: 39082
diff changeset
191 os.environ["PATH"] = os.path.dirname(perl) + \
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
192 os.pathsep + \
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
193 os.environ["PATH"]
39542
edb162100979 Merge 51340 and 51341 from 2.5 branch:
Martin v. Löwis <martin@v.loewis.de>
parents: 39516
diff changeset
194 run_configure(configure, do_script)
43981
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
195 if debug:
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
196 print("OpenSSL debug builds aren't supported.")
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
197 #if arch=="x86" and debug:
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
198 # # the do_masm script in openssl doesn't generate a debug
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
199 # # build makefile so we generate it here:
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
200 # os.system("perl util\mk1mf.pl debug "+configure+" >"+makefile)
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
201
43981
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
202 if arch == "amd64":
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
203 create_makefile64(makefile, m32)
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
204 fix_makefile(makefile)
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
205 shutil.copy(r"crypto\buildinf.h", r"crypto\buildinf_%s.h" % arch)
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
206 shutil.copy(r"crypto\opensslconf.h", r"crypto\opensslconf_%s.h" % arch)
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
207
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
208 # Now run make.
43981
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
209 if arch == "amd64":
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
210 rc = os.system(r"ml64 -c -Foms\uptable.obj ms\uptable.asm")
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
211 if rc:
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
212 print("ml64 assembler has failed.")
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
213 sys.exit(rc)
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
214
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
215 shutil.copy(r"crypto\buildinf_%s.h" % arch, r"crypto\buildinf.h")
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
216 shutil.copy(r"crypto\opensslconf_%s.h" % arch, r"crypto\opensslconf.h")
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
217
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
218 #makeCommand = "nmake /nologo PERL=\"%s\" -f \"%s\"" %(perl, makefile)
62cf08a64bc2 Backport of PCbuild9 fixes from py3k r59130
Christian Heimes <christian@cheimes.de>
parents: 43972
diff changeset
219 makeCommand = "nmake /nologo -f \"%s\"" % makefile
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
220 print("Executing ssl makefiles:", makeCommand)
39516
798becab3903 Build _hashlib on Windows. Build OpenSSL with masm assembler code.
Martin v. Löwis <martin@v.loewis.de>
parents: 39082
diff changeset
221 sys.stdout.flush()
39542
edb162100979 Merge 51340 and 51341 from 2.5 branch:
Martin v. Löwis <martin@v.loewis.de>
parents: 39516
diff changeset
222 rc = os.system(makeCommand)
39080
2a84b46ad64c Extend build_ssl to Win64, using VSExtComp.
Martin v. Löwis <martin@v.loewis.de>
parents: 32737
diff changeset
223 if rc:
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
224 print("Executing "+makefile+" failed")
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
225 print(rc)
39080
2a84b46ad64c Extend build_ssl to Win64, using VSExtComp.
Martin v. Löwis <martin@v.loewis.de>
parents: 32737
diff changeset
226 sys.exit(rc)
26502
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
227 finally:
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
228 os.chdir(old_cd)
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
229 sys.exit(rc)
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
230
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
231 if __name__=='__main__':
671327195dc3 Add _ssl build process for Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
diff changeset
232 main()