build-openssl.bat 8.3 KB

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