Skip to content

Commit bedb0f7

Browse files
author
hirokazu.yamamoto
committed
Merged revisions 70448 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r70448 | hirokazu.yamamoto | 2009-03-18 19:17:26 +0900 | 3 lines Updated openssl support on VC6. (openssl-0.9.6g is old, cannot compile with _ssl.c) If you use http://svn.python.org/projects/external/openssl-0.9.8g, Perl is not needed. This scheme was ported from PCBuild. ........ git-svn-id: http://svn.python.org/projects/python/branches/py3k@70450 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent e8f95e1 commit bedb0f7

3 files changed

Lines changed: 98 additions & 58 deletions

File tree

PC/VC6/_ssl.mak

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
MODULE=_ssl_d.pyd
44
TEMP_DIR=x86-temp-debug/_ssl
55
CFLAGS=/Od /Zi /MDd /LDd /DDEBUG /D_DEBUG /DWIN32
6-
SSL_LIB_DIR=$(SSL_DIR)/out32.dbg
6+
LFLAGS=/nodefaultlib:"msvcrt"
77
!ELSE
88
MODULE=_ssl.pyd
99
TEMP_DIR=x86-temp-release/_ssl
1010
CFLAGS=/Ox /MD /LD /DWIN32
11-
SSL_LIB_DIR=$(SSL_DIR)/out32
11+
LFLAGS=
1212
!ENDIF
1313

1414
INCLUDES=-I ../../Include -I .. -I $(SSL_DIR)/inc32
15+
SSL_LIB_DIR=$(SSL_DIR)/out32
1516
LIBS=gdi32.lib wsock32.lib user32.lib advapi32.lib /libpath:$(SSL_LIB_DIR) libeay32.lib ssleay32.lib
1617

1718
SOURCE=../../Modules/_ssl.c $(SSL_LIB_DIR)/libeay32.lib $(SSL_LIB_DIR)/ssleay32.lib
1819

1920
$(MODULE): $(SOURCE) ../*.h ../../Include/*.h
2021
@if not exist "$(TEMP_DIR)/." mkdir "$(TEMP_DIR)"
21-
cl /nologo $(SOURCE) $(CFLAGS) /Fo$(TEMP_DIR)\$*.obj $(INCLUDES) /link /out:$(MODULE) $(LIBS)
22+
cl /nologo $(SOURCE) $(CFLAGS) /Fo$(TEMP_DIR)\$*.obj $(INCLUDES) /link /out:$(MODULE) $(LIBS) $(LFLAGS)

PC/VC6/build_ssl.py

Lines changed: 91 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# it should configure and build SSL, then build the ssl Python extension
1414
# without intervention.
1515

16-
import os, sys, re
16+
import os, sys, re, shutil
1717

1818
# Find all "foo.exe" files on the PATH.
1919
def find_all_on_path(filename, extras = None):
@@ -42,24 +42,24 @@ def find_working_perl(perls):
4242
if rc:
4343
continue
4444
return perl
45-
print "Can not find a suitable PERL:"
45+
print("Can not find a suitable PERL:")
4646
if perls:
47-
print " the following perl interpreters were found:"
47+
print(" the following perl interpreters were found:")
4848
for p in perls:
49-
print " ", p
50-
print " None of these versions appear suitable for building OpenSSL"
49+
print(" ", p)
50+
print(" None of these versions appear suitable for building OpenSSL")
5151
else:
52-
print " NO perl interpreters were found on this machine at all!"
53-
print " Please install ActivePerl and ensure it appears on your path"
54-
print "The Python SSL module was not built"
52+
print(" NO perl interpreters were found on this machine at all!")
53+
print(" Please install ActivePerl and ensure it appears on your path")
5554
return None
5655

5756
# Locate the best SSL directory given a few roots to look into.
5857
def find_best_ssl_dir(sources):
5958
candidates = []
6059
for s in sources:
6160
try:
62-
s = os.path.abspath(s)
61+
# note: do not abspath s; the build will fail if any
62+
# higher up directory name has spaces in it.
6363
fnames = os.listdir(s)
6464
except os.error:
6565
fnames = []
@@ -79,14 +79,57 @@ def find_best_ssl_dir(sources):
7979
best_parts = parts
8080
best_name = c
8181
if best_name is not None:
82-
print "Found an SSL directory at '%s'" % (best_name,)
82+
print("Found an SSL directory at '%s'" % (best_name,))
8383
else:
84-
print "Could not find an SSL directory in '%s'" % (sources,)
84+
print("Could not find an SSL directory in '%s'" % (sources,))
85+
sys.stdout.flush()
8586
return best_name
8687

88+
def fix_makefile(makefile):
89+
"""Fix some stuff in all makefiles
90+
"""
91+
if not os.path.isfile(makefile):
92+
return
93+
# 2.4 compatibility
94+
fin = open(makefile)
95+
if 1: # with open(makefile) as fin:
96+
lines = fin.readlines()
97+
fin.close()
98+
fout = open(makefile, 'w')
99+
if 1: # with open(makefile, 'w') as fout:
100+
for line in lines:
101+
if line.startswith("PERL="):
102+
continue
103+
if line.startswith("CP="):
104+
line = "CP=copy\n"
105+
if line.startswith("MKDIR="):
106+
line = "MKDIR=mkdir\n"
107+
if line.startswith("CFLAG="):
108+
line = line.strip()
109+
for algo in ("RC5", "MDC2", "IDEA"):
110+
noalgo = " -DOPENSSL_NO_%s" % algo
111+
if noalgo not in line:
112+
line = line + noalgo
113+
line = line + '\n'
114+
fout.write(line)
115+
fout.close()
116+
117+
def run_configure(configure, do_script):
118+
print("perl Configure "+configure)
119+
os.system("perl Configure "+configure)
120+
print(do_script)
121+
os.system(do_script)
122+
87123
def main():
88124
debug = "-d" in sys.argv
89125
build_all = "-a" in sys.argv
126+
if 1: # Win32
127+
arch = "x86"
128+
configure = "VC-WIN32"
129+
do_script = "ms\\do_nasm"
130+
makefile="ms\\nt.mak"
131+
m32 = makefile
132+
configure += " no-idea no-rc5 no-mdc2"
90133
make_flags = ""
91134
if build_all:
92135
make_flags = "-a"
@@ -95,61 +138,57 @@ def main():
95138
perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"])
96139
perl = find_working_perl(perls)
97140
if perl is None:
98-
sys.exit(1)
99-
100-
print "Found a working perl at '%s'" % (perl,)
141+
print("No Perl installation was found. Existing Makefiles are used.")
142+
else:
143+
print("Found a working perl at '%s'" % (perl,))
144+
sys.stdout.flush()
101145
# Look for SSL 3 levels up from pcbuild - ie, same place zlib etc all live.
102-
ssl_dir = find_best_ssl_dir(("../../..",))
146+
ssl_dir = find_best_ssl_dir(("..\\..\\..",))
103147
if ssl_dir is None:
104148
sys.exit(1)
105149

106150
old_cd = os.getcwd()
107151
try:
108152
os.chdir(ssl_dir)
109153
# If the ssl makefiles do not exist, we invoke Perl to generate them.
110-
if not os.path.isfile(os.path.join(ssl_dir, "32.mak")) or \
111-
not os.path.isfile(os.path.join(ssl_dir, "d32.mak")):
112-
print "Creating the makefiles..."
154+
# Due to a bug in this script, the makefile sometimes ended up empty
155+
# Force a regeneration if it is.
156+
if not os.path.isfile(makefile) or os.path.getsize(makefile)==0:
157+
if perl is None:
158+
print("Perl is required to build the makefiles!")
159+
sys.exit(1)
160+
161+
print("Creating the makefiles...")
162+
sys.stdout.flush()
113163
# Put our working Perl at the front of our path
114-
os.environ["PATH"] = os.path.split(perl)[0] + \
164+
os.environ["PATH"] = os.path.dirname(perl) + \
115165
os.pathsep + \
116166
os.environ["PATH"]
117-
# ms\32all.bat will reconfigure OpenSSL and then try to build
118-
# all outputs (debug/nondebug/dll/lib). So we filter the file
119-
# to exclude any "nmake" commands and then execute.
120-
tempname = "ms\\32all_py.bat"
167+
run_configure(configure, do_script)
168+
if debug:
169+
print("OpenSSL debug builds aren't supported.")
170+
#if arch=="x86" and debug:
171+
# # the do_masm script in openssl doesn't generate a debug
172+
# # build makefile so we generate it here:
173+
# os.system("perl util\mk1mf.pl debug "+configure+" >"+makefile)
121174

122-
in_bat = open("ms\\32all.bat")
123-
temp_bat = open(tempname,"w")
124-
while 1:
125-
cmd = in_bat.readline()
126-
print 'cmd', repr(cmd)
127-
if not cmd: break
128-
if cmd.strip()[:5].lower() == "nmake":
129-
continue
130-
temp_bat.write(cmd)
131-
in_bat.close()
132-
temp_bat.close()
133-
os.system(tempname)
134-
try:
135-
os.remove(tempname)
136-
except:
137-
pass
175+
fix_makefile(makefile)
176+
shutil.copy(r"crypto\buildinf.h", r"crypto\buildinf_%s.h" % arch)
177+
shutil.copy(r"crypto\opensslconf.h", r"crypto\opensslconf_%s.h" % arch)
138178

139179
# Now run make.
140-
print "Executing nmake over the ssl makefiles..."
141-
if debug:
142-
rc = os.system("nmake /nologo -f d32.mak")
143-
if rc:
144-
print "Executing d32.mak failed"
145-
print rc
146-
sys.exit(rc)
147-
else:
148-
rc = os.system("nmake /nologo -f 32.mak")
149-
if rc:
150-
print "Executing 32.mak failed"
151-
print rc
152-
sys.exit(rc)
180+
shutil.copy(r"crypto\buildinf_%s.h" % arch, r"crypto\buildinf.h")
181+
shutil.copy(r"crypto\opensslconf_%s.h" % arch, r"crypto\opensslconf.h")
182+
183+
#makeCommand = "nmake /nologo PERL=\"%s\" -f \"%s\"" %(perl, makefile)
184+
makeCommand = "nmake /nologo -f \"%s\"" % makefile
185+
print("Executing ssl makefiles:", makeCommand)
186+
sys.stdout.flush()
187+
rc = os.system(makeCommand)
188+
if rc:
189+
print("Executing "+makefile+" failed")
190+
print(rc)
191+
sys.exit(rc)
153192
finally:
154193
os.chdir(old_cd)
155194
# And finally, we can build the _ssl module itself for Python.

PC/VC6/readme.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ _ssl
150150
http://www.openssl.org
151151

152152
You (probably) don't want the "engine" code. For example, get
153-
openssl-0.9.6g.tar.gz
153+
openssl-0.9.8g.tar.gz
154154
not
155-
openssl-engine-0.9.6g.tar.gz
155+
openssl-engine-0.9.8g.tar.gz
156156

157157
Unpack into the "dist" directory, retaining the folder name from
158158
the archive - for example, the latest stable OpenSSL will install as
159-
dist/openssl-0.9.6g
159+
dist/openssl-0.9.8g
160160

161161
You can (theoretically) use any version of OpenSSL you like - the
162162
build process will automatically select the latest version.

0 commit comments

Comments
 (0)