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" == "vc14.1" (
89 rem Determine the VC14.1 path based on the installed edition in descending
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" (
112 ) else if /i "%~1" == "-VSpath" (
115 echo Error. Please provide VS Path.
118 set "ABS_VC_PATH=%~2\VC"
121 ) else if /i "%~1" == "-perlpath" (
124 echo Error. Please provide Perl root Path.
131 if not defined START_DIR (
138 shift & goto parseArgs
141 rem Compiler is a required parameter
142 if not defined VC_VER goto syntax
144 rem Default the start directory if one isn't specified
145 if not defined START_DIR set START_DIR=..\..\openssl
147 if not defined ABS_VC_PATH (
148 rem Check we have a program files directory
149 if not defined PF goto nopf
150 set "ABS_VC_PATH=%PF%\%VC_PATH%"
153 rem Check we have Visual Studio installed
154 if not exist "%ABS_VC_PATH%" goto novc
156 if not defined PERL_PATH (
157 rem Check we have Perl in our path
158 perl --version <NUL 1>NUL 2>&1
160 rem It isn't so check we have it installed and set the path if it is
161 if exist "%SystemDrive%\Perl" (
162 set "PATH=%SystemDrive%\Perl\bin;%PATH%"
164 if exist "%SystemDrive%\Perl64" (
165 set "PATH=%SystemDrive%\Perl64\bin;%PATH%"
172 set "PATH=%PERL_PATH%\Perl\bin;%PATH%"
175 rem Check the start directory exists
176 if not exist "%START_DIR%" goto noopenssl
178 rem Check that OpenSSL is not unsupported version 1.1.0
179 if not exist "%START_DIR%\ms\do_ms.bat" goto unsupported
182 if "%BUILD_PLATFORM%" == "" (
183 if "%VC_VER%" == "6.0" (
184 set BUILD_PLATFORM=x86
185 ) else if "%VC_VER%" == "7.0" (
186 set BUILD_PLATFORM=x86
187 ) else if "%VC_VER%" == "7.1" (
188 set BUILD_PLATFORM=x86
190 set BUILD_PLATFORM=%OS_PLATFORM%
194 if "%BUILD_PLATFORM%" == "x86" (
195 set VCVARS_PLATFORM=x86
196 ) else if "%BUILD_PLATFORM%" == "x64" (
197 if "%VC_VER%" == "6.0" goto nox64
198 if "%VC_VER%" == "7.0" goto nox64
199 if "%VC_VER%" == "7.1" goto nox64
200 if "%VC_VER%" == "8.0" set VCVARS_PLATFORM=x86_amd64
201 if "%VC_VER%" == "9.0" set VCVARS_PLATFORM=%BUILD_PLATFORM%
202 if "%VC_VER%" == "10.0" set VCVARS_PLATFORM=%BUILD_PLATFORM%
203 if "%VC_VER%" == "11.0" set VCVARS_PLATFORM=amd64
204 if "%VC_VER%" == "12.0" set VCVARS_PLATFORM=amd64
205 if "%VC_VER%" == "14.0" set VCVARS_PLATFORM=amd64
206 if "%VC_VER%" == "14.1" set VCVARS_PLATFORM=amd64
213 if "%VC_VER%" == "6.0" (
214 call "%ABS_VC_PATH%\bin\vcvars32"
215 ) else if "%VC_VER%" == "7.0" (
216 call "%ABS_VC_PATH%\bin\vcvars32"
217 ) else if "%VC_VER%" == "7.1" (
218 call "%ABS_VC_PATH%\bin\vcvars32"
219 ) else if "%VC_VER%" == "14.1" (
220 call "%ABS_VC_PATH%\Auxiliary\Build\vcvarsall" %VCVARS_PLATFORM%
222 call "%ABS_VC_PATH%\vcvarsall" %VCVARS_PLATFORM%
227 if defined START_DIR cd /d %START_DIR%
228 goto %BUILD_PLATFORM%
231 rem Calculate our output directory
232 set OUTDIR=build\Win64\%VC_DESC%
233 if not exist %OUTDIR% md %OUTDIR%
235 if "%BUILD_CONFIG%" == "release" goto x64release
238 rem Configuring 64-bit Debug Build
239 perl Configure debug-VC-WIN64A --prefix=%CD%
241 rem Perform the build
244 nmake -f ms\ntdll.mak
246 rem Move the output directories
247 if exist "%OUTDIR%\LIB Debug" (
248 copy /y out32.dbg\* "%OUTDIR%\LIB Debug" 1>nul
251 move out32.dbg "%OUTDIR%\LIB Debug" 1>nul
253 if exist "%OUTDIR%\DLL Debug" (
254 copy /y out32dll.dbg\* "%OUTDIR%\DLL Debug" 1>nul
255 rd out32dll.dbg /s /q
257 move out32dll.dbg "%OUTDIR%\DLL Debug" 1>nul
260 rem Move the PDB files
261 move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug" 1>nul
262 move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug" 1>nul
264 rem Remove the intermediate directories
266 rd tmp32dll.dbg /s /q
268 if "%BUILD_CONFIG%" == "debug" goto success
271 rem Configuring 64-bit Release Build
272 perl Configure VC-WIN64A --prefix=%CD%
274 rem Perform the build
277 nmake -f ms\ntdll.mak
279 rem Move the output directories
280 if exist "%OUTDIR%\LIB Release" (
281 copy /y out32\* "%OUTDIR%\LIB Release" 1>nul
284 move out32 "%OUTDIR%\LIB Release" 1>nul
286 if exist "%OUTDIR%\DLL Release" (
287 copy /y out32dll\* "%OUTDIR%\DLL Release" 1>nul
290 move out32dll "%OUTDIR%\DLL Release" 1>nul
293 rem Move the PDB files
294 move tmp32\lib.pdb "%OUTDIR%\LIB Release" 1>nul
295 move tmp32dll\lib.pdb "%OUTDIR%\DLL Release" 1>nul
297 rem Remove the intermediate directories
304 rem Calculate our output directory
305 set OUTDIR=build\Win32\%VC_DESC%
306 if not exist %OUTDIR% md %OUTDIR%
308 if "%BUILD_CONFIG%" == "release" goto x86release
311 rem Configuring 32-bit Debug Build
312 perl Configure debug-VC-WIN32 no-asm --prefix=%CD%
314 rem Perform the build
317 nmake -f ms\ntdll.mak
319 rem Move the output directories
320 if exist "%OUTDIR%\LIB Debug" (
321 copy /y out32.dbg\* "%OUTDIR%\LIB Debug" 1>nul
324 move out32.dbg "%OUTDIR%\LIB Debug" 1>nul
326 if exist "%OUTDIR%\DLL Debug" (
327 copy /y out32dll.dbg\* "%OUTDIR%\DLL Debug" 1>nul
328 rd out32dll.dbg /s /q
330 move out32dll.dbg "%OUTDIR%\DLL Debug" 1>nul
333 rem Move the PDB files
334 move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug" 1>nul
335 move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug" 1>nul
337 rem Remove the intermediate directories
339 rd tmp32dll.dbg /s /q
341 if "%BUILD_CONFIG%" == "debug" goto success
344 rem Configuring 32-bit Release Build
345 perl Configure VC-WIN32 no-asm --prefix=%CD%
347 rem Perform the build
350 nmake -f ms\ntdll.mak
352 rem Move the output directories
353 if exist "%OUTDIR%\LIB Release" (
354 copy /y out32\* "%OUTDIR%\LIB Release" 1>nul
357 move out32 "%OUTDIR%\LIB Release" 1>nul
359 if exist "%OUTDIR%\DLL Release" (
360 copy /y out32dll\* "%OUTDIR%\DLL Release" 1>nul
363 move out32dll "%OUTDIR%\DLL Release" 1>nul
366 rem Move the PDB files
367 move tmp32\lib.pdb "%OUTDIR%\LIB Release" 1>nul
368 move tmp32dll\lib.pdb "%OUTDIR%\DLL Release" 1>nul
370 rem Remove the intermediate directories
379 echo Usage: build-openssl ^<compiler^> [platform] [configuration] [directory] [-VSpath] ["VSpath"] [-perlpath] ["perlpath"]
383 echo vc6 - Use Visual Studio 6
384 echo vc7 - Use Visual Studio .NET
385 echo vc7.1 - Use Visual Studio .NET 2003
386 echo vc8 - Use Visual Studio 2005
387 echo vc9 - Use Visual Studio 2008
388 echo vc10 - Use Visual Studio 2010
389 echo vc11 - Use Visual Studio 2012
390 echo vc12 - Use Visual Studio 2013
391 echo vc14 - Use Visual Studio 2015
392 echo vc14.1 - Use Visual Studio 2017
396 echo x86 - Perform a 32-bit build
397 echo x64 - Perform a 64-bit build
401 echo debug - Perform a debug build
402 echo release - Perform a release build
406 echo directory - Specifies the OpenSSL source directory
408 echo -VSpath - Specify the custom VS path if Visual Studio is installed at other location
409 echo then "C:/<ProgramFiles>/Microsoft Visual Studio[version]
410 echo For e.g. -VSpath "C:\apps\MVS14"
412 echo -perlpath - Specify the custom perl root path if perl is not located at "C:\Perl" and it is a
413 echo portable copy of perl and not installed on the win system
414 echo For e.g. -perlpath "D:\strawberry-perl-5.24.3.1-64bit-portable"
419 echo Error: Unknown argument '%1'
424 echo Error: Only a Windows NT based Operating System is supported
429 echo Error: Cannot obtain the directory for Program Files
434 echo Error: %VC_DESC% is not installed
435 echo Error: Please check whether Visual compiler is installed at the path "%ABS_VC_PATH%"
436 echo Error: Please provide proper VS Path by using -VSpath
441 echo Error: Perl is not installed
442 echo Error: Please check whether Perl is installed or it is at location "C:\Perl"
443 echo Error: If Perl is portable please provide perl root path by using -perlpath
448 echo Error: %VC_DESC% does not support 64-bit builds
453 echo Error: Cannot locate OpenSSL source directory
458 echo Error: Unsupported OpenSSL version.
459 echo The pre-generated project files and this build script only support the
460 echo LTS version of OpenSSL ^(v1.0.2^). The next version of this build script
461 echo will support OpenSSL v1.1.0.
465 if "%OS%" == "Windows_NT" endlocal