Guest User

Untitled

a guest
Jun 26th, 2014
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. setlocal enableextensions enabledelayedexpansion
  3.  
  4. REM ### Builds OpenSSL
  5. REM ###
  6. REM ### A related blog post that steps through this process:
  7. REM ### http://developer.covenanteyes.com/building-openssl-for-visual-studio/
  8.  
  9. set OD=%CD%
  10. cd /D %~dp0
  11. title Open SSL
  12.  
  13. if "%1"=="" goto :USAGE
  14. SET PLATFORM=%1
  15.  
  16. REM ### Set up directory structure
  17. if not exist src mkdir src
  18. if not exist src\%PLATFORM% mkdir src\%PLATFORM%
  19. if not exist src\%PLATFORM%\openssl-1.0.1h mkdir src\%PLATFORM%\openssl-1.0.1h
  20. cd /D src\%PLATFORM%\openssl-1.0.1h
  21.  
  22. REM ### Check for currency
  23. if exist openssl-1.0.1h-%PLATFORM%.touch (
  24.     echo OpenSSL %PLATFORM% is current at version 1.0.1h.
  25.     goto :END
  26. )
  27.  
  28. :DOWNLOAD
  29. REM ### Download the source code
  30. IF NOT EXIST openssl-1.0.1h.tar.gz (
  31.     echo retrieving OpenSSL source code
  32.     wget -nv -N https://s3.amazonaws.com/REDACTED/software/openssl/openssl-1.0.1h.tar.gz
  33. )
  34.  
  35. :EXTRACT
  36. IF NOT EXIST openssl-1.0.1h.tar (
  37.     rm -f 7z.1.log
  38.     7za.exe x -y openssl-1.0.1h.tar.gz > 7z.1.log || goto :ERROR
  39.     attrib +h 7z.1.log
  40. )
  41.  
  42. REM ### Clean the working directory
  43. rm -rf openssl-1.0.1h 7z.2.log
  44. REM ### Extract the source code
  45. 7za.exe x -y openssl-1.0.1h.tar -o"." > 7z.2.log || goto :ERROR
  46. attrib +h 7z.2.log
  47.  
  48. :INSTALL
  49. if "%PLATFORM%"=="x86" GOTO :INSTALL_x86
  50. if "%PLATFORM%"=="x64" GOTO :INSTALL_x64
  51. echo "ERROR! Platform should be x86 or x64"
  52.  
  53. REM ### -- x86 version
  54. :INSTALL_x86
  55. rm -rf OpenSSL-x86
  56. mkdir OpenSSL-x86
  57. cd /d openssl-1.0.1h
  58. perl.exe Configure VC-WIN32 --prefix="..\OpenSSL-x86" || goto :ERROR
  59. call ms\do_nasm || goto :ERROR
  60. call "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" x86
  61. nmake -f ms\ntdll.mak || goto :ERROR
  62. nmake -f ms\ntdll.mak install || goto :ERROR
  63. echo x86 build complete
  64. touch ..\openssl-1.0.1h-%PLATFORM%.touch
  65. GOTO :END
  66.  
  67. REM ### -- x64 version
  68. REM ### -- note, no call to "do_nasm" for x64. not sure why
  69. REM ### -- but the documentation instructs us thusly.
  70. REM ### -- We must also pass the "no-asm" directive to "Configure"
  71. REM ### -- and we must ensure that "nasm.exe" is *not* on the system path.
  72. :INSTALL_x64
  73. rm -rf OpenSSL-x64
  74. mkdir OpenSSL-x64
  75. cd openssl-1.0.1h
  76. perl.exe Configure VC-WIN64A no-asm --prefix="..\OpenSSL-x64" || goto :ERROR
  77. call ms\do_win64a || goto :ERROR
  78. call "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" x64
  79. nmake -f ms\ntdll.mak || goto :ERROR
  80. nmake -f ms\ntdll.mak install || goto :ERROR
  81. echo x64 build complete
  82. touch ..\openssl-1.0.1h-%PLATFORM%.touch
  83. GOTO :END
  84.  
  85. :USAGE
  86. echo Usage: %0 [platform]
  87. GOTO :END
  88.  
  89. :ERROR
  90. echo Build FAILED with exit code %ERRORLEVEL%
  91. exit /b %ERRORLEVEL%
  92.  
  93. :END
  94. cd /d %OD%
  95. endlocal
  96.  
  97. :EOF
Advertisement
Add Comment
Please, Sign In to add comment