Last active
October 10, 2021 18:37
-
-
Save guischulz/9599a7116435517a3073c32520a867f2 to your computer and use it in GitHub Desktop.
Build Apache HTTP server Windows 64-bit binaries from GitHub sources
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@setlocal | |
REM start with a clean path | |
set PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem | |
REM --- MSVC C++ build tools --- | |
rem Win64Build | |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" | |
rem Win32Build | |
rem call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat" | |
@echo on | |
REM --- Build helper utilities --- | |
set _git_home_=D:\work\git-2.33.0.2 | |
set _cmake_home_=D:\work\cmake-3.21.3-windows-x86_64 | |
set _nasm_home_=D:\work\nasm-2.15.05 | |
set _perl_home_=C:\Strawberry\perl | |
rem AWK for Windows from https://github.com/danfuzz/one-true-awk/ | |
set _awk_home_=D:\work\one-true-awk\versions\2010-05-23 | |
set "PATH=%_git_home_%\cmd;%_cmake_home_%\bin;%_nasm_home_%;%_perl_home_%\bin;%_awk_home_%;%PATH%" | |
:awk | |
cd /d "%_awk_home_%" | |
if not exist "%_awk_home_%\awk.exe" call "%_awk_home_%\buildwin.bat" | |
REM --- Third party git source directories --- | |
REM !!ATTENTION!! create corresponding directory junctions in "%HTTPD_DIR%\srclib\" with mklink /j | |
set THIRDPARTY_BASE=D:\work\apache_build\3rdparty | |
set ZLIB_DIR=%THIRDPARTY_BASE%\zlib | |
set OPENSSL_DIR=%THIRDPARTY_BASE%\openssl | |
set PCRE_DIR=%THIRDPARTY_BASE%\pcre | |
set LIBXML2_DIR=%THIRDPARTY_BASE%\libxml2 | |
set LIBEXPAT_DIR=%THIRDPARTY_BASE%\libexpat | |
set BROTLI_DIR=%THIRDPARTY_BASE%\brotli | |
set JANSSON_DIR=%THIRDPARTY_BASE%\jansson | |
set CURL_DIR=%THIRDPARTY_BASE%\curl | |
set LUA_DIR=%THIRDPARTY_BASE%\lua | |
set NGHTTP2_DIR=%THIRDPARTY_BASE%\nghttp2 | |
set APR_DIR=%THIRDPARTY_BASE%\apr | |
set APR_ICONV_DIR=%THIRDPARTY_BASE%\apr-iconv | |
set APR_UTIL_DIR=%THIRDPARTY_BASE%\apr-util | |
REM --- Apache httpd source directory --- | |
set HTTPD_DIR=D:\work\apache_build\httpd | |
set INSTALL_DIR=c:\Apache24 | |
:zlib | |
REM === Zlib === | |
rem https://github.com/madler/zlib.git | |
cd /d "%ZLIB_DIR%" | |
git clean -xfd && git fetch --tags | |
git checkout tags/v1.2.11 | |
rem Win64Build | |
nmake -f win32/Makefile.msc AS=ml64 LOC="-DASMV -DASMINF -I." OBJA="inffasx64.obj gvmat64.obj inffas8664.obj" | |
rem Win32Build | |
rem nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" OBJA="inffas32.obj match686.obj" | |
copy zlib.lib zlib1.lib | |
:openssl | |
REM === OpenSSL === | |
rem https://github.com/openssl/openssl.git | |
cd /d "%OPENSSL_DIR%" | |
git clean -xfd && git fetch --tags | |
git checkout tags/OpenSSL_1_1_1l | |
rem Win64Build | |
perl Configure no-comp VC-WIN64A | |
rem Win32Build | |
rem perl Configure no-comp VC-WIN32 | |
nmake -f makefile | |
:pcre | |
REM === PCRE === | |
rem https://github.com/jwilk-mirrors/pcre.git | |
cd /d "%PCRE_DIR%" | |
git clean -xfd && git fetch --tags | |
git checkout tags/pcre-8.45 | |
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=True -DPCRE_SUPPORT_JIT=ON -DPCRE_SUPPORT_UTF=ON -DPCRE_REBUILD_CHARTABLES=ON -DZLIB_LIBRARY=%ZLIB_DIR%\zlib1.lib -DZLIB_INCLUDE_DIR=%ZLIB_DIR% | |
nmake | |
:libxml2 | |
REM === LibXML2=== | |
rem https://github.com/GNOME/libxml2.git | |
cd /d "%LIBXML2_DIR%" | |
git clean -xfd && git fetch --tags | |
git checkout tags/v2.9.12 | |
cd "%LIBXML2_DIR%\win32" | |
cscript configure.js zlib=no iconv=no compiler=msvc debug=no | |
nmake -f Makefile.msvc | |
:expat | |
REM === Expat === | |
rem https://github.com/libexpat/libexpat.git | |
cd /d "%LIBEXPAT_DIR%" | |
git clean -xfd && git fetch --tags | |
git checkout tags/R_2_4_1 | |
cd "%LIBEXPAT_DIR%\expat" | |
cmake -G "NMake Makefiles" -DBUILD_tools=Off -DBUILD_examples=Off -DBUILD_tests=Off -DBUILD_shared=Off -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=False | |
nmake | |
:brotli | |
rem === Brotli === | |
rem https://github.com/google/brotli.git | |
cd /d "%BROTLI_DIR%" | |
git clean -xfd && git fetch --tags | |
git checkout tags/1.0.9 | |
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DBROTLI_BUNDLED_MODE=ON | |
nmake | |
copy /y brotlicommon-static.lib brotlicommon.lib | |
copy /y brotlienc-static.lib brotlienc.lib | |
:jansson | |
REM === Jansson === | |
rem https://github.com/akheron/jansson.git | |
cd /d "%JANSSON_DIR%" | |
git clean -xfd && git fetch --tags | |
git checkout tags/v2.14 | |
cmake -G "NMake Makefiles" -DJANSSON_BUILD_DOCS=OFF -DJANSSON_EXAMPLES=OFF -DJANSSON_BUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release | |
nmake | |
:curl | |
REM === cURL === | |
rem https://github.com/curl/curl.git | |
cd /d "%CURL_DIR%" | |
git clean -xfd && git fetch --tags | |
git checkout tags/curl-7_79_1 | |
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DZLIB_LIBRARY=%ZLIB_DIR%\zlib1.lib -DZLIB_INCLUDE_DIR=%ZLIB_DIR% -DCMAKE_USE_SCHANNEL=ON -DBUILD_SHARED_LIBS=ON -DBUILD_CURL_EXE=OFF | |
nmake | |
copy "%CURL_DIR%\lib\libcurl_imp.lib" "%CURL_DIR%\lib\libcurl.lib" | |
:lua | |
REM === Lua === | |
rem https://github.com/lua/lua.git | |
rem the lua git source directory must be linked to "%HTTPD_DIR%\srclib\src\lua", not just "lua" | |
cd /d "%LUA_DIR%" | |
git clean -xfd && git fetch --tags | |
git checkout tags/v5.3.6 | |
cl /MD /O2 /c /DLUA_BUILD_AS_DLL /DLUA_COMPAT_5_2 /DLUA_COMPAT_5_1 *.c | |
link /MANIFEST /DLL /IMPLIB:lua51.lib /OUT:lua53.dll *.obj | |
mt -manifest lua53.dll.manifest -outputresource:lua53.dll;2 | |
:nghttp2 | |
REM === nghttp2 === | |
rem https://github.com/nghttp2/nghttp2.git | |
cd /d "%NGHTTP2_DIR%" | |
git clean -xfd && git fetch --tags | |
git checkout tags/v1.44.0 | |
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DZLIB_LIBRARY=%ZLIB_DIR%\zlib1.lib -DZLIB_INCLUDE_DIR=%ZLIB_DIR% -DOPENSSL_ROOT_DIR=%OPENSSL_DIR% -DLIBXML2_LIBRARY=%LIBXML2_DIR%\win32\bin\libxml2.lib -DLIBXML2_INCLUDE_DIR=%LIBXML2_DIR% -DJANSSON_LIBRARY=%JANSSON_DIR%\lib\jansson.lib -DJANSSON_INCLUDE_DIR=%JANSSON_DIR%\include -DENABLE_LIB_ONLY=ON | |
nmake | |
md "%NGHTTP2_DIR%\lib\MSVC_obj" | |
copy "%NGHTTP2_DIR%\lib\nghttp2.lib" "%NGHTTP2_DIR%\lib\MSVC_obj" | |
copy "%NGHTTP2_DIR%\lib\nghttp2.dll" "%NGHTTP2_DIR%\lib\MSVC_obj" | |
echo.>"%NGHTTP2_DIR%\lib\MSVC_obj\nghttp2.pdb" | |
:apr | |
REM === Apr === | |
rem https://github.com/apache/apr.git | |
rem https://github.com/apache/apr-iconv.git | |
rem https://github.com/apache/apr-util.git | |
cd /d "%APR_DIR%" | |
git clean -xfd && git fetch --tags | |
git checkout tags/1.7.0 | |
cd /d "%APR_ICONV_DIR%" | |
git clean -xfd && git fetch --tags | |
git checkout tags/1.2.2 | |
cd /d "%APR_UTIL_DIR%" | |
git clean -xfd && git fetch --tags | |
git checkout tags/1.6.1 | |
git checkout -- . | |
rem use external libexpat as xml parser | |
set expat_dir=%APR_UTIL_DIR%\xml\expat | |
xcopy /e/s/v/i/y "%LIBEXPAT_DIR%\expat" "%expat_dir%" | |
echo.> "%expat_dir%\lib\xml.mak" | |
md "%expat_dir%\lib\LibR" | |
copy "%expat_dir%\libexpatMD.lib" "%expat_dir%\lib\LibR\xml.lib" | |
echo.>"%expat_dir%\lib\LibR\xml.pdb" | |
rem compile with crypto and openssl enabled | |
copy "%APR_UTIL_DIR%\include\apu.hw" "%APR_UTIL_DIR%\include\apu.hw.tmp" | |
awk "$2 ~ /^APU_HAVE_(CRYPTO)|(OPENSSL)$/ {$3=\"1\"}; 1" "%APR_UTIL_DIR%\include\apu.hw.tmp" > "%APR_UTIL_DIR%\include\apu.hw" | |
:httpd | |
REM === Apache HTTP Server === | |
rem https://github.com/apache/httpd.git | |
cd /d %HTTPD_DIR% | |
git clean -xfd && git fetch --tags | |
git checkout tags/2.4.51 | |
rem Win64Build | |
set CL=/D_WIN32_WINNT#0x0600 /D "WIN64" /D "_WIN64" | |
set _LINK_=/MANIFEST /MACHINE:x64 | |
rem Win32Build | |
rem set CL=/D_WIN32_WINNT#0x0600 | |
rem set _LINK_=/MANIFEST /MACHINE:x86 | |
nmake -f Makefile.win XML_PARSER="%LIBEXPAT_DIR%\expat\libexpatMD" XML_OPTIONS="/D XML_STATIC" _buildr | |
:post_httpd | |
REM --- mod_session_crypto --- | |
rem not build with the httpd default Makefile.win | |
cd /d "%APR_UTIL_DIR%\crypto" | |
nmake -f apr_crypto_openssl.mak _HAVE_OSSL110=1 CFG="apr_crypto_openssl - Win32 Release" RECURSE=0 | |
cd /d "%HTTPD_DIR%\modules\session" | |
nmake -f "mod_session_crypto.mak" CFG="mod_session_crypto - Win32 Release" RECURSE=0 | |
:install | |
cd /d %HTTPD_DIR% | |
nmake -f Makefile.win INSTDIR="%INSTALL_DIR%" installr | |
del /s "%INSTALL_DIR%\*.pdb" | |
rem copy additional files | |
copy /y "%CURL_DIR%\lib\libcurl.dll" "%INSTALL_DIR%\bin" | |
copy /y "%JANSSON_DIR%\bin\jansson.dll" "%INSTALL_DIR%\bin" | |
copy /y "%LUA_DIR%\lua53.dll" "%INSTALL_DIR%\bin" | |
copy /y "%ZLIB_DIR%\zlib.lib" "%INSTALL_DIR%\lib" | |
copy /y "%ZLIB_DIR%\zconf.h" "%INSTALL_DIR%\include" | |
copy /y "%ZLIB_DIR%\zlib.h" "%INSTALL_DIR%\include" | |
copy /y "%HTTPD_DIR%\modules\proxy\Release\mod_proxy.lib" "%INSTALL_DIR%\lib" | |
copy /y "%APR_UTIL_DIR%\crypto\Release\apr_crypto_openssl-1.dll" "%INSTALL_DIR%\bin" | |
copy /y "%HTTPD_DIR%\modules\session\Release\mod_session_crypto.so" "%INSTALL_DIR%\modules" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment