2 rem ***************************************************************************
4 rem * Project ___| | | | _ \| |
5 rem * / __| | | | |_) | |
6 rem * | (__| |_| | _ <| |___
7 rem * \___|\___/|_| \_\_____|
9 rem * Copyright (C) 2012 - 2016, 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
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 in our path
124 echo %PATH% | findstr /I /C:"\Perl" 1>nul
126 rem It isn't so check we have it installed and set the path if it is
127 if exist "%SystemDrive%\Perl" (
128 set "PATH=%SystemDrive%\Perl\bin;%PATH%"
130 if exist "%SystemDrive%\Perl64" (
131 set "PATH=%SystemDrive%\Perl64\bin;%PATH%"
138 rem Check the start directory exists
139 if not exist "%START_DIR%" goto noopenssl
142 if "%BUILD_PLATFORM%" == "" (
143 if "%VC_VER%" == "6.0" (
144 set BUILD_PLATFORM=x86
145 ) else if "%VC_VER%" == "7.0" (
146 set BUILD_PLATFORM=x86
147 ) else if "%VC_VER%" == "7.1" (
148 set BUILD_PLATFORM=x86
150 set BUILD_PLATFORM=%OS_PLATFORM%
154 if "%BUILD_PLATFORM%" == "x86" (
155 set VCVARS_PLATFORM=x86
156 ) else if "%BUILD_PLATFORM%" == "x64" (
157 if "%VC_VER%" == "6.0" goto nox64
158 if "%VC_VER%" == "7.0" goto nox64
159 if "%VC_VER%" == "7.1" goto nox64
160 if "%VC_VER%" == "8.0" set VCVARS_PLATFORM=x86_amd64
161 if "%VC_VER%" == "9.0" set VCVARS_PLATFORM=%BUILD_PLATFORM%
162 if "%VC_VER%" == "10.0" set VCVARS_PLATFORM=%BUILD_PLATFORM%
163 if "%VC_VER%" == "11.0" set VCVARS_PLATFORM=amd64
164 if "%VC_VER%" == "12.0" set VCVARS_PLATFORM=amd64
165 if "%VC_VER%" == "14.0" set VCVARS_PLATFORM=amd64
170 if "%VC_VER%" == "6.0" (
171 call "%PF%\%VC_PATH%\bin\vcvars32"
172 ) else if "%VC_VER%" == "7.0" (
173 call "%PF%\%VC_PATH%\bin\vcvars32"
174 ) else if "%VC_VER%" == "7.1" (
175 call "%PF%\%VC_PATH%\bin\vcvars32"
177 call "%PF%\%VC_PATH%\vcvarsall" %VCVARS_PLATFORM%
182 if defined START_DIR CD %START_DIR%
183 goto %BUILD_PLATFORM%
186 rem Calculate our output directory
187 set OUTDIR=build\Win64\%VC_DESC%
188 if not exist %OUTDIR% md %OUTDIR%
190 if "%BUILD_CONFIG%" == "release" goto x64release
193 rem Configuring 64-bit Debug Build
194 perl Configure debug-VC-WIN64A --prefix=%CD%
196 rem Perform the build
199 nmake -f ms\ntdll.mak
201 rem Move the output directories
202 move out32.dbg "%OUTDIR%\LIB Debug"
203 move out32dll.dbg "%OUTDIR%\DLL Debug"
205 rem Move the PDB files
206 move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug"
207 move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug"
209 rem Remove the intermediate directories
211 rd tmp32dll.dbg /s /q
213 if "%BUILD_CONFIG%" == "debug" goto success
216 rem Configuring 64-bit Release Build
217 perl Configure VC-WIN64A --prefix=%CD%
219 rem Perform the build
222 nmake -f ms\ntdll.mak
224 rem Move the output directories
225 move out32 "%OUTDIR%\LIB Release"
226 move out32dll "%OUTDIR%\DLL Release"
228 rem Move the PDB files
229 move tmp32\lib.pdb "%OUTDIR%\LIB Release"
230 move tmp32dll\lib.pdb "%OUTDIR%\DLL Release"
232 rem Remove the intermediate directories
239 rem Calculate our output directory
240 set OUTDIR=build\Win32\%VC_DESC%
241 if not exist %OUTDIR% md %OUTDIR%
243 if "%BUILD_CONFIG%" == "release" goto x86release
246 rem Configuring 32-bit Debug Build
247 perl Configure debug-VC-WIN32 no-asm --prefix=%CD%
249 rem Perform the build
252 nmake -f ms\ntdll.mak
254 rem Move the output directories
255 move out32.dbg "%OUTDIR%\LIB Debug"
256 move out32dll.dbg "%OUTDIR%\DLL Debug"
258 rem Move the PDB files
259 move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug"
260 move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug"
262 rem Remove the intermediate directories
264 rd tmp32dll.dbg /s /q
266 if "%BUILD_CONFIG%" == "debug" goto success
269 rem Configuring 32-bit Release Build
270 perl Configure VC-WIN32 no-asm --prefix=%CD%
272 rem Perform the build
275 nmake -f ms\ntdll.mak
277 rem Move the output directories
278 move out32 "%OUTDIR%\LIB Release"
279 move out32dll "%OUTDIR%\DLL Release"
281 rem Move the PDB files
282 move tmp32\lib.pdb "%OUTDIR%\LIB Release"
283 move tmp32dll\lib.pdb "%OUTDIR%\DLL Release"
285 rem Remove the intermediate directories
294 echo Usage: build-openssl ^<compiler^> ^<platform^> [configuration] [directory]
298 echo vc6 - Use Visual Studio 6
299 echo vc7 - Use Visual Studio .NET
300 echo vc7.1 - Use Visual Studio .NET 2003
301 echo vc8 - Use Visual Studio 2005
302 echo vc9 - Use Visual Studio 2008
303 echo vc10 - Use Visual Studio 2010
304 echo vc11 - Use Visual Studio 2012
305 echo vc12 - Use Visual Studio 2013
306 echo vc14 - Use Visual Studio 2015
310 echo x86 - Perform a 32-bit build
311 echo x64 - Perform a 64-bit build
315 echo debug - Perform a debug build
316 echo release - Perform a release build
320 echo directory - Specifies the OpenSSL source directory
325 echo Error: Unknown argument '%1'
330 echo Error: Only a Windows NT based Operating System is supported
335 echo Error: Cannot obtain the directory for Program Files
340 echo Error: %VC_DESC% is not installed
345 echo Error: Perl is not installed
350 echo Error: %VC_DESC% does not support 64-bit builds
355 echo Error: Cannot locate OpenSSL source directory
359 if "%OS%" == "Windows_NT" endlocal