2 rem ***************************************************************************
4 rem * Project ___| | | | _ \| |
5 rem * / __| | | | |_) | |
6 rem * | (__| |_| | _ <| |___
7 rem * \___|\___/|_| \_\_____|
9 rem * Copyright (C) 2012 - 2015, Steve Holme, <steve_holme@hotmail.com>.
11 rem * This software is licensed as described in the file COPYING, which
12 rem * you should have received as part of this distribution. The terms
13 rem * are also available at http://curl.haxx.se/docs/copyright.html.
15 rem * You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 rem * copies of the Software, and permit persons to whom the Software is
17 rem * furnished to do so, under the terms of the COPYING file.
19 rem * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 rem * KIND, either express or implied.
22 rem ***************************************************************************
25 rem Check we are running on a Windows NT derived OS
26 if not "%OS%" == "Windows_NT" goto nodos
33 rem Ensure we have the required arguments
34 if /i "%~1" == "" goto syntax
37 if "%~1" == "" goto prerequisites
39 if /i "%~1" == "vc6" (
42 set "VC_PATH=Microsoft Visual Studio\VC98"
43 ) else if /i "%~1" == "vc7" (
46 set "VC_PATH=Microsoft Visual Studio .NET\Vc7"
47 ) else if /i "%~1" == "vc7.1" (
50 set "VC_PATH=Microsoft Visual Studio .NET 2003\Vc7"
51 ) else if /i "%~1" == "vc8" (
54 set "VC_PATH=Microsoft Visual Studio 8\VC"
55 ) else if /i "%~1" == "vc9" (
58 set "VC_PATH=Microsoft Visual Studio 9.0\VC"
59 ) else if /i "%~1" == "vc10" (
62 set "VC_PATH=Microsoft Visual Studio 10.0\VC"
63 ) else if /i "%~1" == "vc11" (
66 set "VC_PATH=Microsoft Visual Studio 11.0\VC"
67 ) else if /i "%~1" == "vc12" (
70 set "VC_PATH=Microsoft Visual Studio 12.0\VC"
71 ) else if /i "%~1" == "vc14" (
74 set "VC_PATH=Microsoft Visual Studio 14.0\VC"
75 ) else if /i "%~1%" == "x86" (
76 set BUILD_PLATFORM=x86
77 ) else if /i "%~1%" == "x64" (
78 set BUILD_PLATFORM=x64
79 ) else if /i "%~1%" == "debug" (
80 set BUILD_CONFIG=debug
81 ) else if /i "%~1%" == "release" (
82 set BUILD_CONFIG=release
83 ) else if /i "%~1" == "-?" (
85 ) else if /i "%~1" == "-h" (
87 ) else if /i "%~1" == "-help" (
90 if not defined START_DIR (
97 shift & goto parseArgs
100 rem Compiler and platform are required parameters.
101 if not defined VC_VER goto syntax
102 if not defined BUILD_PLATFORM goto syntax
104 rem Default the start directory if one isn't specified
105 if not defined START_DIR set START_DIR=..\..\openssl
107 rem Calculate the program files directory
108 if defined PROGRAMFILES (
109 set "PF=%PROGRAMFILES%"
112 if defined PROGRAMFILES(x86) (
113 set "PF=%PROGRAMFILES(x86)%"
117 rem Check we have a program files directory
118 if not defined PF goto nopf
120 rem Check we have Visual Studio installed
121 if not exist "%PF%\%VC_PATH%" goto novc
123 rem Check we have Perl installed
124 echo %PATH% | findstr /I /C:"\Perl" 1>nul
126 if not exist "%SystemDrive%\Perl" (
127 if not exist "%SystemDrive%\Perl64" goto noperl
131 rem Check the start directory exists
132 if not exist "%START_DIR%" goto noopenssl
135 if "%BUILD_PLATFORM%" == "" (
136 if "%VC_VER%" == "6.0" (
137 set BUILD_PLATFORM=x86
138 ) else if "%VC_VER%" == "7.0" (
139 set BUILD_PLATFORM=x86
140 ) else if "%VC_VER%" == "7.1" (
141 set BUILD_PLATFORM=x86
143 set BUILD_PLATFORM=%OS_PLATFORM%
147 if "%BUILD_PLATFORM%" == "x86" (
148 set VCVARS_PLATFORM=x86
149 ) else if "%BUILD_PLATFORM%" == "x64" (
150 if "%VC_VER%" == "6.0" goto nox64
151 if "%VC_VER%" == "7.0" goto nox64
152 if "%VC_VER%" == "7.1" goto nox64
153 if "%VC_VER%" == "8.0" set VCVARS_PLATFORM=x86_amd64
154 if "%VC_VER%" == "9.0" set VCVARS_PLATFORM=%BUILD_PLATFORM%
155 if "%VC_VER%" == "10.0" set VCVARS_PLATFORM=%BUILD_PLATFORM%
156 if "%VC_VER%" == "11.0" set VCVARS_PLATFORM=amd64
157 if "%VC_VER%" == "12.0" set VCVARS_PLATFORM=amd64
158 if "%VC_VER%" == "14.0" set VCVARS_PLATFORM=amd64
163 if "%VC_VER%" == "6.0" (
164 call "%PF%\%VC_PATH%\bin\vcvars32"
165 ) else if "%VC_VER%" == "7.0" (
166 call "%PF%\%VC_PATH%\bin\vcvars32"
167 ) else if "%VC_VER%" == "7.1" (
168 call "%PF%\%VC_PATH%\bin\vcvars32"
170 call "%PF%\%VC_PATH%\vcvarsall" %VCVARS_PLATFORM%
175 if defined START_DIR CD %START_DIR%
176 goto %BUILD_PLATFORM%
179 rem Calculate our output directory
180 set OUTDIR=build\Win64\%VC_DESC%
181 if not exist %OUTDIR% md %OUTDIR%
183 if "%BUILD_CONFIG%" == "release" goto x64release
186 rem Configuring 64-bit Debug Build
187 perl Configure debug-VC-WIN64A --prefix=%CD%
189 rem Perform the build
192 nmake -f ms\ntdll.mak
194 rem Move the output directories
195 move out32.dbg "%OUTDIR%\LIB Debug"
196 move out32dll.dbg "%OUTDIR%\DLL Debug"
198 rem Move the PDB files
199 move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug"
200 move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug"
202 rem Remove the intermediate directories
204 rd tmp32dll.dbg /s /q
206 if "%BUILD_CONFIG%" == "debug" goto success
209 rem Configuring 64-bit Release Build
210 perl Configure VC-WIN64A --prefix=%CD%
212 rem Perform the build
215 nmake -f ms\ntdll.mak
217 rem Move the output directories
218 move out32 "%OUTDIR%\LIB Release"
219 move out32dll "%OUTDIR%\DLL Release"
221 rem Move the PDB files
222 move tmp32\lib.pdb "%OUTDIR%\LIB Release"
223 move tmp32dll\lib.pdb "%OUTDIR%\DLL Release"
225 rem Remove the intermediate directories
232 rem Calculate our output directory
233 set OUTDIR=build\Win32\%VC_DESC%
234 if not exist %OUTDIR% md %OUTDIR%
236 if "%BUILD_CONFIG%" == "release" goto x86release
239 rem Configuring 32-bit Debug Build
240 perl Configure debug-VC-WIN32 no-asm --prefix=%CD%
242 rem Perform the build
245 nmake -f ms\ntdll.mak
247 rem Move the output directories
248 move out32.dbg "%OUTDIR%\LIB Debug"
249 move out32dll.dbg "%OUTDIR%\DLL Debug"
251 rem Move the PDB files
252 move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug"
253 move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug"
255 rem Remove the intermediate directories
257 rd tmp32dll.dbg /s /q
259 if "%BUILD_CONFIG%" == "debug" goto success
262 rem Configuring 32-bit Release Build
263 perl Configure VC-WIN32 no-asm --prefix=%CD%
265 rem Perform the build
268 nmake -f ms\ntdll.mak
270 rem Move the output directories
271 move out32 "%OUTDIR%\LIB Release"
272 move out32dll "%OUTDIR%\DLL Release"
274 rem Move the PDB files
275 move tmp32\lib.pdb "%OUTDIR%\LIB Release"
276 move tmp32dll\lib.pdb "%OUTDIR%\DLL Release"
278 rem Remove the intermediate directories
287 echo Usage: build-openssl ^<compiler^> ^<platform^> [configuration] [directory]
291 echo vc6 - Use Visual Studio 6
292 echo vc7 - Use Visual Studio .NET
293 echo vc7.1 - Use Visual Studio .NET 2003
294 echo vc8 - Use Visual Studio 2005
295 echo vc9 - Use Visual Studio 2008
296 echo vc10 - Use Visual Studio 2010
297 echo vc11 - Use Visual Studio 2012
298 echo vc12 - Use Visual Studio 2013
299 echo vc14 - Use Visual Studio 2015
303 echo x86 - Perform a 32-bit build
304 echo x64 - Perform a 64-bit build
308 echo debug - Perform a debug build
309 echo release - Perform a release build
313 echo directory - Specifies the OpenSSL source directory
318 echo Error: Unknown argument '%1'
323 echo Error: Only a Windows NT based Operating System is supported
328 echo Error: Cannot obtain the directory for Program Files
333 echo Error: %VC_DESC% is not installed
338 echo Error: Perl is not installed
343 echo Error: %VC_DESC% does not support 64-bit builds
348 echo Error: Cannot locate OpenSSL source directory
352 if "%OS%" == "Windows_NT" endlocal