build-openssl.bat 21 KB

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