Skip to content

Instantly share code, notes, and snippets.

@n0phx
Created February 6, 2022 00:20
Show Gist options
  • Save n0phx/c5c9c38a48d8994a029822815d6b17b2 to your computer and use it in GitHub Desktop.
Save n0phx/c5c9c38a48d8994a029822815d6b17b2 to your computer and use it in GitHub Desktop.
Build OpenSSL Batch file (Windows)
REM Dependencies: git, 7zip, ActivePerl, NASM, PowerShell, MSBuild, Visual Studio 2015
REM @echo off
setlocal
set VCVARSALL=%VS140COMNTOOLS%..\..\VC\vcvarsall.bat
if not exist "%VCVARSALL%" (
echo "vcvarsall.bat was not found on this path: %VCVARSALL%"
exit /b
)
set SEVENZIP_BIN=%ProgramFiles%\7-Zip\7z.exe
if not exist "%SEVENZIP_BIN%" (
echo "7-zip was not found on this path: %SEVENZIP_BIN%"
exit /b
)
set NASM_BIN=%SystemDrive%\NASM\nasm.exe
if not exist "%NASM_BIN%" (
echo "NASM was not found on this path: %NASM_BIN%"
exit /b
)
where /q perl
if errorlevel 1 (
echo "ActivePerl must be installed and it's executable added to the PATH environment variable."
exit /b
)
where /q git
if errorlevel 1 (
echo "git must be installed and it's executable added to the PATH environment variable."
exit /b
)
where /q powershell
if errorlevel 1 (
echo "powershell must be installed and it's executable added to the PATH environment variable."
exit /b
)
set BUILD_DIR=%CD%
set OPENSSL_VERSION=1.0.2j
set OPENSSL_NAME=openssl-%OPENSSL_VERSION%
set OPENSSL_FILE=%OPENSSL_NAME%.tar.gz
set OPENSSL_URL=https://www.openssl.org/source/%OPENSSL_FILE%
if not defined DevEnvDir (
call "%VCVARSALL%" x86
)
if not exist %OPENSSL_FILE% powershell Invoke-WebRequest $env:OPENSSL_URL -OutFile $env:BUILD_DIR\%OPENSSL_FILE% -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::FireFox
if not exist %OPENSSL_NAME% call :BUILD_OPENSSL_OLD
cd "%BUILD_DIR%"
goto :DONE
:BUILD_OPENSSL_OLD
cd "%BUILD_DIR%"
"%SEVENZIP_BIN%" x %OPENSSL_FILE% && "%SEVENZIP_BIN%" x %OPENSSL_NAME%.tar && del %OPENSSL_NAME%.tar
cd %OPENSSL_NAME%
perl Configure VC-WIN32
call ms\do_ms
call ms\do_nasm
nmake /f ms\nt.mak
exit /b
:BUILD_OPENSSL_NEW
cd %BUILD_DIR%
"%SEVENZIP_BIN%" x %OPENSSL_FILE% && "%SEVENZIP_BIN%" x %OPENSSL_NAME%.tar && del %OPENSSL_NAME%.tar
cd %OPENSSL_NAME%
perl Configure VC-WIN32 enable-static-engine
nmake
exit /b
:DONE
echo "Build completed"
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment