bat脚本+vs2019编译openssl(x86 | x64) - (static | shared) - (debug | release)
一、準備工作(perl, nasm, cygwin)
工作需要,我要以(x86 | x64) - (static | shared) - (debug | release)選項編譯openssl,最終得到8個版本:
下載安裝vs2019,去github下載openssl源碼,這兩步不介紹。。。
安裝perl, nasm, cygwin:
http://strawberryperl.com/
https://www.nasm.us
https://www.cygwin.com/
安裝perl只需一路下一步,nasm需要在安裝成功后自行添加環境變量,確保perl和nasm命令在cmd中可用,只需 perl --help 和 nasm --help 驗證一下即可。
cygwin稍微麻煩一點,除了 cygwin 本身,還需要安裝3個命令行工具:p7zip, md5sum, patch
方法有很多,命令行應該可以下載,但是我喜歡圖形界面,下面簡單介紹一下方法,首先需要安裝
setup-x86_64.exe,安裝成功后桌面應該會有一個快捷方式:
不用管這個,我們再次運行安裝程序 setup-x86_64.exe,再次進入安裝界面:
一路下一步直到來到這個界面:
view 這里選擇 full,然后在 search 里搜索這三個工具,其中md5sum 是默認伴隨 cygwin 安裝的,另外兩個需要我們自己裝,操作過程如下圖:
大概就是這樣,選擇最新版本,然后一路下一步就行了。
二、準備腳本
https://www.npcglib.org/~stathis/blog/precompiled-openssl/
這個網站提供openssl預編譯版本,但是最高只到vs2017和openssl 1.1.0,我需要 vs2019和openssl 1.1.1,但是沒關系,網站提供了編譯腳本:
接下來只需要把批處理腳本和 patch 文件下下來,自己修改就行了,其實你不用往下看了。
不過,為了避免我以后忘掉了,我這里還是記錄一下步驟。
他提供了批處理,還有一個 patch ,其實 patch可有可無,它是用來修改代碼,加上編譯參數的。我自己修改了批處理,刪減了一些代碼和注釋,您只需要修改一下里面一下路徑,應該就能直接用了。如果我這個腳本在你這不能工作,建議你直接去提供腳本的網站下載,然后自行修改。
直接運行腳本:
build-openssl-1.1.0k.bat build all然后睡個覺,睡醒就編譯好了。
三、腳本代碼
你需要修改里面的一些版本號和路徑。
@echo off SETLOCAL EnableExtensions EnableDelayedExpansion:: VS 版本 SET VS_VERSION=2019:: VS VC 路徑 SET VISUAL_STUDIO_VC=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC:: Set CYGWIN_DIR to the location of your Cygwin root ( one level up from /bin ) :: Make sure you install the following cygwin packages: p7zip, md5sum, patchSET CYGWIN_DIR=C:\cygwin64SET PERL_ROOT=C:\Strawberry\perl\binrem ========================================================================================================SET SEVENZIP_CMD=7zSET MD5SUM_CMD=md5sumSET DATE_CMD=dateSET PATCH_CMD=patchSET DOS2UNIX_CMD=dos2unixrem ========================================================================================================SET BUILD_PROJECT=opensslSET PROJECT_VERSION=1.1.0k:: 這里需要改為你自己的路徑 SET PROJECT_SRC_DIR=C:\Users\Pig\Desktop\openssl-OpenSSL_1_1_1k SET PROJECT_BUILD_DIR=C:\Users\Pig\Desktop\openssl-OpenSSL_1_1_1k\build SET PROJECT_INSTALL_DIR=C:\Users\Pig\Desktop\openssl-OpenSSL_1_1_1k\installrem ======================================================================================================== rem == PLEASE DO NOT EDIT BELOW THIS LINE rem ========================================================================================================rem We load the config file first call :loadconfig "%~dpn0"rem we then carry on execution call :execScript %0 %1 %2 %3 %4ENDLOCAL@exit /B 0rem ======================================================================================================== rem == Pseudo-function to load config rem ========================================================================================================:loadconfig rem set the variable HOSTNAME by executing the command (that's the computer's name) FOR /F "delims=" %%a IN ('hostname') DO @set HOSTNAME=%%arem strip double quotes set scriptFile=%1 set scriptFile=%scriptFile:"=%rem We use two files: myScript.conf and myScript.<HOSTNAME> rem myScript.<HOSTNAME> overrides myScript.conf rem %~dpn0 is the full file minus the extension. FOR %%c IN ("!scriptFile!.conf""!scriptFile!.!HOSTNAME!" ) DO (IF EXIST "%%c" (ECHO.ECHO # Loading local configuration from: %%cECHO.FOR /F "usebackq delims=" %%v IN (%%c) DO (set %%v)) )GOTO :eofrem ========================================================================================================:execScript rem Use this pseudo-function to write the code of your main script SETLOCAL EnableExtensions EnableDelayedExpansionSET scriptName=%1 SET arg[0]=%2 SET arg[1]=%3 SET arg[2]=%4 SET arg[3]=%5:: ATTENTION: this is down here because out-of-source builds are not supported DO NOT CHANGE IT! :: SET PROJECT_BUILD_DIR=!PROJECT_SRC_DIR!\buildIF "!SEVENZIP_CMD_OPTIONS!" == "" (SET SEVENZIP_CMD_OPTIONS=a -r -mx9 )FOR /F "delims=" %%a IN ('!CYGWIN_DIR!/bin/cygpath -p -u !SEVENZIP_CMD!') DO @set __SEVENZIP_CMD=%%aIF "!arg[0]!" == "" GOTO usage IF NOT EXIST "!PROJECT_SRC_DIR!" (ECHO.CALL :exitB "ERROR: Source directory !PROJECT_SRC_DIR! does not exist or does not contain the !BUILD_PROJECT! sources. Aborting."GOTO :eof )IF "!VS_VERSION!" == "2019" (SET VISUAL_STUDIO_VC=!VISUAL_STUDIO_VC!\Auxiliary\Buildpushd "!VISUAL_STUDIO_VC!\..\..\..\Common7\Tools\"call "!VISUAL_STUDIO_VC!\..\..\..\Common7\Tools\vsdevcmd.bat" -clean_envpopd )IF NOT EXIST "!VISUAL_STUDIO_VC!\vcvarsall.bat" (ECHO.CALL :exitB "ERROR: !VISUAL_STUDIO_VC!\vcvarsall.bat does not exist. Aborting."GOTO :eof )IF "!DATE_CMD_OPTIONS!" == "" (SET DATE_CMD_OPTIONS=%%d %%b %%Y )SET argC=-1 FOR %%x in (%*) DO SET /A argC+=1if /i "!arg[0]!" == "build" (if !argC! == 2 (if /i "!arg[1]!" == "all" (echo.echo You are about to build all permutations [x86^|x64] [static^|shared] [debug^|release]echo.timeout /t 5call :buildallgoto :eof) else (goto usage)) else if !argC! == 4 (call :callArch !arg[1]! !arg[2]! !arg[3]!goto :eof) else (goto usage)) else if /i "!arg[0]!" == "package" (if !argC! == 2 (if /i "!arg[1]!" == "all" (echo.echo You are about to package all permutations [x86^|x64] [static^|shared] [debug^|release]echo.timeout /t 5call :createPackagegoto :eof) else (goto usage)) else if !argC! == 3 (echo.echo This feature is currently unsupported. Only "package all" is supported at this time.echo.goto usageREM set archGood=falseREM if /i "!arg[1]!" == "x86" set archGood=trueREM if /i "!arg[1]!" == "x64" set archGood=trueREM if /i "!archGood!" == "true" (REM call :createPackage !arg[0]! !arg[1]!REM goto :eofREM ) else (REM goto usageREM )) else (goto usage)) else if /i "!arg[0]!" == "patch" (call :patch !PROJECT_VERSION! ) else if /i "!arg[0]!" == "unpatch" (call :unpatch !PROJECT_VERSION! ) else if !argC! == 3 (call :callArch !arg[0]! !arg[1]! !arg[2]!GOTO :eof ) else (GOTO usage )ENDLOCAL GOTO :eofrem ======================================================================================================== :printConfiguration SETLOCAL EnableExtensions EnableDelayedExpansion SET PATH=!CYGWIN_DIR!\bin;!CYGWIN_DIR!\usr\bin;!PATH!echo. echo PATH: !PATH! echo.echo VS_VERSION: !VS_VERSION! echo VISUAL_STUDIO_VC: !VISUAL_STUDIO_VC! echo CYGWIN_DIR: !CYGWIN_DIR! echo. bash -c "echo -n \" SEVENZIP_CMD: \" & which !__SEVENZIP_CMD!" echo SEVENZIP_CMD_OPTIONS: !SEVENZIP_CMD_OPTIONS! bash -c "echo -n \" MD5SUM_CMD: \" & which !MD5SUM_CMD!" bash -c "echo -n \" DATE_CMD: \" & which !DATE_CMD!" bash -c "echo -n \" PATCH_CMD: \" & which !PATCH_CMD!" echo. echo BUILD_PROJECT: !BUILD_PROJECT! echo PROJECT_VERSION: !PROJECT_VERSION! echo PROJECT_SRC_DIR: !PROJECT_SRC_DIR! echo PROJECT_BUILD_DIR: !PROJECT_BUILD_DIR! echo PROJECT_INSTALL_DIR: !PROJECT_INSTALL_DIR! ENDLOCAL goto :eofrem ========================================================================================================:callArch set archGood=false if /i "%1" == "x86" set archGood=true if /i "%1" == "x64" set archGood=true if /i "!archGood!" == "true" (set linkGood=falseif /i "%2"=="static" set linkGood=trueif /i "%2"=="shared" set linkGood=trueif /i "!linkGood!" == "true" (set buildGood=falseif /i "%3" == "debug" set buildGood=trueif /i "%3" == "release" set buildGood=trueif /i "!buildGood!" == "true" (call :build %1 %2 %3goto :eof))) goto usage goto :eofrem ========================================================================================================:usage call :printConfiguration ECHO: ECHO Error in script usage. The correct usage is: ECHO: ECHO !scriptName! [patch^|unpatch] - apply/remove patches to the sources ECHO !scriptName! build [all^|x86^|x64] ^<[static^|shared] [debug^|release]^> - builds all or specific permutations ECHO !scriptName! package [all^|x86^|x64] ^<[static^|shared]^> - creates a package file ECHO: GOTO :eofrem ========================================================================================================:unpatch rem remove patches from the sources call :patch %1 unpatch goto :eof:patch rem patch sources :: :: To create a patch for mkdef.pl: :: $ diff -u "F:\openssl-1.0.1e-orig\util\mk1mf.pl" "F:\openssl-1.0.1e\util\mk1mf.pl" > "%SSBUILDER_ROOT%\misc\openssl-1.0.1e-mk1mf.pl.patch" :: $ diff -u "F:\openssl-1.0.1e-orig\util\mkdef.pl" "F:\openssl-1.0.1e\util\mkdef.pl" > "%SSBUILDER_ROOT%\misc\openssl-1.0.1e-mkdef.pl.patch" :: $ diff -u "F:\openssl-1.0.1e-orig\util\pl\VC-32.pl" "F:\openssl-1.0.1e\util\pl\VC-32.pl" > "%SSBUILDER_ROOT%\misc\openssl-1.0.1e-VC-32.pl.patch" :: :: To apply the patch: :: cd into the unmodified openssl-x.x.x source directory :: patch [--dry-run] -p2 -i "D:\dev\ssbuilder\misc\openssl-1.0.1e-mkdef.pl.patch" :: patch [--dry-run] -p2 -i "D:\dev\ssbuilder\misc\openssl-1.0.1e-mkdef.pl.patch" :: SETLOCAL EnableExtensions EnableDelayedExpansionif /i "%2" == "unpatch" (SET EXTRA_TEXT=RemovingSET EXTRA_FLAGS=-R ) else (SET EXTRA_TEXT=Applying )SET PATH=!CYGWIN_DIR!\bin;!CYGWIN_DIR!\usr\bin;SET CYGWIN=nodosfilewarningECHO. ECHO !EXTRA_TEXT! patches to [!BUILD_PROJECT! v%~1] sources ECHO.pushd "!PROJECT_SRC_DIR!"call :applyPatch !BUILD_PROJECT!-%~1.patchpopdENDLOCAL goto :eof:applyPatch SET PATCH_FILE=%~dp0 SET PATCH_FILE=!PATCH_FILE!%1IF NOT EXIST "!PATCH_FILE!" (call :exitB "Patch: [!PATCH_FILE!] does not exist. Aborting.") ELSE (!DOS2UNIX_CMD! "!PATCH_FILE!"!PATCH_CMD! --binary !EXTRA_FLAGS! -N -p1 -i "!PATCH_FILE!") goto :eofrem ========================================================================================================:createPackagecall :printConfigurationecho: echo Packaging OpenSSL Library echo:SET DIST_DIR=!PROJECT_INSTALL_DIR!\!BUILD_PROJECT!-!PROJECT_VERSION!-vs!VS_VERSION!echo !DIST_DIR!@mkdir !DIST_DIR!\bin 2>nul @mkdir !DIST_DIR!\bin64 2>nul @mkdir !DIST_DIR!\lib 2>nul @mkdir !DIST_DIR!\lib64 2>nul @mkdir !DIST_DIR!\include 2>nul @mkdir !DIST_DIR!\include64 2>nul @mkdir !DIST_DIR!\ssl 2>nul @mkdir !DIST_DIR!\logs 2>nulcall :packagetypeecho:ENDLOCAL @exit /B 0rem ========================================================================================================:: %1 library type (e.g. static) :packagetypeSET DST_DIST=!BUILD_PROJECT!-!PROJECT_VERSION!-vs!VS_VERSION! SET DST_DIST_DIR=!PROJECT_INSTALL_DIR!\!DST_DIST!for %%l in (static shared) do (for %%a in (x86 x64) do (if /i "%%a" == "x86" (SET BITS=32SET BITSTR=) else (SET BITS=64SET BITSTR=!BITS!SET PREFIX_WIN=!PREFIX_WIN!!BITS!)for %%b in (debug release) do (SET __ARCH=%%aSET __BUILD=%%bSET __LINK=%%lSET SRC_DIST_DIR=!PROJECT_INSTALL_DIR!\!BUILD_PROJECT!-!__ARCH!-!__LINK!-!__BUILD!-vs!VS_VERSION!echo [copy] !SRC_DIST_DIR! =^> !DST_DIST_DIR!if exist "!SRC_DIST_DIR!" (xcopy /Q /Y !SRC_DIST_DIR!\bin\*.dll !DST_DIST_DIR!\bin!BITSTR!\xcopy /Q /Y !SRC_DIST_DIR!\bin\*.lib !DST_DIST_DIR!\bin!BITSTR!\xcopy /Q /Y !SRC_DIST_DIR!\bin\*.pdb !DST_DIST_DIR!\bin!BITSTR!\xcopy /Q /Y !SRC_DIST_DIR!\bin\*.exe !DST_DIST_DIR!\bin!BITSTR!\xcopy /Q /Y !SRC_DIST_DIR!\lib\*.lib !DST_DIST_DIR!\lib!BITSTR!\xcopy /Q /Y !SRC_DIST_DIR!\lib\*.pdb !DST_DIST_DIR!\lib!BITSTR!\xcopy /Q /Y /E /I !SRC_DIST_DIR!\include !DST_DIST_DIR!\include!BITSTR!xcopy /Q /Y /E /I !SRC_DIST_DIR!\ssl !DST_DIST_DIR!\sslxcopy /Q /Y /E /I !SRC_DIST_DIR!\html !DST_DIST_DIR!\htmlxcopy /Q /Y /E /I !SRC_DIST_DIR!\logs !DST_DIST_DIR!\logs))) )echo Copied all files for: !BUILD_PROJECT! v!PROJECT_VERSION!set README=!DST_DIST_DIR!\readme.precompiled.txt echo !README!pushd !PROJECT_INSTALL_DIR!SETLOCAL EnableExtensions EnableDelayedExpansionSET PATH=!CYGWIN_DIR!\bin;!CYGWIN_DIR!\usr\bin;!PATH!echo. > !README!bash -c "!DATE_CMD! +\"!DATE_CMD_OPTIONS!\"" >> !README!echo ====================================================================================================================== >> !README! echo url: http://www.npcglib.org/~stathis/blog/precompiled-openssl >> !README! echo ====================================================================================================================== >> !README!echo These are custom pre-built OpenSSL Libraries v!PROJECT_VERSION! (http://www.openssl.org). >> !README!echo They are compiled with Cygwin/MSVC for 32/64-bit Windows, using Visual Studio !VS_VERSION!. >> !README!echo. >> !README!echo Please note that the OpenSSL Project (http://www.openssl.org) is the only official source of OpenSSL. >> !README!echo These builds are created for my own personal use and therefore you are utilizing them at your own risk. >> !README!echo My builds are unsupported and not endorsed by The OpenSSL Project. >> !README!echo. >> !README!echo I build these in the context of my own work and spare time, >> !README!echo I do NOT charge any money, I do NOT make any money ... and NO I do NOT accept any donations^^! >> !README!echo If you really like OpenSSL, if it has helped you or your company in any way, >> !README!echo or you are feeling like giving back anyway, then please >> !README!echo donate directly to the OpenSSL Project: https://www.openssl.org/support/donations.html >> !README!echo The developers and countless contributors deserve it^^! >> !README!echo. >> !README!echo ------------------------------------------------------------------------------ >> !README!echo 32-bit OpenSSL Libraries [shared] [runtime: dynamic (/MD)]]>> !README!echo ------------------------------------------------------------------------------ >> !README!echo release runtime dlls: bin\libcryptoMD.dll bin\libsslMD.dll >> !README!echo release import libs: lib\libcryptoMD.lib lib\libsslMD.lib >> !README! echo debug runtime dlls: bin\libcryptoMDd.dll bin\libsslMDd.dll >> !README!echo debug import libs: lib\libcryptoMDd.lib lib\libsslMDd.lib >> !README!echo. >> !README!echo ------------------------------------------------------------------------------ >> !README!echo 32-bit OpenSSL Libraries [static] [runtime: static (/MT)]]>> !README!echo ------------------------------------------------------------------------------ >> !README!echo release libs: lib\libcryptoMT.lib lib\libsslMT.lib >> !README! echo debug libs: lib\libcryptoMTd.lib lib\libsslMTd.lib >> !README! echo. >> !README!echo ------------------------------------------------------------------------------ >> !README!echo 64-bit OpenSSL Libraries [shared] [runtime: dynamic (/MD)]]>> !README!echo ------------------------------------------------------------------------------ >> !README!echo release runtime dlls: bin64\libcryptoMD.dll bin64\libsslMD.dll >> !README!echo release import libs: lib64\libcryptoMD.lib lib64\libsslMD.lib >> !README! echo debug runtime dlls: bin64\libcryptoMDd.dll bin64\libsslMDd.dll >> !README!echo debug import libs: lib64\libcryptoMDd.lib lib64\libsslMDd.lib >> !README!echo. >> !README!echo ------------------------------------------------------------------------------ >> !README!echo 64-bit OpenSSL Libraries [static] [runtime: static (/MT)]]>> !README!echo ------------------------------------------------------------------------------ >> !README!echo release libs: lib64\libcryptoMT.lib lib64\libsslMT.lib >> !README! echo debug libs: lib64\libcryptoMTd.lib lib64\libsslMTd.lib >> !README! echo. >> !README!echo ====================================================================================================================== >> !README!echo. >> !README!echo If you have any comments or problems send me an email at: >> !README!echo stathis ^<stathis@npcglib.org^> >> !README!bash -c "cp -f \"!PROJECT_SRC_DIR!\AUTHORS\" \"!DST_DIST_DIR!\AUTHORS.txt\""bash -c "cp -f \"!PROJECT_SRC_DIR!\ACKNOWLEDGEMENTS\" \"!DST_DIST_DIR!\ACKNOWLEDGEMENTS.txt\""bash -c "cp -f \"!PROJECT_SRC_DIR!\CHANGES\" \"!DST_DIST_DIR!\CHANGES.txt\""bash -c "cp -f \"!PROJECT_SRC_DIR!\CONTRIBUTING\" \"!DST_DIST_DIR!\CONTRIBUTING.txt\""bash -c "cp -f \"!PROJECT_SRC_DIR!\README\" \"!DST_DIST_DIR!\README.txt\""bash -c "cp -f \"!PROJECT_SRC_DIR!\README.ECC\" \"!DST_DIST_DIR!\README.ECC.txt\""bash -c "cp -f \"!PROJECT_SRC_DIR!\FAQ\" \"!DST_DIST_DIR!\FAQ.txt\""bash -c "cp -f \"!PROJECT_SRC_DIR!\NEWS\" \"!DST_DIST_DIR!\NEWS.txt\""bash -c "cp -f \"!PROJECT_SRC_DIR!\NOTES.WIN\" \"!DST_DIST_DIR!\NOTES.WIN.txt\""bash -c "cp -f \"!PROJECT_SRC_DIR!\LICENSE\" \"!DST_DIST_DIR!\LICENSE.txt\""bash -c "cp -f \"!PROJECT_SRC_DIR!\FAQ\" \"!DST_DIST_DIR!\FAQ.txt\""set __FILENAME=!DST_DIST!set COMPRESSED_FILE=!__FILENAME!.7zecho.echo Packaging !BUILD_PROJECT! Library [v!PROJECT_VERSION!]echo ----------------------------------------------------------------------------echo [ Build in: !PROJECT_BUILD_DIR!] echo [ Installation: !PROJECT_INSTALL_DIR!] echo [ Packaging: !PROJECT_INSTALL_DIR!]echo [ Compressed: !COMPRESSED_FILE!]echo [ Readme: !README!]echo ----------------------------------------------------------------------------echo.echo Compressing with: !__SEVENZIP_CMD! !SEVENZIP_CMD_OPTIONS! !COMPRESSED_FILE! !DST_DIST!bash -c "!__SEVENZIP_CMD! !SEVENZIP_CMD_OPTIONS! !COMPRESSED_FILE! !DST_DIST!" echo Compressing in: !COMPRESSED_FILE!IF EXIST !COMPRESSED_FILE! (for %%I in (!COMPRESSED_FILE!) do (SET /A _fsize=%%~zI / 1024 / 1024)!MD5SUM_CMD! !COMPRESSED_FILE! 1> !__FILENAME!.md5echo Generated md5sum !__FILENAME!.md5 [!_fsize!MB])ENDLOCALpopdgoto :eofrem ========================================================================================================:buildallfor %%a in (x86 x64) do (for %%l in (shared static) do (for %%b in (debug release) do (call :build %%a %%l %%b)) )goto :eofrem ========================================================================================================:: call :build <x86|x64> <static|shared> <debug|release> :build SET __ARCH=%~1 SET __LINK=%~2 SET __BUILD=%~3if /i "!__ARCH!" == "x86" (SET BITS=32SET BIT_STR= ) else (SET BITS=64SET BIT_STR=64 )echo: echo Building OpenSSL Library [!__ARCH!] [!__LINK!] [!__BUILD!] echo:SETLOCAL EnableExtensions EnableDelayedExpansionIF "!VS_VERSION!" == "2019" (pushd "!VISUAL_STUDIO_VC!\..\..\..\Common7\Tools\"call "!VISUAL_STUDIO_VC!\..\..\..\Common7\Tools\vsdevcmd.bat" -clean_envpopd)call "!VISUAL_STUDIO_VC!\vcvarsall.bat" !__ARCH!rem Place the linker and compiler of Visual Studio infront of any other binaries when searchingrem SET PATH=!PATH!;!CYGWIN_DIR!\bin;!CYGWIN_DIR!\usr\bin;call :printConfigurationcall :buildtype !__ARCH! !__LINK! !__BUILD!ENDLOCAL goto :eofrem ========================================================================================================:: call :build <x86|x64> <static|shared> <debug|release> :buildtype SET __ARCH=%~1 SET __LINK=%~2 SET __BUILD=%~3SET CYGWIN=nodosfilewarningif /i "!__ARCH!" == "x86" (SET BITS=32SET BIT_STR= ) else (SET BITS=64SET BIT_STR=64 )IF NOT EXIST "!PROJECT_BUILD_DIR!" (mkdir "!PROJECT_BUILD_DIR!" )SET RUNTIME_SUFFIX= if /i "!__LINK!" == "shared" (SET RUNTIME_SUFFIX=MD )if /i "!__LINK!" == "static" (SET RUNTIME_SUFFIX=MT )SET LIBSUFFIX= if /i "!__BUILD!" == "debug" (SET LIBSUFFIX=d )SET RUNTIME_FULL_SUFFIX=!RUNTIME_SUFFIX!!LIBSUFFIX!SET DLL_STR= if /i "!__LINK!" == "shared" (SET DLL_STR=dll )SET INSTALL_DIR=!PROJECT_INSTALL_DIR!\!BUILD_PROJECT!-!__ARCH!-!__LINK!-!__BUILD!-vs!VS_VERSION!SET B_CMD=perl !PROJECT_SRC_DIR!\Configure SET COMMON_OPTIONS=enable-static-engine --prefix=!INSTALL_DIR! --openssldir=./ssl SET MODE=VC-WINif /i "!__LINK!" == "shared" (SET COMMON_OPTIONS=!COMMON_OPTIONS! shared )if /i "!__LINK!" == "static" (SET COMMON_OPTIONS=!COMMON_OPTIONS! no-shared -static )if /i "!__BUILD!" == "debug" (SET MODE=!__BUILD!-!MODE! )if /i "!__ARCH!" == "x86" (SET MODE=!MODE!!BITS!SET COMMON_OPTIONS=!COMMON_OPTIONS! no-asm ) else (SET MODE=!MODE!!BITS!ASET COMMON_OPTIONS=!COMMON_OPTIONS! no-asm )SET BUILD_DIR=!PROJECT_BUILD_DIR!\!BUILD_PROJECT!-!__ARCH!-!__LINK!-!__BUILD!-vs!VS_VERSION!IF NOT EXIST "!BUILD_DIR!" (mkdir "!BUILD_DIR!" )SET CONFIG_LOG_FILE=!BUILD_DIR!\!BUILD_PROJECT!-!__ARCH!-!__LINK!-!__BUILD!-vs!VS_VERSION!.config.log SET BUILD_LOG_FILE=!BUILD_DIR!\!BUILD_PROJECT!-!__ARCH!-!__LINK!-!__BUILD!-vs!VS_VERSION!.build.log SET TEST_LOG_FILE=!BUILD_DIR!\!BUILD_PROJECT!-!__ARCH!-!__LINK!-!__BUILD!-vs!VS_VERSION!.test.log SET INSTALL_LOG_FILE=!BUILD_DIR!\!BUILD_PROJECT!-!__ARCH!-!__LINK!-!__BUILD!-vs!VS_VERSION!.install.logECHO. > !CONFIG_LOG_FILE!SET B_CMD=!B_CMD! !MODE! !COMMON_OPTIONS! echo Commands: !B_CMD!timeout /t 10rem pushd !PROJECT_SRC_DIR! pushd !BUILD_DIR! echo Configured with: !B_CMD! > !CONFIG_LOG_FILE! 2>&1 !B_CMD! >> !CONFIG_LOG_FILE! 2>&1SET MK_CMD=nmakeECHO. > !BUILD_LOG_FILE!!MK_CMD! > !BUILD_LOG_FILE! 2>&1 rem !MK_CMD! list-tests > !TEST_LOG_FILE! 2>&1 !MK_CMD! test >> !TEST_LOG_FILE! 2>&1IF NOT EXIST "!INSTALL_DIR!" (mkdir "!INSTALL_DIR!" )rem !MK_CMD! DESTDIR=!INSTALL_DIR! install >> !INSTALL_LOG_FILE! 2>&1 !MK_CMD! install_sw >> !INSTALL_LOG_FILE! 2>&1rem Install the OpenSSL configuration dir (./ssl) !MK_CMD! install_ssldirs >> !INSTALL_LOG_FILE! 2>&1rem Install the OpenSSL documentation dir (./html) !MK_CMD! install_html_docs >> !INSTALL_LOG_FILE! 2>&1IF NOT EXIST "!INSTALL_DIR!\logs" (mkdir "!INSTALL_DIR!\logs" )xcopy /Q /Y !CONFIG_LOG_FILE! !INSTALL_DIR!\logs\ >> !INSTALL_LOG_FILE! 2>&1 xcopy /Q /Y !BUILD_LOG_FILE! !INSTALL_DIR!\logs\ >> !INSTALL_LOG_FILE! 2>&1 xcopy /Q /Y !TEST_LOG_FILE! !INSTALL_DIR!\logs\ >> !INSTALL_LOG_FILE! 2>&1 xcopy /Q /Y !INSTALL_LOG_FILE! !INSTALL_DIR!\logs\ >> !INSTALL_LOG_FILE! 2>&1popdgoto :eofrem ========================================================================================================:toLower str -- converts uppercase character to lowercase :: -- str [in,out] - valref of string variable to be converted :$created 20060101 :$changed 20080219 :$categories StringManipulation :$source http://www.dostips.com if not defined %~1 EXIT /b for %%a in ("A=a" "B=b" "C=c" "D=d" "E=e" "F=f" "G=g" "H=h" "I=i""J=j" "K=k" "L=l" "M=m" "N=n" "O=o" "P=p" "Q=q" "R=r""S=s" "T=t" "U=u" "V=v" "W=w" "X=x" "Y=y" "Z=z" "??"?? "??) do (call set %~1=%%%~1:%%~a%% ) EXIT /brem ========================================================================================================:: %1 an error message :exitB echo: echo Error: %1 echo: echo Contact stathis@npcglib.org @exit /B 0總結
以上是生活随笔為你收集整理的bat脚本+vs2019编译openssl(x86 | x64) - (static | shared) - (debug | release)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 结构化异常捕获空指针异常
- 下一篇: CS起源pointermap找基址+工具