build-openssl.bat 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. @echo off
  2. rem ***************************************************************************
  3. rem * _ _ ____ _
  4. rem * Project ___| | | | _ \| |
  5. rem * / __| | | | |_) | |
  6. rem * | (__| |_| | _ <| |___
  7. rem * \___|\___/|_| \_\_____|
  8. rem *
  9. rem * Copyright (C) 2012 - 2021, Steve Holme, <steve_holme@hotmail.com>.
  10. rem *
  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.se/docs/copyright.html.
  14. rem *
  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.
  18. rem *
  19. rem * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  20. rem * KIND, either express or implied.
  21. rem *
  22. rem ***************************************************************************
  23. :begin
  24. rem Check we are running on a Windows NT derived OS
  25. if not "%OS%" == "Windows_NT" goto nodos
  26. rem Set our variables
  27. setlocal ENABLEDELAYEDEXPANSION
  28. set BUILD_CONFIG=
  29. set BUILD_PLATFORM=
  30. set SAVED_PATH=
  31. set SOURCE_PATH=
  32. set TMP_BUILD_PATH=
  33. set TMP_INSTALL_PATH=
  34. set VC_VER=
  35. rem Ensure we have the required arguments
  36. if /i "%~1" == "" goto syntax
  37. rem Calculate the program files directory
  38. if defined PROGRAMFILES (
  39. set "PF=%PROGRAMFILES%"
  40. set OS_PLATFORM=x86
  41. )
  42. if defined PROGRAMFILES(x86) (
  43. set "PF=%PROGRAMFILES(x86)%"
  44. set OS_PLATFORM=x64
  45. )
  46. :parseArgs
  47. if not "%~1" == "" (
  48. if /i "%~1" == "vc6" (
  49. set VC_VER=6.0
  50. set VC_DESC=VC6
  51. set "VC_PATH=Microsoft Visual Studio\VC98"
  52. ) else if /i "%~1" == "vc7" (
  53. set VC_VER=7.0
  54. set VC_DESC=VC7
  55. set "VC_PATH=Microsoft Visual Studio .NET\Vc7"
  56. ) else if /i "%~1" == "vc7.1" (
  57. set VC_VER=7.1
  58. set VC_DESC=VC7.1
  59. set "VC_PATH=Microsoft Visual Studio .NET 2003\Vc7"
  60. ) else if /i "%~1" == "vc8" (
  61. set VC_VER=8.0
  62. set VC_DESC=VC8
  63. set "VC_PATH=Microsoft Visual Studio 8\VC"
  64. ) else if /i "%~1" == "vc9" (
  65. set VC_VER=9.0
  66. set VC_DESC=VC9
  67. set "VC_PATH=Microsoft Visual Studio 9.0\VC"
  68. ) else if /i "%~1" == "vc10" (
  69. set VC_VER=10.0
  70. set VC_DESC=VC10
  71. set "VC_PATH=Microsoft Visual Studio 10.0\VC"
  72. ) else if /i "%~1" == "vc11" (
  73. set VC_VER=11.0
  74. set VC_DESC=VC11
  75. set "VC_PATH=Microsoft Visual Studio 11.0\VC"
  76. ) else if /i "%~1" == "vc12" (
  77. set VC_VER=12.0
  78. set VC_DESC=VC12
  79. set "VC_PATH=Microsoft Visual Studio 12.0\VC"
  80. ) else if /i "%~1" == "vc14" (
  81. set VC_VER=14.0
  82. set VC_DESC=VC14
  83. set "VC_PATH=Microsoft Visual Studio 14.0\VC"
  84. ) else if /i "%~1" == "vc14.1" (
  85. set VC_VER=14.1
  86. set VC_DESC=VC14.1
  87. rem Determine the VC14.1 path based on the installed edition in descending
  88. rem order (Enterprise, then Professional and finally Community)
  89. if exist "%PF%\Microsoft Visual Studio\2017\Enterprise\VC" (
  90. set "VC_PATH=Microsoft Visual Studio\2017\Enterprise\VC"
  91. ) else if exist "%PF%\Microsoft Visual Studio\2017\Professional\VC" (
  92. set "VC_PATH=Microsoft Visual Studio\2017\Professional\VC"
  93. ) else (
  94. set "VC_PATH=Microsoft Visual Studio\2017\Community\VC"
  95. )
  96. ) else if /i "%~1" == "vc14.2" (
  97. set VC_VER=14.2
  98. set VC_DESC=VC14.2
  99. rem Determine the VC14.2 path based on the installed edition in descending
  100. rem order (Enterprise, then Professional and finally Community)
  101. if exist "%PF%\Microsoft Visual Studio\2019\Enterprise\VC" (
  102. set "VC_PATH=Microsoft Visual Studio\2019\Enterprise\VC"
  103. ) else if exist "%PF%\Microsoft Visual Studio\2019\Professional\VC" (
  104. set "VC_PATH=Microsoft Visual Studio\2019\Professional\VC"
  105. ) else (
  106. set "VC_PATH=Microsoft Visual Studio\2019\Community\VC"
  107. )
  108. ) else if /i "%~1%" == "x86" (
  109. set BUILD_PLATFORM=x86
  110. ) else if /i "%~1%" == "x64" (
  111. set BUILD_PLATFORM=x64
  112. ) else if /i "%~1%" == "debug" (
  113. set BUILD_CONFIG=debug
  114. ) else if /i "%~1%" == "release" (
  115. set BUILD_CONFIG=release
  116. ) else if /i "%~1" == "-?" (
  117. goto syntax
  118. ) else if /i "%~1" == "-h" (
  119. goto syntax
  120. ) else if /i "%~1" == "-help" (
  121. goto syntax
  122. ) else if /i "%~1" == "-VSpath" (
  123. if "%~2" == "" (
  124. echo.
  125. echo Error. Please provide VS Path.
  126. goto error
  127. ) else (
  128. set "ABS_VC_PATH=%~2\VC"
  129. shift
  130. )
  131. ) else if /i "%~1" == "-perlpath" (
  132. if "%~2" == "" (
  133. echo.
  134. echo Error. Please provide Perl root Path.
  135. goto error
  136. ) else (
  137. set "PERL_PATH=%~2"
  138. shift
  139. )
  140. ) else (
  141. if not defined START_DIR (
  142. set "START_DIR=%~1%"
  143. ) else (
  144. goto unknown
  145. )
  146. )
  147. shift & goto parseArgs
  148. )
  149. :prerequisites
  150. rem Compiler is a required parameter
  151. if not defined VC_VER goto syntax
  152. rem Default the start directory if one isn't specified
  153. if not defined START_DIR set START_DIR=..\..\openssl
  154. if not defined ABS_VC_PATH (
  155. rem Check we have a program files directory
  156. if not defined PF goto nopf
  157. set "ABS_VC_PATH=%PF%\%VC_PATH%"
  158. )
  159. rem Check we have Visual Studio installed
  160. if not exist "%ABS_VC_PATH%" goto novc
  161. if not defined PERL_PATH (
  162. rem Check we have Perl in our path
  163. perl --version <NUL 1>NUL 2>&1
  164. if errorlevel 1 (
  165. rem It isn't so check we have it installed and set the path if it is
  166. if exist "%SystemDrive%\Perl" (
  167. set "PATH=%SystemDrive%\Perl\bin;%PATH%"
  168. ) else (
  169. if exist "%SystemDrive%\Perl64" (
  170. set "PATH=%SystemDrive%\Perl64\bin;%PATH%"
  171. ) else (
  172. goto noperl
  173. )
  174. )
  175. )
  176. ) else (
  177. set "PATH=%PERL_PATH%\Perl\bin;%PATH%"
  178. )
  179. rem Check the start directory exists
  180. if not exist "%START_DIR%" goto noopenssl
  181. :setup
  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
  189. ) else (
  190. set BUILD_PLATFORM=%OS_PLATFORM%
  191. )
  192. )
  193. if "%BUILD_PLATFORM%" == "x86" (
  194. set VCVARS_PLATFORM=x86
  195. ) else if "%BUILD_PLATFORM%" == "x64" (
  196. if "%VC_VER%" == "6.0" goto nox64
  197. if "%VC_VER%" == "7.0" goto nox64
  198. if "%VC_VER%" == "7.1" goto nox64
  199. if "%VC_VER%" == "8.0" set VCVARS_PLATFORM=x86_amd64
  200. if "%VC_VER%" == "9.0" set VCVARS_PLATFORM=%BUILD_PLATFORM%
  201. if "%VC_VER%" == "10.0" set VCVARS_PLATFORM=%BUILD_PLATFORM%
  202. if "%VC_VER%" == "11.0" set VCVARS_PLATFORM=amd64
  203. if "%VC_VER%" == "12.0" set VCVARS_PLATFORM=amd64
  204. if "%VC_VER%" == "14.0" set VCVARS_PLATFORM=amd64
  205. if "%VC_VER%" == "14.1" set VCVARS_PLATFORM=amd64
  206. if "%VC_VER%" == "14.2" set VCVARS_PLATFORM=amd64
  207. )
  208. if exist "%START_DIR%\ms\do_ms.bat" (
  209. set LEGACY_BUILD=TRUE
  210. ) else (
  211. set LEGACY_BUILD=FALSE
  212. )
  213. :start
  214. echo.
  215. set "SAVED_PATH=%CD%"
  216. if "%VC_VER%" == "6.0" (
  217. call "%ABS_VC_PATH%\bin\vcvars32"
  218. ) else if "%VC_VER%" == "7.0" (
  219. call "%ABS_VC_PATH%\bin\vcvars32"
  220. ) else if "%VC_VER%" == "7.1" (
  221. call "%ABS_VC_PATH%\bin\vcvars32"
  222. ) else if "%VC_VER%" == "14.1" (
  223. call "%ABS_VC_PATH%\Auxiliary\Build\vcvarsall" %VCVARS_PLATFORM%
  224. ) else if "%VC_VER%" == "14.2" (
  225. call "%ABS_VC_PATH%\Auxiliary\Build\vcvarsall" %VCVARS_PLATFORM%
  226. ) else (
  227. call "%ABS_VC_PATH%\vcvarsall" %VCVARS_PLATFORM%
  228. )
  229. echo.
  230. cd /d "%START_DIR%" || (echo Error: Failed cd start & exit /B 1)
  231. rem Save the full path of the openssl source dir
  232. set "SOURCE_PATH=%CD%"
  233. rem Set temporary paths for building and installing OpenSSL. If a temporary
  234. rem path is not the same as the source path then it is *removed* after the
  235. rem installation is completed.
  236. rem
  237. rem For legacy OpenSSL the temporary build path must be the source path.
  238. rem
  239. rem For OpenSSL 1.1.x the temporary paths must be separate not a descendant
  240. rem of the other, otherwise pdb files will be lost between builds.
  241. rem https://github.com/openssl/openssl/issues/10005
  242. rem
  243. if "%LEGACY_BUILD%" == "TRUE" (
  244. set "TMP_BUILD_PATH=%SOURCE_PATH%"
  245. set "TMP_INSTALL_PATH=%SOURCE_PATH%"
  246. ) else (
  247. set "TMP_BUILD_PATH=%SOURCE_PATH%\build\tmp_build"
  248. set "TMP_INSTALL_PATH=%SOURCE_PATH%\build\tmp_install"
  249. )
  250. goto %BUILD_PLATFORM%
  251. :x64
  252. rem Calculate our output directory
  253. set OUTDIR=build\Win64\%VC_DESC%
  254. if not exist %OUTDIR% md %OUTDIR%
  255. if not "%BUILD_CONFIG%" == "release" (
  256. rem Configuring 64-bit Static Library Debug Build
  257. call :configure x64 debug static %LEGACY_BUILD%
  258. rem Perform the build
  259. call :build x64 static %LEGACY_BUILD%
  260. rem Perform the install
  261. call :install debug static %LEGACY_BUILD%
  262. rem Configuring 64-bit Shared Library Debug Build
  263. call :configure x64 debug shared %LEGACY_BUILD%
  264. rem Perform the build
  265. call :build x64 shared %LEGACY_BUILD%
  266. rem Perform the install
  267. call :install debug shared %LEGACY_BUILD%
  268. )
  269. if not "%BUILD_CONFIG%" == "debug" (
  270. rem Configuring 64-bit Static Library Release Build
  271. call :configure x64 release static %LEGACY_BUILD%
  272. rem Perform the build
  273. call :build x64 static %LEGACY_BUILD%
  274. rem Perform the install
  275. call :install release static %LEGACY_BUILD%
  276. rem Configuring 64-bit Shared Library Release Build
  277. call :configure x64 release shared %LEGACY_BUILD%
  278. rem Perform the build
  279. call :build x64 shared %LEGACY_BUILD%
  280. rem Perform the install
  281. call :install release shared %LEGACY_BUILD%
  282. )
  283. goto success
  284. :x86
  285. rem Calculate our output directory
  286. set OUTDIR=build\Win32\%VC_DESC%
  287. if not exist %OUTDIR% md %OUTDIR%
  288. if not "%BUILD_CONFIG%" == "release" (
  289. rem Configuring 32-bit Static Library Debug Build
  290. call :configure x86 debug static %LEGACY_BUILD%
  291. rem Perform the build
  292. call :build x86 static %LEGACY_BUILD%
  293. rem Perform the install
  294. call :install debug static %LEGACY_BUILD%
  295. rem Configuring 32-bit Shared Library Debug Build
  296. call :configure x86 debug shared %LEGACY_BUILD%
  297. rem Perform the build
  298. call :build x86 shared %LEGACY_BUILD%
  299. rem Perform the install
  300. call :install debug shared %LEGACY_BUILD%
  301. )
  302. if not "%BUILD_CONFIG%" == "debug" (
  303. rem Configuring 32-bit Static Library Release Build
  304. call :configure x86 release static %LEGACY_BUILD%
  305. rem Perform the build
  306. call :build x86 static %LEGACY_BUILD%
  307. rem Perform the install
  308. call :install release static %LEGACY_BUILD%
  309. rem Configuring 32-bit Shared Library Release Build
  310. call :configure x86 release shared %LEGACY_BUILD%
  311. rem Perform the build
  312. call :build x86 shared %LEGACY_BUILD%
  313. rem Perform the install
  314. call :install release shared %LEGACY_BUILD%
  315. )
  316. goto success
  317. rem Function to configure the build.
  318. rem
  319. rem %1 - Platform (x86 or x64)
  320. rem %2 - Configuration (release or debug)
  321. rem %3 - Build Type (static or shared)
  322. rem %4 - Build type (TRUE for legacy aka pre v1.1.0; otherwise FALSE)
  323. rem
  324. :configure
  325. setlocal
  326. if "%1" == "" exit /B 1
  327. if "%2" == "" exit /B 1
  328. if "%3" == "" exit /B 1
  329. if "%4" == "" exit /B 1
  330. if not exist "%TMP_BUILD_PATH%" mkdir "%TMP_BUILD_PATH%"
  331. cd /d "%TMP_BUILD_PATH%" || (echo Error: Failed cd build & exit /B 1)
  332. if "%4" == "TRUE" (
  333. rem Calculate the configure options
  334. if "%1" == "x86" (
  335. if "%2" == "debug" (
  336. set options=debug-VC-WIN32
  337. ) else if "%2" == "release" (
  338. set options=VC-WIN32
  339. ) else (
  340. exit /B 1
  341. )
  342. set options=!options! no-asm
  343. ) else if "%1" == "x64" (
  344. if "%2" == "debug" (
  345. set options=debug-VC-WIN64A
  346. ) else if "%2" == "release" (
  347. set options=VC-WIN64A
  348. ) else (
  349. exit /B 1
  350. )
  351. ) else (
  352. exit /B 1
  353. )
  354. ) else if "%4" == "FALSE" (
  355. rem Has configure already been ran?
  356. if exist makefile (
  357. rem Clean up the previous build
  358. nmake clean
  359. rem Remove the old makefile
  360. del makefile 1>nul
  361. )
  362. rem Calculate the configure options
  363. if "%1" == "x86" (
  364. set options=VC-WIN32
  365. ) else if "%1" == "x64" (
  366. set options=VC-WIN64A
  367. ) else (
  368. exit /B 1
  369. )
  370. if "%2" == "debug" (
  371. set options=!options! --debug
  372. ) else if "%2" == "release" (
  373. set options=!options! --release
  374. ) else (
  375. exit /B 1
  376. )
  377. if "%3" == "static" (
  378. set options=!options! no-shared
  379. ) else if not "%3" == "shared" (
  380. exit /B 1
  381. )
  382. set options=!options! no-asm
  383. ) else (
  384. exit /B 1
  385. )
  386. rem Run the configure
  387. perl "%SOURCE_PATH%\Configure" %options% "--prefix=%TMP_INSTALL_PATH%"
  388. exit /B %ERRORLEVEL%
  389. rem Main build function.
  390. rem
  391. rem %1 - Platform (x86 or x64)
  392. rem %2 - Build Type (static or shared)
  393. rem %3 - Build type (TRUE for legacy aka pre v1.1.0; otherwise FALSE)
  394. rem
  395. :build
  396. setlocal
  397. if "%1" == "" exit /B 1
  398. if "%2" == "" exit /B 1
  399. if "%3" == "" exit /B 1
  400. cd /d "%TMP_BUILD_PATH%" || (echo Error: Failed cd build & exit /B 1)
  401. if "%3" == "TRUE" (
  402. if "%1" == "x86" (
  403. call ms\do_ms.bat
  404. ) else if "%1" == "x64" (
  405. call ms\do_win64a.bat
  406. ) else (
  407. exit /B 1
  408. )
  409. if "%2" == "static" (
  410. nmake -f ms\nt.mak
  411. ) else if "%2" == "shared" (
  412. nmake -f ms\ntdll.mak
  413. ) else (
  414. exit /B 1
  415. )
  416. ) else if "%3" == "FALSE" (
  417. nmake
  418. ) else (
  419. exit /B 1
  420. )
  421. exit /B 0
  422. rem Main installation function.
  423. rem
  424. rem %1 - Configuration (release or debug)
  425. rem %2 - Build Type (static or shared)
  426. rem %3 - Build type (TRUE for legacy aka pre v1.1.0; otherwise FALSE)
  427. rem
  428. :install
  429. setlocal
  430. if "%1" == "" exit /B 1
  431. if "%2" == "" exit /B 1
  432. if "%3" == "" exit /B 1
  433. rem Copy the generated files to our directory structure
  434. if "%3" == "TRUE" (
  435. rem There's no actual installation for legacy OpenSSL, the files are copied
  436. rem from the build dir (for legacy this is same as source dir) to the final
  437. rem location.
  438. cd /d "%SOURCE_PATH%" || (echo Error: Failed cd source & exit /B 1)
  439. if "%1" == "debug" (
  440. if "%2" == "static" (
  441. rem Move the output directories
  442. if exist "%OUTDIR%\LIB Debug" (
  443. copy /y out32.dbg\* "%OUTDIR%\LIB Debug" 1>nul
  444. rd out32.dbg /s /q
  445. ) else (
  446. move out32.dbg "%OUTDIR%\LIB Debug" 1>nul
  447. )
  448. rem Move the PDB files
  449. move tmp32.dbg\lib.pdb "%OUTDIR%\LIB Debug" 1>nul
  450. rem Remove the intermediate directories
  451. rd tmp32.dbg /s /q
  452. ) else if "%2" == "shared" (
  453. if exist "%OUTDIR%\DLL Debug" (
  454. copy /y out32dll.dbg\* "%OUTDIR%\DLL Debug" 1>nul
  455. rd out32dll.dbg /s /q
  456. ) else (
  457. move out32dll.dbg "%OUTDIR%\DLL Debug" 1>nul
  458. )
  459. rem Move the PDB files
  460. move tmp32dll.dbg\lib.pdb "%OUTDIR%\DLL Debug" 1>nul
  461. rem Remove the intermediate directories
  462. rd tmp32dll.dbg /s /q
  463. ) else (
  464. exit /B 1
  465. )
  466. ) else if "%1" == "release" (
  467. if "%2" == "static" (
  468. rem Move the output directories
  469. if exist "%OUTDIR%\LIB Release" (
  470. copy /y out32\* "%OUTDIR%\LIB Release" 1>nul
  471. rd out32 /s /q
  472. ) else (
  473. move out32 "%OUTDIR%\LIB Release" 1>nul
  474. )
  475. rem Move the PDB files
  476. move tmp32\lib.pdb "%OUTDIR%\LIB Release" 1>nul
  477. rem Remove the intermediate directories
  478. rd tmp32 /s /q
  479. ) else if "%2" == "shared" (
  480. if exist "%OUTDIR%\DLL Release" (
  481. copy /y out32dll\* "%OUTDIR%\DLL Release" 1>nul
  482. rd out32dll /s /q
  483. ) else (
  484. move out32dll "%OUTDIR%\DLL Release" 1>nul
  485. )
  486. rem Move the PDB files
  487. move tmp32dll\lib.pdb "%OUTDIR%\DLL Release" 1>nul
  488. rem Remove the intermediate directories
  489. rd tmp32dll /s /q
  490. ) else (
  491. exit /B 1
  492. )
  493. )
  494. ) else if "%3" == "FALSE" (
  495. cd /d "%TMP_BUILD_PATH%" || (echo Error: Failed cd build & exit /B 1)
  496. rem Perform the installation
  497. nmake install_sw
  498. cd /d "%SOURCE_PATH%" || (echo Error: Failed cd source & exit /B 1)
  499. rem Move the output directories
  500. if "%1" == "debug" (
  501. if "%2" == "static" (
  502. if not exist "%OUTDIR%\LIB Debug" (
  503. mkdir "%OUTDIR%\LIB Debug" 1>nul
  504. )
  505. move "%TMP_INSTALL_PATH%\lib\*.lib" "%OUTDIR%\LIB Debug" 1>nul
  506. move "%TMP_INSTALL_PATH%\lib\*.pdb" "%OUTDIR%\LIB Debug" 1>nul
  507. move "%TMP_INSTALL_PATH%\bin\*.exe" "%OUTDIR%\LIB Debug" 1>nul
  508. move "%TMP_INSTALL_PATH%\bin\*.pdb" "%OUTDIR%\LIB Debug" 1>nul
  509. xcopy /E /I /Y "%TMP_INSTALL_PATH%\include" "%OUTDIR%\LIB Debug\include" 1>nul
  510. ) else if "%2" == "shared" (
  511. if not exist "%OUTDIR%\DLL Debug" (
  512. mkdir "%OUTDIR%\DLL Debug" 1>nul
  513. )
  514. move "%TMP_INSTALL_PATH%\lib\*.lib" "%OUTDIR%\DLL Debug" 1>nul
  515. move "%TMP_INSTALL_PATH%\lib\engines-1_1\*.dll" "%OUTDIR%\DLL Debug" 1>nul
  516. move "%TMP_INSTALL_PATH%\lib\engines-1_1\*.pdb" "%OUTDIR%\DLL Debug" 1>nul
  517. move "%TMP_INSTALL_PATH%\bin\*.dll" "%OUTDIR%\DLL Debug" 1>nul
  518. move "%TMP_INSTALL_PATH%\bin\*.exe" "%OUTDIR%\DLL Debug" 1>nul
  519. move "%TMP_INSTALL_PATH%\bin\*.pdb" "%OUTDIR%\DLL Debug" 1>nul
  520. xcopy /E /I /Y "%TMP_INSTALL_PATH%\include" "%OUTDIR%\DLL Debug\include" 1>nul
  521. ) else (
  522. exit /B 1
  523. )
  524. ) else if "%1" == "release" (
  525. if "%2" == "static" (
  526. if not exist "%OUTDIR%\LIB Release" (
  527. mkdir "%OUTDIR%\LIB Release" 1>nul
  528. )
  529. move "%TMP_INSTALL_PATH%\lib\*.lib" "%OUTDIR%\LIB Release" 1>nul
  530. move "%TMP_INSTALL_PATH%\lib\*.pdb" "%OUTDIR%\LIB Release" 1>nul
  531. move "%TMP_INSTALL_PATH%\bin\*.exe" "%OUTDIR%\LIB Release" 1>nul
  532. move "%TMP_INSTALL_PATH%\bin\*.pdb" "%OUTDIR%\LIB Release" 1>nul
  533. xcopy /E /I /Y "%TMP_INSTALL_PATH%\include" "%OUTDIR%\LIB Release\include" 1>nul
  534. ) else if "%2" == "shared" (
  535. if not exist "%OUTDIR%\DLL Release" (
  536. mkdir "%OUTDIR%\DLL Release" 1>nul
  537. )
  538. move "%TMP_INSTALL_PATH%\lib\*.lib" "%OUTDIR%\DLL Release" 1>nul
  539. move "%TMP_INSTALL_PATH%\lib\engines-1_1\*.dll" "%OUTDIR%\DLL Release" 1>nul
  540. move "%TMP_INSTALL_PATH%\lib\engines-1_1\*.pdb" "%OUTDIR%\DLL Release" 1>nul
  541. move "%TMP_INSTALL_PATH%\bin\*.dll" "%OUTDIR%\DLL Release" 1>nul
  542. move "%TMP_INSTALL_PATH%\bin\*.exe" "%OUTDIR%\DLL Release" 1>nul
  543. move "%TMP_INSTALL_PATH%\bin\*.pdb" "%OUTDIR%\DLL Release" 1>nul
  544. xcopy /E /I /Y "%TMP_INSTALL_PATH%\include" "%OUTDIR%\DLL Release\include" 1>nul
  545. ) else (
  546. exit /B 1
  547. )
  548. ) else (
  549. exit /B 1
  550. )
  551. rem Remove the output directories
  552. if not "%SOURCE_PATH%" == "%TMP_BUILD_PATH%" (
  553. rd "%TMP_BUILD_PATH%" /s /q
  554. )
  555. if not "%SOURCE_PATH%" == "%TMP_INSTALL_PATH%" (
  556. rd "%TMP_INSTALL_PATH%" /s /q
  557. )
  558. ) else (
  559. exit /B 1
  560. )
  561. exit /B 0
  562. :syntax
  563. rem Display the help
  564. echo.
  565. echo Usage: build-openssl ^<compiler^> [platform] [configuration] [directory] [-VSpath] ["VSpath"] [-perlpath] ["perlpath"]
  566. echo.
  567. echo Compiler:
  568. echo.
  569. echo vc6 - Use Visual Studio 6
  570. echo vc7 - Use Visual Studio .NET
  571. echo vc7.1 - Use Visual Studio .NET 2003
  572. echo vc8 - Use Visual Studio 2005
  573. echo vc9 - Use Visual Studio 2008
  574. echo vc10 - Use Visual Studio 2010
  575. echo vc11 - Use Visual Studio 2012
  576. echo vc12 - Use Visual Studio 2013
  577. echo vc14 - Use Visual Studio 2015
  578. echo vc14.1 - Use Visual Studio 2017
  579. echo vc14.2 - Use Visual Studio 2019
  580. echo.
  581. echo Platform:
  582. echo.
  583. echo x86 - Perform a 32-bit build
  584. echo x64 - Perform a 64-bit build
  585. echo.
  586. echo Configuration:
  587. echo.
  588. echo debug - Perform a debug build
  589. echo release - Perform a release build
  590. echo.
  591. echo Other:
  592. echo.
  593. echo directory - Specifies the OpenSSL source directory
  594. echo.
  595. echo -VSpath - Specify the custom VS path if Visual Studio is not located at
  596. echo "C:\<ProgramFiles>\Microsoft Visual Studio <version>"
  597. echo For e.g. -VSpath "C:\apps\MVS14"
  598. echo.
  599. echo -perlpath - Specify the custom perl root path if perl is not located at
  600. echo "C:\Perl" and it is a portable copy of perl and not
  601. echo installed on the win system.
  602. echo For e.g. -perlpath "D:\strawberry-perl-5.24.3.1-64bit-portable"
  603. goto error
  604. :unknown
  605. echo.
  606. echo Error: Unknown argument '%1'
  607. goto error
  608. :nodos
  609. echo.
  610. echo Error: Only a Windows NT based Operating System is supported
  611. goto error
  612. :nopf
  613. echo.
  614. echo Error: Cannot obtain the directory for Program Files
  615. goto error
  616. :novc
  617. echo.
  618. echo Error: %VC_DESC% is not installed
  619. echo Error: Please check whether Visual compiler is installed at the path "%ABS_VC_PATH%"
  620. echo Error: Please provide proper VS Path by using -VSpath
  621. goto error
  622. :noperl
  623. echo.
  624. echo Error: Perl is not installed
  625. echo Error: Please check whether Perl is installed or it is at location "C:\Perl"
  626. echo Error: If Perl is portable please provide perl root path by using -perlpath
  627. goto error
  628. :nox64
  629. echo.
  630. echo Error: %VC_DESC% does not support 64-bit builds
  631. goto error
  632. :noopenssl
  633. echo.
  634. echo Error: Cannot locate OpenSSL source directory
  635. goto error
  636. :error
  637. if "%OS%" == "Windows_NT" endlocal
  638. exit /B 1
  639. :success
  640. cd /d "%SAVED_PATH%"
  641. endlocal
  642. exit /B 0