build-openssl.bat 21 KB

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