2 rem ***************************************************************************
4 rem * Project ___| | | | _ \| |
5 rem * / __| | | | |_) | |
6 rem * | (__| |_| | _ <| |___
7 rem * \___|\___/|_| \_\_____|
9 rem * Copyright (C) 2012 - 2018, 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 https://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
36 rem Calculate the program files directory
37 if defined PROGRAMFILES (
38 set "PF=%PROGRAMFILES%"
41 if defined PROGRAMFILES(x86) (
42 set "PF=%PROGRAMFILES(x86)%"
47 if "%~1" == "" goto prerequisites
49 if /i "%~1" == "vc6" (
52 set "VC_PATH=Microsoft Visual Studio\VC98"
53 ) else if /i "%~1" == "vc7" (
56 set "VC_PATH=Microsoft Visual Studio .NET\Vc7"
57 ) else if /i "%~1" == "vc7.1" (
60 set "VC_PATH=Microsoft Visual Studio .NET 2003\Vc7"
61 ) else if /i "%~1" == "vc8" (
64 set "VC_PATH=Microsoft Visual Studio 8\VC"
65 ) else if /i "%~1" == "vc9" (
68 set "VC_PATH=Microsoft Visual Studio 9.0\VC"
69 ) else if /i "%~1" == "vc10" (
72 set "VC_PATH=Microsoft Visual Studio 10.0\VC"
73 ) else if /i "%~1" == "vc11" (
76 set "VC_PATH=Microsoft Visual Studio 11.0\VC"
77 ) else if /i "%~1" == "vc12" (
80 set "VC_PATH=Microsoft Visual Studio 12.0\VC"
81 ) else if /i "%~1" == "vc14" (
84 set "VC_PATH=Microsoft Visual Studio 14.0\VC"
85 ) else if /i "%~1" == "vc15" (
89 rem Determine the VC15 path based on the installed edition in decending
90 rem order (Enterprise, then Professional and finally Community)
91 if exist "%PF%\Microsoft Visual Studio\2017\Enterprise\VC" (
92 set "VC_PATH=Microsoft Visual Studio\2017\Enterprise\VC"
93 ) else if exist "%PF%\Microsoft Visual Studio\2017\Professional\VC" (
94 set "VC_PATH=Microsoft Visual Studio\2017\Professional\VC"
96 set "VC_PATH=Microsoft Visual Studio\2017\Community\VC"
98 ) else if /i "%~1%" == "x86" (
99 set BUILD_PLATFORM=x86
100 ) else if /i "%~1%" == "x64" (
101 set BUILD_PLATFORM=x64
102 ) else if /i "%~1%" == "debug" (
103 set BUILD_CONFIG=debug
104 ) else if /i "%~1%" == "release" (
105 set BUILD_CONFIG=release
106 ) else if /i "%~1" == "-?" (
108 ) else if /i "%~1" == "-h" (
110 ) else if /i "%~1" == "-help" (
113 if not defined START_DIR (
120 shift & goto parseArgs
123 rem Compiler is a required parameter
124 if not defined VC_VER goto syntax
126 rem Default the start directory if one isn't specified
127 if not defined START_DIR set START_DIR=..\..\openssl
129 rem Check we have a program files directory
130 if not defined PF goto nopf
132 rem Check we have Visual Studio installed
133 if not exist "%PF%\%VC_PATH%" goto novc
135 rem Check we have Perl in our path
136 echo %PATH% | findstr /I /C:"\Perl" 1>nul
138 rem It isn't so check we have it installed and set the path if it is
139 if exist "%SystemDrive%\Perl" (
140 set "PATH=%SystemDrive%\Perl\bin;%PATH%"
142 if exist "%SystemDrive%\Perl64" (
143 set "PATH=%SystemDrive%\Perl64\bin;%PATH%"
150 rem Check the start directory exists
151 if not exist "%START_DIR%" goto noopenssl
153 rem Check that OpenSSL is not unsupported version 1.1.0
154 if not exist "%START_DIR%\ms\do_ms.bat" goto unsupported
157 if "%BUILD_PLATFORM%" == "" (
158 if "%VC_VER%" == "6.0" (
159 set BUILD_PLATFORM=x86
160 ) else if "%VC_VER%" == "7.0" (
161 set BUILD_PLATFORM=x86
162 ) else if "%VC_VER%" == "7.1" (
163 set BUILD_PLATFORM=x86
165 set BUILD_PLATFORM=%OS_PLATFORM%
169 if "%BUILD_PLATFORM%" == "x86" (
170 set VCVARS_PLATFORM=x86
171 ) else if "%BUILD_PLATFORM%" == "x64" (
172 if "%VC_VER%" == "6.0" goto nox64
173 if "%VC_VER%" == "7.0" goto nox64
174 if "%VC_VER%" == "7.1" goto nox64
175 if "%VC_VER%" == "8.0" set VCVARS_PLATFORM=x86_amd64
176 if "%VC_VER%" == "9.0" set VCVARS_PLATFORM=%BUILD_PLATFORM%
177 if "%VC_VER%" == "10.0" set VCVARS_PLATFORM=%BUILD_PLATFORM%
178 if "%VC_VER%" == "11.0" set VCVARS_PLATFORM=amd64
179 if "%VC_VER%" == "12.0" set VCVARS_PLATFORM=amd64
180 if "%VC_VER%" == "14.0" set VCVARS_PLATFORM=amd64
181 if "%VC_VER%" == "15.0" set VCVARS_PLATFORM=amd64
188 if "%VC_VER%" == "6.0" (
189 call "%PF%\%VC_PATH%\bin\vcvars32"
190 ) else if "%VC_VER%" == "7.0" (
191 call "%PF%\%VC_PATH%\bin\vcvars32"
192 ) else if "%VC_VER%" == "7.1" (
193 call "%PF%\%VC_PATH%\bin\vcvars32"
194 ) else if "%VC_VER%" == "15.0" (
195 call "%PF%\%VC_PATH%\Auxiliary\Build\vcvarsall" %VCVARS_PLATFORM%
197 call "%PF%\%VC_PATH%\vcvarsall" %VCVARS_PLATFORM%
203 goto %BUILD_PLATFORM%
206 rem Calculate our output directory
207 set OUTDIR=build\Win64\%VC_DESC%
208 if not exist %OUTDIR% md %OUTDIR%
210 if "%BUILD_CONFIG%" == "release" goto x64release
213 rem Configuring 64-bit Debug Build
214 perl Configure debug-VC-WIN64A --prefix=%CD%
216 rem Perform the build
219 nmake -f ms\ntdll.mak
221 rem Move the output directories
222 if exist "%OUTDIR%\LIB Debug" (
223 copy /y out32.dbg\* "%OUTDIR%\LIB Debug" 1>nul
226 move out32.dbg "%OUTDIR%\LIB Debug" 1>nul
228 if exist "%OUTDIR%\DLL Debug" (
229 copy /y out32dll.dbg\* "%OUTDIR%\DLL Debug" 1>nul
230 rd out32dll.dbg /s /q
232 move out32dll.dbg "%OUTDIR%\DLL Debug" 1>nul
235 rem Move the PDB files
236 move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug" 1>nul
237 move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug" 1>nul
239 rem Remove the intermediate directories
241 rd tmp32dll.dbg /s /q
243 if "%BUILD_CONFIG%" == "debug" goto success
246 rem Configuring 64-bit Release Build
247 perl Configure VC-WIN64A --prefix=%CD%
249 rem Perform the build
252 nmake -f ms\ntdll.mak
254 rem Move the output directories
255 if exist "%OUTDIR%\LIB Release" (
256 copy /y out32\* "%OUTDIR%\LIB Release" 1>nul
259 move out32 "%OUTDIR%\LIB Release" 1>nul
261 if exist "%OUTDIR%\DLL Release" (
262 copy /y out32dll\* "%OUTDIR%\DLL Release" 1>nul
265 move out32dll "%OUTDIR%\DLL Release" 1>nul
268 rem Move the PDB files
269 move tmp32\lib.pdb "%OUTDIR%\LIB Release" 1>nul
270 move tmp32dll\lib.pdb "%OUTDIR%\DLL Release" 1>nul
272 rem Remove the intermediate directories
279 rem Calculate our output directory
280 set OUTDIR=build\Win32\%VC_DESC%
281 if not exist %OUTDIR% md %OUTDIR%
283 if "%BUILD_CONFIG%" == "release" goto x86release
286 rem Configuring 32-bit Debug Build
287 perl Configure debug-VC-WIN32 no-asm --prefix=%CD%
289 rem Perform the build
292 nmake -f ms\ntdll.mak
294 rem Move the output directories
295 if exist "%OUTDIR%\LIB Debug" (
296 copy /y out32.dbg\* "%OUTDIR%\LIB Debug" 1>nul
299 move out32.dbg "%OUTDIR%\LIB Debug" 1>nul
301 if exist "%OUTDIR%\DLL Debug" (
302 copy /y out32dll.dbg\* "%OUTDIR%\DLL Debug" 1>nul
303 rd out32dll.dbg /s /q
305 move out32dll.dbg "%OUTDIR%\DLL Debug" 1>nul
308 rem Move the PDB files
309 move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug" 1>nul
310 move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug" 1>nul
312 rem Remove the intermediate directories
314 rd tmp32dll.dbg /s /q
316 if "%BUILD_CONFIG%" == "debug" goto success
319 rem Configuring 32-bit Release Build
320 perl Configure VC-WIN32 no-asm --prefix=%CD%
322 rem Perform the build
325 nmake -f ms\ntdll.mak
327 rem Move the output directories
328 if exist "%OUTDIR%\LIB Release" (
329 copy /y out32\* "%OUTDIR%\LIB Release" 1>nul
332 move out32 "%OUTDIR%\LIB Release" 1>nul
334 if exist "%OUTDIR%\DLL Release" (
335 copy /y out32dll\* "%OUTDIR%\DLL Release" 1>nul
338 move out32dll "%OUTDIR%\DLL Release" 1>nul
341 rem Move the PDB files
342 move tmp32\lib.pdb "%OUTDIR%\LIB Release" 1>nul
343 move tmp32dll\lib.pdb "%OUTDIR%\DLL Release" 1>nul
345 rem Remove the intermediate directories
354 echo Usage: build-openssl ^<compiler^> [platform] [configuration] [directory]
358 echo vc6 - Use Visual Studio 6
359 echo vc7 - Use Visual Studio .NET
360 echo vc7.1 - Use Visual Studio .NET 2003
361 echo vc8 - Use Visual Studio 2005
362 echo vc9 - Use Visual Studio 2008
363 echo vc10 - Use Visual Studio 2010
364 echo vc11 - Use Visual Studio 2012
365 echo vc12 - Use Visual Studio 2013
366 echo vc14 - Use Visual Studio 2015
367 echo vc15 - Use Visual Studio 2017
371 echo x86 - Perform a 32-bit build
372 echo x64 - Perform a 64-bit build
376 echo debug - Perform a debug build
377 echo release - Perform a release build
381 echo directory - Specifies the OpenSSL source directory
386 echo Error: Unknown argument '%1'
391 echo Error: Only a Windows NT based Operating System is supported
396 echo Error: Cannot obtain the directory for Program Files
401 echo Error: %VC_DESC% is not installed
406 echo Error: Perl is not installed
411 echo Error: %VC_DESC% does not support 64-bit builds
416 echo Error: Cannot locate OpenSSL source directory
421 echo Error: Unsupported OpenSSL version.
422 echo The pre-generated project files and this build script only support the
423 echo LTS version of OpenSSL ^(v1.0.2^). The next version of this build script
424 echo will support OpenSSL v1.1.0.
428 if "%OS%" == "Windows_NT" endlocal