]> granicus.if.org Git - python/commitdiff
In anticipation of the upcoming ssl patch I've added _ssl to PCbuild8. It's based...
authorChristian Heimes <christian@cheimes.de>
Thu, 15 Nov 2007 19:57:43 +0000 (19:57 +0000)
committerChristian Heimes <christian@cheimes.de>
Thu, 15 Nov 2007 19:57:43 +0000 (19:57 +0000)
PCbuild8/_ssl/_ssl.vcproj [new file with mode: 0644]
PCbuild8/build_ssl.py [new file with mode: 0644]
PCbuild8/pyproject.vsprops

diff --git a/PCbuild8/_ssl/_ssl.vcproj b/PCbuild8/_ssl/_ssl.vcproj
new file mode 100644 (file)
index 0000000..81162b8
--- /dev/null
@@ -0,0 +1,668 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="8,00"
+       Name="_ssl"
+       ProjectGUID="{ECF06871-0C44-4137-93EE-E75A2F10DBE7}"
+       RootNamespace="_ssl"
+       Keyword="Win32Proj"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+               <Platform
+                       Name="x64"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       ConfigurationType="2"
+                       InheritedPropertySheets="..\pyd_d.vsprops"
+                       CharacterSet="0"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                               CommandLine="$(OutDir)\python_d.exe $(OutDir)\..\build_ssl.py $(ConfigurationName) -a"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               AdditionalIncludeDirectories="$(opensslDir)\inc32"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;_SOCKET_EXPORTS"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="3"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="4"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                               CommandLine="$(OutDir)\python_d.exe $(OutDir)\..\build_ssl.py $(ConfigurationName) -a"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib $(opensslDir)\out32\libeay32.lib $(opensslDir)\out32\ssleay32.lib"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Debug|x64"
+                       ConfigurationType="2"
+                       InheritedPropertySheets="..\pyd_d.vsprops"
+                       CharacterSet="0"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                               CommandLine="$(OutDir)\python.exe $(OutDir)\..\build_ssl.py $(ConfigurationName) -a"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TargetEnvironment="3"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               AdditionalIncludeDirectories="$(opensslDir)\inc32"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;_SOCKET_EXPORTS"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="3"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                               CommandLine="$(OutDir)\python_d.exe $(OutDir)\..\build_ssl.py $(ConfigurationName) -a"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib $(opensslDir)\out32\libeay32.lib $(opensslDir)\out32\ssleay32.lib"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               TargetMachine="17"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       ConfigurationType="2"
+                       InheritedPropertySheets="..\pyd.vsprops"
+                       CharacterSet="0"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                               CommandLine=""
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories="$(opensslDir)\inc32"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_SOCKET_EXPORTS"
+                               RuntimeLibrary="2"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                               CommandLine="$(OutDir)\python.exe $(OutDir)\..\build_ssl.py $(ConfigurationName) -a"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib $(opensslDir)\out32\libeay32.lib $(opensslDir)\out32\ssleay32.lib"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|x64"
+                       ConfigurationType="2"
+                       InheritedPropertySheets="..\pyd.vsprops"
+                       CharacterSet="0"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                               CommandLine=""
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TargetEnvironment="3"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories="$(opensslDir)\inc32"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_SOCKET_EXPORTS"
+                               RuntimeLibrary="2"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                               CommandLine="$(OutDir)\python.exe $(OutDir)\..\build_ssl.py $(ConfigurationName) -a"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib $(opensslDir)\out32\libeay32.lib $(opensslDir)\out32\ssleay32.lib"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="17"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="PGInstrument|Win32"
+                       ConfigurationType="2"
+                       InheritedPropertySheets="..\pyd.vsprops;..\PGInstrument.vsprops"
+                       CharacterSet="0"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                               CommandLine=""
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories="$(opensslDir)\inc32"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_SOCKET_EXPORTS"
+                               RuntimeLibrary="2"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                               CommandLine="$(OutDir)\python.exe $(OutDir)\..\build_ssl.py $(ConfigurationName) -a"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib $(opensslDir)\out32\libeay32.lib $(opensslDir)\out32\ssleay32.lib"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="PGInstrument|x64"
+                       ConfigurationType="2"
+                       InheritedPropertySheets="..\pyd.vsprops;..\PGInstrument.vsprops"
+                       CharacterSet="0"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                               CommandLine=""
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TargetEnvironment="3"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories="$(opensslDir)\inc32"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_SOCKET_EXPORTS"
+                               RuntimeLibrary="2"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                               CommandLine="$(OutDir)\python.exe $(OutDir)\..\build_ssl.py $(ConfigurationName) -a"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib $(opensslDir)\out32\libeay32.lib $(opensslDir)\out32\ssleay32.lib"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="17"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="PGUpdate|Win32"
+                       ConfigurationType="2"
+                       InheritedPropertySheets="..\pyd.vsprops;..\PGUpdate.vsprops"
+                       CharacterSet="0"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                               CommandLine=""
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories="$(opensslDir)\inc32"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_SOCKET_EXPORTS"
+                               RuntimeLibrary="2"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                               CommandLine="$(OutDir)\python.exe $(OutDir)\..\build_ssl.py $(ConfigurationName) -a"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib $(opensslDir)\out32\libeay32.lib $(opensslDir)\out32\ssleay32.lib"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="PGUpdate|x64"
+                       ConfigurationType="2"
+                       InheritedPropertySheets="..\pyd.vsprops;..\PGUpdate.vsprops"
+                       CharacterSet="0"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                               CommandLine=""
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TargetEnvironment="3"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories="$(opensslDir)\inc32"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_SOCKET_EXPORTS"
+                               RuntimeLibrary="2"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                               CommandLine="$(OutDir)\python.exe $(OutDir)\..\build_ssl.py $(ConfigurationName) -a"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib $(opensslDir)\out32\libeay32.lib $(opensslDir)\out32\ssleay32.lib"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="17"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+                       >
+                       <File
+                               RelativePath="..\..\Modules\_ssl.c"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+                       >
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+                       >
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/PCbuild8/build_ssl.py b/PCbuild8/build_ssl.py
new file mode 100644 (file)
index 0000000..7658da1
--- /dev/null
@@ -0,0 +1,172 @@
+# Script for building the _ssl and _hashlib modules for Windows.
+# Uses Perl to setup the OpenSSL environment correctly
+# and build OpenSSL, then invokes a simple nmake session
+# for the actual _ssl.pyd and _hashlib.pyd DLLs.
+
+# THEORETICALLY, you can:
+# * Unpack the latest SSL release one level above your main Python source
+#   directory.  It is likely you will already find the zlib library and
+#   any other external packages there.
+# * Install ActivePerl and ensure it is somewhere on your path.
+# * Run this script from the PCBuild directory.
+#
+# it should configure and build SSL, then build the _ssl and _hashlib
+# Python extensions without intervention.
+
+import os, sys, re
+
+# Find all "foo.exe" files on the PATH.
+def find_all_on_path(filename, extras = None):
+    entries = os.environ["PATH"].split(os.pathsep)
+    ret = []
+    for p in entries:
+        fname = os.path.abspath(os.path.join(p, filename))
+        if os.path.isfile(fname) and fname not in ret:
+            ret.append(fname)
+    if extras:
+        for p in extras:
+            fname = os.path.abspath(os.path.join(p, filename))
+            if os.path.isfile(fname) and fname not in ret:
+                ret.append(fname)
+    return ret
+
+# Find a suitable Perl installation for OpenSSL.
+# cygwin perl does *not* work.  ActivePerl does.
+# Being a Perl dummy, the simplest way I can check is if the "Win32" package
+# is available.
+def find_working_perl(perls):
+    for perl in perls:
+        fh = os.popen(perl + ' -e "use Win32;"')
+        fh.read()
+        rc = fh.close()
+        if rc:
+            continue
+        return perl
+    print("Can not find a suitable PERL:")
+    if perls:
+        print(" the following perl interpreters were found:")
+        for p in perls:
+            print(" ", p)
+        print(" None of these versions appear suitable for building OpenSSL")
+    else:
+        print(" NO perl interpreters were found on this machine at all!")
+    print(" Please install ActivePerl and ensure it appears on your path")
+    print("The Python SSL module was not built")
+    return None
+
+# Locate the best SSL directory given a few roots to look into.
+def find_best_ssl_dir(sources):
+    candidates = []
+    for s in sources:
+        try:
+            # note: do not abspath s; the build will fail if any
+            # higher up directory name has spaces in it.
+            fnames = os.listdir(s)
+        except os.error:
+            fnames = []
+        for fname in fnames:
+            fqn = os.path.join(s, fname)
+            if os.path.isdir(fqn) and fname.startswith("openssl-"):
+                candidates.append(fqn)
+    # Now we have all the candidates, locate the best.
+    best_parts = []
+    best_name = None
+    for c in candidates:
+        parts = re.split("[.-]", os.path.basename(c))[1:]
+        # eg - openssl-0.9.7-beta1 - ignore all "beta" or any other qualifiers
+        if len(parts) >= 4:
+            continue
+        if parts > best_parts:
+            best_parts = parts
+            best_name = c
+    if best_name is not None:
+        print("Found an SSL directory at '%s'" % (best_name,))
+    else:
+        print("Could not find an SSL directory in '%s'" % (sources,))
+    sys.stdout.flush()
+    return best_name
+
+def run_configure(configure, do_script):
+    os.system("perl Configure "+configure)
+    os.system(do_script)
+
+def main():
+    build_all = "-a" in sys.argv
+    if sys.argv[1] == "Release":
+        arch = "x86"
+        debug = False
+        configure = "VC-WIN32"
+        do_script = "ms\\do_masm"
+        makefile = "ms\\nt.mak"
+    elif sys.argv[1] == "Debug":
+        arch = "x86"
+        debug = True
+        configure = "VC-WIN32"
+        do_script = "ms\\do_masm"
+        makefile="ms\\d32.mak"
+    elif sys.argv[1] == "ReleaseItanium":
+        arch = "ia64"
+        debug = False
+        configure = "VC-WIN64I"
+        do_script = "ms\\do_win64i"
+        makefile = "ms\\nt.mak"
+        os.environ["VSEXTCOMP_USECL"] = "MS_ITANIUM"
+    elif sys.argv[1] == "ReleaseAMD64":
+        arch="amd64"
+        debug=False
+        configure = "VC-WIN64A"
+        do_script = "ms\\do_win64a"
+        makefile = "ms\\nt.mak"
+        os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON"
+    make_flags = ""
+    if build_all:
+        make_flags = "-a"
+    # perl should be on the path, but we also look in "\perl" and "c:\\perl"
+    # as "well known" locations
+    perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"])
+    perl = find_working_perl(perls)
+    if perl is None:
+        sys.exit(1)
+
+    print("Found a working perl at '%s'" % (perl,))
+    sys.stdout.flush()
+    # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live.
+    ssl_dir = find_best_ssl_dir(("..\\..\\..",))
+    if ssl_dir is None:
+        print(os.path.abspath(os.getcwd()))
+        sys.exit(1)
+
+    old_cd = os.getcwd()
+    try:
+        os.chdir(ssl_dir)
+        # If the ssl makefiles do not exist, we invoke Perl to generate them.
+        # Due to a bug in this script, the makefile sometimes ended up empty
+        # Force a regeneration if it is.
+        if not os.path.isfile(makefile) or os.path.getsize(makefile)==0:
+            print("Creating the makefiles...")
+            sys.stdout.flush()
+            # Put our working Perl at the front of our path
+            os.environ["PATH"] = os.path.dirname(perl) + \
+                                          os.pathsep + \
+                                          os.environ["PATH"]
+            run_configure(configure, do_script)
+            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)
+
+        # Now run make.
+        makeCommand = "nmake /nologo PERL=\"%s\" -f \"%s\"" %(perl, makefile)
+        print("Executing ssl makefiles:", makeCommand)
+        sys.stdout.flush()
+        rc = os.system(makeCommand)
+        if rc:
+            print("Executing "+makefile+" failed")
+            print(rc)
+            sys.exit(rc)
+    finally:
+        os.chdir(old_cd)
+    sys.exit(rc)
+
+if __name__=='__main__':
+    main()
index b120ba8d37441308e33447b654980a40588f637d..752e1746e21e7fc22867dc22f46f51851ede28a1 100644 (file)
@@ -35,4 +35,8 @@
                Name="bz2Dir"\r
                Value="..\..\..\bzip2-1.0.3"\r
        />\r
+       <UserMacro\r
+               Name="opensslDir"\r
+               Value="..\..\..\openssl-0.9.8a"\r
+       />\r
 </VisualStudioPropertySheet>\r