개발/오픈소스
OPENSSL WINDOWS 빌드 방법
-=HaeJuK=-
2024. 9. 2. 19:20
728x90
반응형
param(
[string]$vsVersion,
[string]$buildType = "Release",
[string]$arch = "x64"
)
if (-not $vsVersion -or ($buildType -notin @("Debug", "Release", "Release-MD")) -or ($arch -notin @("x64", "x86"))) {
Write-Host "Usage: .\build_openssl.ps1 -vsVersion <version> [-buildType Debug|Release|Release-MD] [-arch x64|x86]"
exit
}
# 변수 설정
$opensslSrcPath = "G:\ThirdParty\Source\OpenSSL\openssl_3.2.1\openssl-Debug"
$buildPath = "G:\ThirdParty\Source\OpenSSL\openssl_3.2.1\openssl-Debug\builds"
$perlPath = "C:\Strawberry\perl\bin"
$nasmPath = "C:\Program Files\NASM"
# 환경변수 설정
$env:Path += ";$perlPath;$nasmPath"
# 빌드 디렉토리 생성
$currentBuildPath = Join-Path $buildPath ("OpenSSL_${vsVersion}_${buildType}_${arch}")
New-Item -Path $currentBuildPath -ItemType Directory -Force
# 작업 디렉토리 변경
Set-Location -Path $opensslSrcPath
# Prepare OpenSSL configuration
$configureOptions = "no-idea no-md2 no-mdc2 no-rc5 no-rc4"
if ($buildType -eq "Release-MD") {
# $configureOptions += " no-static" # Dynamic linking for Release-MD
} else {
$configureOptions += " no-shared" # Static linking for Debug and Release
}
# Set the target based on architecture
if ($arch -eq "x64")
{
$target = "VC-WIN64A"
}
else
{
$target = "VC-WIN32"
}
if ($buildType -eq "Debug") {
$configureCommand = "perl Configure debug-$target $configureOptions --openssldir=$currentBuildPath --prefix=$currentBuildPath"
} elseif ($buildType -eq "Release") {
$configureCommand = "perl Configure $target $configureOptions --openssldir=$currentBuildPath --prefix=$currentBuildPath"
} elseif ($buildType -eq "Release-MD") {
$configureCommand = "perl Configure $target $configureOptions --openssldir=$currentBuildPath --prefix=$currentBuildPath"
}
# 사용자 정보 출력
Write-Host "====================================================================" -ForegroundColor Cyan
Write-Host "=== INFORMATION" -ForegroundColor Yellow
Write-Host "=== [VS Version]: $vsVersion" -ForegroundColor Green
Write-Host "=== [BUILD Type]: $buildType" -ForegroundColor Green
Write-Host "=== [ARCH]: $arch" -ForegroundColor Green
Write-Host "=== [configureOptions]: $configureOptions" -ForegroundColor Red
Write-Host "=== [DIR PATH]: $currentBuildPath" -ForegroundColor Green
Write-Host "=== [configureCommand]: $configureCommand" -ForegroundColor Blue
Write-Host "====================================================================" -ForegroundColor Cyan
# 사용자 확인 요청
$response = Read-Host "Is the above information correct? (y/n)"
if ($response -ne 'y') {
Write-Host "Process aborted by user." -ForegroundColor Red
exit
}
Write-Host "Configuring OpenSSL for Visual Studio $vsVersion, $buildType, $arch..."
Invoke-Expression -Command $configureCommand
# OpenSSL 빌드
Write-Host "Building OpenSSL..."
Invoke-Expression -Command "nmake"
# OpenSSL 빌드 테스트
Write-Host "Testing OpenSSL build..."
Invoke-Expression -Command "nmake test"
# OpenSSL 설치
Write-Host "Installing OpenSSL..."
Invoke-Expression -Command "nmake install"
# 작업 디렉토리 복원
Set-Location -Path $currentBuildPath
# 정리
Invoke-Expression -Command "nmake clean"
Write-Host "Build process for Visual Studio $vsVersion $buildType $arch completed."
728x90