1@echo off 2rem *************************************************************************** 3rem * _ _ ____ _ 4rem * Project ___| | | | _ \| | 5rem * / __| | | | |_) | | 6rem * | (__| |_| | _ <| |___ 7rem * \___|\___/|_| \_\_____| 8rem * 9rem * Copyright (C) 2012 - 2015, 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 http://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 setlocal 28 29 rem Display the help 30 if /i "%~1" == "" goto syntax 31 if /i "%~1" == "-?" goto syntax 32 if /i "%~1" == "-h" goto syntax 33 if /i "%~1" == "-help" goto syntax 34 35:parseArgs 36 if "%~1" == "" goto prerequisites 37 38 if /i "%~1" == "vc6" ( 39 set VC_VER=6.0 40 set VC_DESC=VC6 41 set "VC_PATH=Microsoft Visual Studio\VC98" 42 ) else if /i "%~1" == "vc7" ( 43 set VC_VER=7.0 44 set VC_DESC=VC7 45 set "VC_PATH=Microsoft Visual Studio .NET\Vc7" 46 ) else if /i "%~1" == "vc7.1" ( 47 set VC_VER=7.1 48 set VC_DESC=VC7.1 49 set "VC_PATH=Microsoft Visual Studio .NET 2003\Vc7" 50 ) else if /i "%~1" == "vc8" ( 51 set VC_VER=8.0 52 set VC_DESC=VC8 53 set "VC_PATH=Microsoft Visual Studio 8\VC" 54 ) else if /i "%~1" == "vc9" ( 55 set VC_VER=9.0 56 set VC_DESC=VC9 57 set "VC_PATH=Microsoft Visual Studio 9.0\VC" 58 ) else if /i "%~1" == "vc10" ( 59 set VC_VER=10.0 60 set VC_DESC=VC10 61 set "VC_PATH=Microsoft Visual Studio 10.0\VC" 62 ) else if /i "%~1" == "vc11" ( 63 set VC_VER=11.0 64 set VC_DESC=VC11 65 set "VC_PATH=Microsoft Visual Studio 11.0\VC" 66 ) else if /i "%~1" == "vc12" ( 67 set VC_VER=12.0 68 set VC_DESC=VC12 69 set "VC_PATH=Microsoft Visual Studio 12.0\VC" 70 ) else if /i "%~1%" == "x86" ( 71 set BUILD_PLATFORM=x86 72 ) else if /i "%~1%" == "x64" ( 73 set BUILD_PLATFORM=x64 74 ) else if /i "%~1%" == "debug" ( 75 set BUILD_CONFIG=debug 76 ) else if /i "%~1%" == "release" ( 77 set BUILD_CONFIG=release 78 ) else ( 79 if not defined START_DIR ( 80 set START_DIR=%~1% 81 ) else ( 82 goto unknown 83 ) 84 ) 85 86 shift & goto parseArgs 87 88:prerequisites 89 rem Default the start directory if one isn't specified 90 if not defined START_DIR set START_DIR=..\..\openssl 91 92 rem Calculate the program files directory 93 if defined PROGRAMFILES ( 94 set "PF=%PROGRAMFILES%" 95 set OS_PLATFORM=x86 96 ) 97 if defined PROGRAMFILES(x86) ( 98 set "PF=%PROGRAMFILES(x86)%" 99 set OS_PLATFORM=x64 100 ) 101 102 rem Check we have a program files directory 103 if not defined PF goto nopf 104 105 rem Check we have Visual Studio installed 106 if not exist "%PF%\%VC_PATH%" goto novc 107 108 rem Check we have Perl installed 109 echo %PATH% | findstr /I /C:"\Perl" 1>nul 110 if errorlevel 1 ( 111 if not exist "%SystemDrive%\Perl" ( 112 if not exist "%SystemDrive%\Perl64" goto noperl 113 ) 114 ) 115 116 rem Check the start directory exists 117 if not exist "%START_DIR%" goto noopenssl 118 119:configure 120 if "%BUILD_PLATFORM%" == "" ( 121 if "%VC_VER%" == "6.0" ( 122 set BUILD_PLATFORM=x86 123 ) else if "%VC_VER%" == "7.0" ( 124 set BUILD_PLATFORM=x86 125 ) else if "%VC_VER%" == "7.1" ( 126 set BUILD_PLATFORM=x86 127 ) else ( 128 set BUILD_PLATFORM=%OS_PLATFORM% 129 ) 130 ) 131 132 if "%BUILD_PLATFORM%" == "x86" ( 133 set VCVARS_PLATFORM=x86 134 ) else if "%BUILD_PLATFORM%" == "x64" ( 135 if "%VC_VER%" == "6.0" goto nox64 136 if "%VC_VER%" == "7.0" goto nox64 137 if "%VC_VER%" == "7.1" goto nox64 138 if "%VC_VER%" == "8.0" set VCVARS_PLATFORM=x86_amd64 139 if "%VC_VER%" == "9.0" set VCVARS_PLATFORM=%BUILD_PLATFORM% 140 if "%VC_VER%" == "10.0" set VCVARS_PLATFORM=%BUILD_PLATFORM% 141 if "%VC_VER%" == "11.0" set VCVARS_PLATFORM=amd64 142 if "%VC_VER%" == "12.0" set VCVARS_PLATFORM=amd64 143 ) 144 145:start 146 echo. 147 if "%VC_VER%" == "6.0" ( 148 call "%PF%\%VC_PATH%\bin\vcvars32" 149 ) else if "%VC_VER%" == "7.0" ( 150 call "%PF%\%VC_PATH%\bin\vcvars32" 151 ) else if "%VC_VER%" == "7.1" ( 152 call "%PF%\%VC_PATH%\bin\vcvars32" 153 ) else ( 154 call "%PF%\%VC_PATH%\vcvarsall" %VCVARS_PLATFORM% 155 ) 156 157 echo. 158 set SAVED_PATH=%CD% 159 if defined START_DIR CD %START_DIR% 160 goto %BUILD_PLATFORM% 161 162:x64 163 rem Calculate our output directory 164 set OUTDIR=build\Win64\%VC_DESC% 165 if not exist %OUTDIR% md %OUTDIR% 166 167 if "%BUILD_CONFIG%" == "release" goto x64release 168 169:x64debug 170 rem Configuring 64-bit Debug Build 171 perl Configure debug-VC-WIN64A --prefix=%CD% 172 173 rem Perform the build 174 call ms\do_win64a 175 nmake -f ms\nt.mak 176 nmake -f ms\ntdll.mak 177 178 rem Move the output directories 179 move out32.dbg "%OUTDIR%\LIB Debug" 180 move out32dll.dbg "%OUTDIR%\DLL Debug" 181 182 rem Move the PDB files 183 move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug" 184 move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug" 185 186 rem Remove the intermediate directories 187 rd tmp32.dbg /s /q 188 rd tmp32dll.dbg /s /q 189 190 if "%BUILD_CONFIG%" == "debug" goto success 191 192:x64release 193 rem Configuring 64-bit Release Build 194 perl Configure 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 "%OUTDIR%\LIB Release" 203 move out32dll "%OUTDIR%\DLL Release" 204 205 rem Move the PDB files 206 move tmp32\lib.pdb "%OUTDIR%\LIB Release" 207 move tmp32dll\lib.pdb "%OUTDIR%\DLL Release" 208 209 rem Remove the intermediate directories 210 rd tmp32 /s /q 211 rd tmp32dll /s /q 212 213 goto success 214 215:x86 216 rem Calculate our output directory 217 set OUTDIR=build\Win32\%VC_DESC% 218 if not exist %OUTDIR% md %OUTDIR% 219 220 if "%BUILD_CONFIG%" == "release" goto x86release 221 222:x86debug 223 rem Configuring 32-bit Debug Build 224 perl Configure debug-VC-WIN32 no-asm --prefix=%CD% 225 226 rem Perform the build 227 call ms\do_ms 228 nmake -f ms\nt.mak 229 nmake -f ms\ntdll.mak 230 231 rem Move the output directories 232 move out32.dbg "%OUTDIR%\LIB Debug" 233 move out32dll.dbg "%OUTDIR%\DLL Debug" 234 235 rem Move the PDB files 236 move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug" 237 move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug" 238 239 rem Remove the intermediate directories 240 rd tmp32.dbg /s /q 241 rd tmp32dll.dbg /s /q 242 243 if "%BUILD_CONFIG%" == "debug" goto success 244 245:x86release 246 rem Configuring 32-bit Release Build 247 perl Configure 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 "%OUTDIR%\LIB Release" 256 move out32dll "%OUTDIR%\DLL Release" 257 258 rem Move the PDB files 259 move tmp32\lib.pdb "%OUTDIR%\LIB Release" 260 move tmp32dll\lib.pdb "%OUTDIR%\DLL Release" 261 262 rem Remove the intermediate directories 263 rd tmp32 /s /q 264 rd tmp32dll /s /q 265 266 goto success 267 268:syntax 269 rem Display the help 270 echo. 271 echo Usage: build-openssl ^<compiler^> ^<platform^> [configuration] [directory] 272 echo. 273 echo Compiler: 274 echo. 275 echo vc6 - Use Visual Studio 6 276 echo vc7 - Use Visual Studio .NET 277 echo vc7.1 - Use Visual Studio .NET 2003 278 echo vc8 - Use Visual Studio 2005 279 echo vc9 - Use Visual Studio 2008 280 echo vc10 - Use Visual Studio 2010 281 echo vc11 - Use Visual Studio 2012 282 echo vc12 - Use Visual Studio 2013 283 echo. 284 echo Platform: 285 echo. 286 echo x86 - Perform a 32-bit build 287 echo x64 - Perform a 64-bit build 288 echo. 289 echo Configuration: 290 echo. 291 echo debug - Perform a debug build 292 echo release - Perform a release build 293 echo. 294 echo Other: 295 echo. 296 echo directory - Specifies the OpenSSL source directory 297 goto error 298 299:unknown 300 echo. 301 echo Error: Unknown argument '%1' 302 goto error 303 304:nodos 305 echo. 306 echo Error: Only a Windows NT based Operating System is supported 307 goto error 308 309:nopf 310 echo. 311 echo Error: Cannot obtain the directory for Program Files 312 goto error 313 314:novc 315 echo. 316 echo Error: %VC_DESC% is not installed 317 goto error 318 319:noperl 320 echo. 321 echo Error: Perl is not installed 322 goto error 323 324:nox64 325 echo. 326 echo Error: %VC_DESC% does not support 64-bit builds 327 goto error 328 329:noopenssl 330 echo. 331 echo Error: Cannot locate OpenSSL source directory 332 goto error 333 334:error 335 if "%OS%" == "Windows_NT" endlocal 336 exit /B 1 337 338:success 339 cd %SAVED_PATH% 340 endlocal 341 exit /B 0 342