1@echo off 2rem *************************************************************************** 3rem * _ _ ____ _ 4rem * Project ___| | | | _ \| | 5rem * / __| | | | |_) | | 6rem * | (__| |_| | _ <| |___ 7rem * \___|\___/|_| \_\_____| 8rem * 9rem * Copyright (C) 2012 - 2016, Steve Holme, <steve_holme@hotmail.com>. 10rem * 11rem * This software is licensed as described in the file COPYING, which 12rem * you should have received as part of this distribution. The terms 13rem * are also available at https://curl.haxx.se/docs/copyright.html. 14rem * 15rem * You may opt to use, copy, modify, merge, publish, distribute and/or sell 16rem * copies of the Software, and permit persons to whom the Software is 17rem * furnished to do so, under the terms of the COPYING file. 18rem * 19rem * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 20rem * KIND, either express or implied. 21rem * 22rem *************************************************************************** 23 24:begin 25 rem Check we are running on a Windows NT derived OS 26 if not "%OS%" == "Windows_NT" goto nodos 27 28 rem Set our variables 29 setlocal 30 set VC_VER= 31 set BUILD_PLATFORM= 32 33 rem Ensure we have the required arguments 34 if /i "%~1" == "" goto syntax 35 36:parseArgs 37 if "%~1" == "" goto prerequisites 38 39 if /i "%~1" == "vc6" ( 40 set VC_VER=6.0 41 set VC_DESC=VC6 42 set "VC_PATH=Microsoft Visual Studio\VC98" 43 ) else if /i "%~1" == "vc7" ( 44 set VC_VER=7.0 45 set VC_DESC=VC7 46 set "VC_PATH=Microsoft Visual Studio .NET\Vc7" 47 ) else if /i "%~1" == "vc7.1" ( 48 set VC_VER=7.1 49 set VC_DESC=VC7.1 50 set "VC_PATH=Microsoft Visual Studio .NET 2003\Vc7" 51 ) else if /i "%~1" == "vc8" ( 52 set VC_VER=8.0 53 set VC_DESC=VC8 54 set "VC_PATH=Microsoft Visual Studio 8\VC" 55 ) else if /i "%~1" == "vc9" ( 56 set VC_VER=9.0 57 set VC_DESC=VC9 58 set "VC_PATH=Microsoft Visual Studio 9.0\VC" 59 ) else if /i "%~1" == "vc10" ( 60 set VC_VER=10.0 61 set VC_DESC=VC10 62 set "VC_PATH=Microsoft Visual Studio 10.0\VC" 63 ) else if /i "%~1" == "vc11" ( 64 set VC_VER=11.0 65 set VC_DESC=VC11 66 set "VC_PATH=Microsoft Visual Studio 11.0\VC" 67 ) else if /i "%~1" == "vc12" ( 68 set VC_VER=12.0 69 set VC_DESC=VC12 70 set "VC_PATH=Microsoft Visual Studio 12.0\VC" 71 ) else if /i "%~1" == "vc14" ( 72 set VC_VER=14.0 73 set VC_DESC=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" == "-?" ( 84 goto syntax 85 ) else if /i "%~1" == "-h" ( 86 goto syntax 87 ) else if /i "%~1" == "-help" ( 88 goto syntax 89 ) else ( 90 if not defined START_DIR ( 91 set START_DIR=%~1% 92 ) else ( 93 goto unknown 94 ) 95 ) 96 97 shift & goto parseArgs 98 99:prerequisites 100 rem Compiler and platform are required parameters. 101 if not defined VC_VER goto syntax 102 if not defined BUILD_PLATFORM goto syntax 103 104 rem Default the start directory if one isn't specified 105 if not defined START_DIR set START_DIR=..\..\openssl 106 107 rem Calculate the program files directory 108 if defined PROGRAMFILES ( 109 set "PF=%PROGRAMFILES%" 110 set OS_PLATFORM=x86 111 ) 112 if defined PROGRAMFILES(x86) ( 113 set "PF=%PROGRAMFILES(x86)%" 114 set OS_PLATFORM=x64 115 ) 116 117 rem Check we have a program files directory 118 if not defined PF goto nopf 119 120 rem Check we have Visual Studio installed 121 if not exist "%PF%\%VC_PATH%" goto novc 122 123 rem Check we have Perl in our path 124 echo %PATH% | findstr /I /C:"\Perl" 1>nul 125 if errorlevel 1 ( 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%" 129 ) else ( 130 if exist "%SystemDrive%\Perl64" ( 131 set "PATH=%SystemDrive%\Perl64\bin;%PATH%" 132 ) else ( 133 goto noperl 134 ) 135 ) 136 ) 137 138 rem Check the start directory exists 139 if not exist "%START_DIR%" goto noopenssl 140 141:configure 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 149 ) else ( 150 set BUILD_PLATFORM=%OS_PLATFORM% 151 ) 152 ) 153 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 166 ) 167 168:start 169 echo. 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" 176 ) else ( 177 call "%PF%\%VC_PATH%\vcvarsall" %VCVARS_PLATFORM% 178 ) 179 180 echo. 181 set SAVED_PATH=%CD% 182 if defined START_DIR CD %START_DIR% 183 goto %BUILD_PLATFORM% 184 185:x64 186 rem Calculate our output directory 187 set OUTDIR=build\Win64\%VC_DESC% 188 if not exist %OUTDIR% md %OUTDIR% 189 190 if "%BUILD_CONFIG%" == "release" goto x64release 191 192:x64debug 193 rem Configuring 64-bit Debug Build 194 perl Configure debug-VC-WIN64A --prefix=%CD% 195 196 rem Perform the build 197 call ms\do_win64a 198 nmake -f ms\nt.mak 199 nmake -f ms\ntdll.mak 200 201 rem Move the output directories 202 move out32.dbg "%OUTDIR%\LIB Debug" 203 move out32dll.dbg "%OUTDIR%\DLL Debug" 204 205 rem Move the PDB files 206 move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug" 207 move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug" 208 209 rem Remove the intermediate directories 210 rd tmp32.dbg /s /q 211 rd tmp32dll.dbg /s /q 212 213 if "%BUILD_CONFIG%" == "debug" goto success 214 215:x64release 216 rem Configuring 64-bit Release Build 217 perl Configure VC-WIN64A --prefix=%CD% 218 219 rem Perform the build 220 call ms\do_win64a 221 nmake -f ms\nt.mak 222 nmake -f ms\ntdll.mak 223 224 rem Move the output directories 225 move out32 "%OUTDIR%\LIB Release" 226 move out32dll "%OUTDIR%\DLL Release" 227 228 rem Move the PDB files 229 move tmp32\lib.pdb "%OUTDIR%\LIB Release" 230 move tmp32dll\lib.pdb "%OUTDIR%\DLL Release" 231 232 rem Remove the intermediate directories 233 rd tmp32 /s /q 234 rd tmp32dll /s /q 235 236 goto success 237 238:x86 239 rem Calculate our output directory 240 set OUTDIR=build\Win32\%VC_DESC% 241 if not exist %OUTDIR% md %OUTDIR% 242 243 if "%BUILD_CONFIG%" == "release" goto x86release 244 245:x86debug 246 rem Configuring 32-bit Debug Build 247 perl Configure debug-VC-WIN32 no-asm --prefix=%CD% 248 249 rem Perform the build 250 call ms\do_ms 251 nmake -f ms\nt.mak 252 nmake -f ms\ntdll.mak 253 254 rem Move the output directories 255 move out32.dbg "%OUTDIR%\LIB Debug" 256 move out32dll.dbg "%OUTDIR%\DLL Debug" 257 258 rem Move the PDB files 259 move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug" 260 move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug" 261 262 rem Remove the intermediate directories 263 rd tmp32.dbg /s /q 264 rd tmp32dll.dbg /s /q 265 266 if "%BUILD_CONFIG%" == "debug" goto success 267 268:x86release 269 rem Configuring 32-bit Release Build 270 perl Configure VC-WIN32 no-asm --prefix=%CD% 271 272 rem Perform the build 273 call ms\do_ms 274 nmake -f ms\nt.mak 275 nmake -f ms\ntdll.mak 276 277 rem Move the output directories 278 move out32 "%OUTDIR%\LIB Release" 279 move out32dll "%OUTDIR%\DLL Release" 280 281 rem Move the PDB files 282 move tmp32\lib.pdb "%OUTDIR%\LIB Release" 283 move tmp32dll\lib.pdb "%OUTDIR%\DLL Release" 284 285 rem Remove the intermediate directories 286 rd tmp32 /s /q 287 rd tmp32dll /s /q 288 289 goto success 290 291:syntax 292 rem Display the help 293 echo. 294 echo Usage: build-openssl ^<compiler^> ^<platform^> [configuration] [directory] 295 echo. 296 echo Compiler: 297 echo. 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 307 echo. 308 echo Platform: 309 echo. 310 echo x86 - Perform a 32-bit build 311 echo x64 - Perform a 64-bit build 312 echo. 313 echo Configuration: 314 echo. 315 echo debug - Perform a debug build 316 echo release - Perform a release build 317 echo. 318 echo Other: 319 echo. 320 echo directory - Specifies the OpenSSL source directory 321 goto error 322 323:unknown 324 echo. 325 echo Error: Unknown argument '%1' 326 goto error 327 328:nodos 329 echo. 330 echo Error: Only a Windows NT based Operating System is supported 331 goto error 332 333:nopf 334 echo. 335 echo Error: Cannot obtain the directory for Program Files 336 goto error 337 338:novc 339 echo. 340 echo Error: %VC_DESC% is not installed 341 goto error 342 343:noperl 344 echo. 345 echo Error: Perl is not installed 346 goto error 347 348:nox64 349 echo. 350 echo Error: %VC_DESC% does not support 64-bit builds 351 goto error 352 353:noopenssl 354 echo. 355 echo Error: Cannot locate OpenSSL source directory 356 goto error 357 358:error 359 if "%OS%" == "Windows_NT" endlocal 360 exit /B 1 361 362:success 363 cd %SAVED_PATH% 364 endlocal 365 exit /B 0 366