Merged revisions 70448 via svnmerge from
svn+ssh://pythondev@svn.python.org/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. ........
This commit is contained in:
parent
ca88cd1792
commit
6c87e8b741
|
@ -3,19 +3,20 @@
|
||||||
MODULE=_ssl_d.pyd
|
MODULE=_ssl_d.pyd
|
||||||
TEMP_DIR=x86-temp-debug/_ssl
|
TEMP_DIR=x86-temp-debug/_ssl
|
||||||
CFLAGS=/Od /Zi /MDd /LDd /DDEBUG /D_DEBUG /DWIN32
|
CFLAGS=/Od /Zi /MDd /LDd /DDEBUG /D_DEBUG /DWIN32
|
||||||
SSL_LIB_DIR=$(SSL_DIR)/out32.dbg
|
LFLAGS=/nodefaultlib:"msvcrt"
|
||||||
!ELSE
|
!ELSE
|
||||||
MODULE=_ssl.pyd
|
MODULE=_ssl.pyd
|
||||||
TEMP_DIR=x86-temp-release/_ssl
|
TEMP_DIR=x86-temp-release/_ssl
|
||||||
CFLAGS=/Ox /MD /LD /DWIN32
|
CFLAGS=/Ox /MD /LD /DWIN32
|
||||||
SSL_LIB_DIR=$(SSL_DIR)/out32
|
LFLAGS=
|
||||||
!ENDIF
|
!ENDIF
|
||||||
|
|
||||||
INCLUDES=-I ../../Include -I .. -I $(SSL_DIR)/inc32
|
INCLUDES=-I ../../Include -I .. -I $(SSL_DIR)/inc32
|
||||||
|
SSL_LIB_DIR=$(SSL_DIR)/out32
|
||||||
LIBS=gdi32.lib wsock32.lib user32.lib advapi32.lib /libpath:$(SSL_LIB_DIR) libeay32.lib ssleay32.lib
|
LIBS=gdi32.lib wsock32.lib user32.lib advapi32.lib /libpath:$(SSL_LIB_DIR) libeay32.lib ssleay32.lib
|
||||||
|
|
||||||
SOURCE=../../Modules/_ssl.c $(SSL_LIB_DIR)/libeay32.lib $(SSL_LIB_DIR)/ssleay32.lib
|
SOURCE=../../Modules/_ssl.c $(SSL_LIB_DIR)/libeay32.lib $(SSL_LIB_DIR)/ssleay32.lib
|
||||||
|
|
||||||
$(MODULE): $(SOURCE) ../*.h ../../Include/*.h
|
$(MODULE): $(SOURCE) ../*.h ../../Include/*.h
|
||||||
@if not exist "$(TEMP_DIR)/." mkdir "$(TEMP_DIR)"
|
@if not exist "$(TEMP_DIR)/." mkdir "$(TEMP_DIR)"
|
||||||
cl /nologo $(SOURCE) $(CFLAGS) /Fo$(TEMP_DIR)\$*.obj $(INCLUDES) /link /out:$(MODULE) $(LIBS)
|
cl /nologo $(SOURCE) $(CFLAGS) /Fo$(TEMP_DIR)\$*.obj $(INCLUDES) /link /out:$(MODULE) $(LIBS) $(LFLAGS)
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# it should configure and build SSL, then build the ssl Python extension
|
# it should configure and build SSL, then build the ssl Python extension
|
||||||
# without intervention.
|
# without intervention.
|
||||||
|
|
||||||
import os, sys, re
|
import os, sys, re, shutil
|
||||||
|
|
||||||
# Find all "foo.exe" files on the PATH.
|
# Find all "foo.exe" files on the PATH.
|
||||||
def find_all_on_path(filename, extras = None):
|
def find_all_on_path(filename, extras = None):
|
||||||
|
@ -51,7 +51,6 @@ def find_working_perl(perls):
|
||||||
else:
|
else:
|
||||||
print " NO perl interpreters were found on this machine at all!"
|
print " NO perl interpreters were found on this machine at all!"
|
||||||
print " Please install ActivePerl and ensure it appears on your path"
|
print " Please install ActivePerl and ensure it appears on your path"
|
||||||
print "The Python SSL module was not built"
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Locate the best SSL directory given a few roots to look into.
|
# Locate the best SSL directory given a few roots to look into.
|
||||||
|
@ -59,7 +58,8 @@ def find_best_ssl_dir(sources):
|
||||||
candidates = []
|
candidates = []
|
||||||
for s in sources:
|
for s in sources:
|
||||||
try:
|
try:
|
||||||
s = os.path.abspath(s)
|
# note: do not abspath s; the build will fail if any
|
||||||
|
# higher up directory name has spaces in it.
|
||||||
fnames = os.listdir(s)
|
fnames = os.listdir(s)
|
||||||
except os.error:
|
except os.error:
|
||||||
fnames = []
|
fnames = []
|
||||||
|
@ -82,11 +82,54 @@ def find_best_ssl_dir(sources):
|
||||||
print "Found an SSL directory at '%s'" % (best_name,)
|
print "Found an SSL directory at '%s'" % (best_name,)
|
||||||
else:
|
else:
|
||||||
print "Could not find an SSL directory in '%s'" % (sources,)
|
print "Could not find an SSL directory in '%s'" % (sources,)
|
||||||
|
sys.stdout.flush()
|
||||||
return best_name
|
return best_name
|
||||||
|
|
||||||
|
def fix_makefile(makefile):
|
||||||
|
"""Fix some stuff in all makefiles
|
||||||
|
"""
|
||||||
|
if not os.path.isfile(makefile):
|
||||||
|
return
|
||||||
|
# 2.4 compatibility
|
||||||
|
fin = open(makefile)
|
||||||
|
if 1: # with open(makefile) as fin:
|
||||||
|
lines = fin.readlines()
|
||||||
|
fin.close()
|
||||||
|
fout = open(makefile, 'w')
|
||||||
|
if 1: # with open(makefile, 'w') as fout:
|
||||||
|
for line in lines:
|
||||||
|
if line.startswith("PERL="):
|
||||||
|
continue
|
||||||
|
if line.startswith("CP="):
|
||||||
|
line = "CP=copy\n"
|
||||||
|
if line.startswith("MKDIR="):
|
||||||
|
line = "MKDIR=mkdir\n"
|
||||||
|
if line.startswith("CFLAG="):
|
||||||
|
line = line.strip()
|
||||||
|
for algo in ("RC5", "MDC2", "IDEA"):
|
||||||
|
noalgo = " -DOPENSSL_NO_%s" % algo
|
||||||
|
if noalgo not in line:
|
||||||
|
line = line + noalgo
|
||||||
|
line = line + '\n'
|
||||||
|
fout.write(line)
|
||||||
|
fout.close()
|
||||||
|
|
||||||
|
def run_configure(configure, do_script):
|
||||||
|
print "perl Configure "+configure
|
||||||
|
os.system("perl Configure "+configure)
|
||||||
|
print do_script
|
||||||
|
os.system(do_script)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
debug = "-d" in sys.argv
|
debug = "-d" in sys.argv
|
||||||
build_all = "-a" in sys.argv
|
build_all = "-a" in sys.argv
|
||||||
|
if 1: # Win32
|
||||||
|
arch = "x86"
|
||||||
|
configure = "VC-WIN32"
|
||||||
|
do_script = "ms\\do_nasm"
|
||||||
|
makefile="ms\\nt.mak"
|
||||||
|
m32 = makefile
|
||||||
|
configure += " no-idea no-rc5 no-mdc2"
|
||||||
make_flags = ""
|
make_flags = ""
|
||||||
if build_all:
|
if build_all:
|
||||||
make_flags = "-a"
|
make_flags = "-a"
|
||||||
|
@ -95,11 +138,12 @@ def main():
|
||||||
perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"])
|
perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"])
|
||||||
perl = find_working_perl(perls)
|
perl = find_working_perl(perls)
|
||||||
if perl is None:
|
if perl is None:
|
||||||
sys.exit(1)
|
print "No Perl installation was found. Existing Makefiles are used."
|
||||||
|
else:
|
||||||
print "Found a working perl at '%s'" % (perl,)
|
print "Found a working perl at '%s'" % (perl,)
|
||||||
|
sys.stdout.flush()
|
||||||
# Look for SSL 3 levels up from pcbuild - ie, same place zlib etc all live.
|
# Look for SSL 3 levels up from pcbuild - ie, same place zlib etc all live.
|
||||||
ssl_dir = find_best_ssl_dir(("../../..",))
|
ssl_dir = find_best_ssl_dir(("..\\..\\..",))
|
||||||
if ssl_dir is None:
|
if ssl_dir is None:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -107,49 +151,44 @@ def main():
|
||||||
try:
|
try:
|
||||||
os.chdir(ssl_dir)
|
os.chdir(ssl_dir)
|
||||||
# If the ssl makefiles do not exist, we invoke Perl to generate them.
|
# If the ssl makefiles do not exist, we invoke Perl to generate them.
|
||||||
if not os.path.isfile(os.path.join(ssl_dir, "32.mak")) or \
|
# Due to a bug in this script, the makefile sometimes ended up empty
|
||||||
not os.path.isfile(os.path.join(ssl_dir, "d32.mak")):
|
# Force a regeneration if it is.
|
||||||
|
if not os.path.isfile(makefile) or os.path.getsize(makefile)==0:
|
||||||
|
if perl is None:
|
||||||
|
print "Perl is required to build the makefiles!"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
print "Creating the makefiles..."
|
print "Creating the makefiles..."
|
||||||
|
sys.stdout.flush()
|
||||||
# Put our working Perl at the front of our path
|
# Put our working Perl at the front of our path
|
||||||
os.environ["PATH"] = os.path.split(perl)[0] + \
|
os.environ["PATH"] = os.path.dirname(perl) + \
|
||||||
os.pathsep + \
|
os.pathsep + \
|
||||||
os.environ["PATH"]
|
os.environ["PATH"]
|
||||||
# ms\32all.bat will reconfigure OpenSSL and then try to build
|
run_configure(configure, do_script)
|
||||||
# all outputs (debug/nondebug/dll/lib). So we filter the file
|
if debug:
|
||||||
# to exclude any "nmake" commands and then execute.
|
print "OpenSSL debug builds aren't supported."
|
||||||
tempname = "ms\\32all_py.bat"
|
#if arch=="x86" and debug:
|
||||||
|
# # the do_masm script in openssl doesn't generate a debug
|
||||||
|
# # build makefile so we generate it here:
|
||||||
|
# os.system("perl util\mk1mf.pl debug "+configure+" >"+makefile)
|
||||||
|
|
||||||
in_bat = open("ms\\32all.bat")
|
fix_makefile(makefile)
|
||||||
temp_bat = open(tempname,"w")
|
shutil.copy(r"crypto\buildinf.h", r"crypto\buildinf_%s.h" % arch)
|
||||||
while 1:
|
shutil.copy(r"crypto\opensslconf.h", r"crypto\opensslconf_%s.h" % arch)
|
||||||
cmd = in_bat.readline()
|
|
||||||
print 'cmd', repr(cmd)
|
|
||||||
if not cmd: break
|
|
||||||
if cmd.strip()[:5].lower() == "nmake":
|
|
||||||
continue
|
|
||||||
temp_bat.write(cmd)
|
|
||||||
in_bat.close()
|
|
||||||
temp_bat.close()
|
|
||||||
os.system(tempname)
|
|
||||||
try:
|
|
||||||
os.remove(tempname)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Now run make.
|
# Now run make.
|
||||||
print "Executing nmake over the ssl makefiles..."
|
shutil.copy(r"crypto\buildinf_%s.h" % arch, r"crypto\buildinf.h")
|
||||||
if debug:
|
shutil.copy(r"crypto\opensslconf_%s.h" % arch, r"crypto\opensslconf.h")
|
||||||
rc = os.system("nmake /nologo -f d32.mak")
|
|
||||||
if rc:
|
#makeCommand = "nmake /nologo PERL=\"%s\" -f \"%s\"" %(perl, makefile)
|
||||||
print "Executing d32.mak failed"
|
makeCommand = "nmake /nologo -f \"%s\"" % makefile
|
||||||
print rc
|
print "Executing ssl makefiles:", makeCommand
|
||||||
sys.exit(rc)
|
sys.stdout.flush()
|
||||||
else:
|
rc = os.system(makeCommand)
|
||||||
rc = os.system("nmake /nologo -f 32.mak")
|
if rc:
|
||||||
if rc:
|
print "Executing "+makefile+" failed"
|
||||||
print "Executing 32.mak failed"
|
print rc
|
||||||
print rc
|
sys.exit(rc)
|
||||||
sys.exit(rc)
|
|
||||||
finally:
|
finally:
|
||||||
os.chdir(old_cd)
|
os.chdir(old_cd)
|
||||||
# And finally, we can build the _ssl module itself for Python.
|
# And finally, we can build the _ssl module itself for Python.
|
||||||
|
|
|
@ -203,13 +203,13 @@ _ssl
|
||||||
http://www.openssl.org
|
http://www.openssl.org
|
||||||
|
|
||||||
You (probably) don't want the "engine" code. For example, get
|
You (probably) don't want the "engine" code. For example, get
|
||||||
openssl-0.9.6g.tar.gz
|
openssl-0.9.8g.tar.gz
|
||||||
not
|
not
|
||||||
openssl-engine-0.9.6g.tar.gz
|
openssl-engine-0.9.8g.tar.gz
|
||||||
|
|
||||||
Unpack into the "dist" directory, retaining the folder name from
|
Unpack into the "dist" directory, retaining the folder name from
|
||||||
the archive - for example, the latest stable OpenSSL will install as
|
the archive - for example, the latest stable OpenSSL will install as
|
||||||
dist/openssl-0.9.6g
|
dist/openssl-0.9.8g
|
||||||
|
|
||||||
You can (theoretically) use any version of OpenSSL you like - the
|
You can (theoretically) use any version of OpenSSL you like - the
|
||||||
build process will automatically select the latest version.
|
build process will automatically select the latest version.
|
||||||
|
|
Loading…
Reference in New Issue