Last active
October 29, 2021 02:04
-
-
Save rampageX/dd7acd0aae6616e49f98c3a96e0c535f to your computer and use it in GitHub Desktop.
Revisions
-
rampageX renamed this gist
Oct 29, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
rampageX created this gist
Oct 29, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,108 @@ #!/bin/sh #Build Static Nginx aarch64 Binary PCRE_TAG=8.45 OPENSSL_TAG=3.0.0 ZLIB_TAG=1.2.11 LIBATOMIC_OPS_TAG=7.6.12 NGINX_TAG=1.21.3 STANDARD="c++17" base_dir=$(cd $(dirname $0) && pwd) install_dir="${base_dir}/aarch64_dev" include_dir="${install_dir}/include" lib_dir="${install_dir}/lib" result_dir="${base_dir}/aarch64_result" custom_flags_set() { CXXFLAGS="-std=${STANDARD}" CPPFLAGS="--static -static -I${include_dir}" LDFLAGS="--static -static -Wl,--no-as-needed -L${lib_dir} -lpthread -pthread" LD_LIBRARY_PATH="-L${lib_dir}" PKG_CONFIG_PATH="-L${lib_dir}/pkgconfig" } custom_flags_reset() { CXXFLAGS="-std=${STANDARD}" CPPFLAGS="" LDFLAGS="" } custom_flags_reset build_libs() { #zLib [ ! -e ${base_dir}/aarch64_dev/lib/libz.a ] && { [ ! -e ${base_dir}/zlib-${ZLIB_TAG} ] && curl -sSL "https://zlib.net/zlib-${ZLIB_TAG}.tar.gz" | tar zxvf - cd zlib-${ZLIB_TAG} custom_flags_set make clean CC=aarch64-linux-musl-gcc ./configure --prefix=${install_dir} --static make -j"$(nproc)" CXXFLAGS="${CXXFLAGS}" CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" make install cd .. } #libssl [ ! -e ${base_dir}/aarch64_dev/lib/libssl.a ] && { [ ! -e ${base_dir}/openssl-${OPENSSL_TAG} ] && curl -sSL "https://www.openssl.org/source/openssl-${OPENSSL_TAG}.tar.gz" | tar zxvf - cd openssl-${OPENSSL_TAG} custom_flags_set make clean ./Configure linux-aarch64 --cross-compile-prefix=aarch64-linux-musl- --prefix=${install_dir} threads no-shared no-dso no-comp CXXFLAGS="${CXXFLAGS}" CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" make -j$(nproc) make install_sw cd .. } #pcre [ ! -e ${base_dir}/aarch64_dev/lib/libpcre.a ] && { [ ! -e ${base_dir}/pcre-${PCRE_TAG} ] && curl -sSL "https://ftp.pcre.org/pub/pcre/pcre-${PCRE_TAG}.tar.gz" | tar zxvf - cd pcre-${PCRE_TAG} custom_flags_reset make clean ./configure --prefix=${install_dir} --disable-shared --host=aarch64-linux-musl make -j$(nproc) make install cd .. } #libatomic_ops [ ! -e ${base_dir}/aarch64_dev/lib/libatomic_ops.a ] && { [ ! -e ${base_dir}/libatomic_ops-${LIBATOMIC_OPS_TAG} ] && curl -sSL "https://github.com/ivmai/libatomic_ops/releases/download/v${LIBATOMIC_OPS_TAG}/libatomic_ops-${LIBATOMIC_OPS_TAG}.tar.gz" | tar zxvf - cd libatomic_ops-${LIBATOMIC_OPS_TAG} custom_flags_set make clean CC=aarch64-linux-musl-gcc CXX=aarch64-linux-musl-g++ \ ./configure --prefix=${install_dir} --disable-shared --host=aarch64-linux-musl \ CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" make -j$(nproc) make install cd .. } } build_nginx() { [ ! -e ${base_dir}/nginx-${NGINX_TAG} ] && curl -sSL "http://nginx.org/download/nginx-${NGINX_TAG}.tar.gz" | tar zxvf - cd nginx-${NGINX_TAG} custom_flags_set make clean ./configure --prefix=/usr/local --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx_error.log --http-log-path=/var/log/nginx_access.log --pid-path=/run/nginx.pid --lock-path=/run/nginx.lock --with-openssl-opt="linux-aarch64 --cross-compile-prefix=aarch64-linux-musl-" --with-mail --with-mail_ssl_module --with-stream --with-stream_ssl_module --with-stream_realip_module --with-stream_ssl_preread_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-pcre-jit --with-libatomic --with-compat --with-file-aio --with-threads --with-poll_module --with-select_module --with-cc-opt="${CPPFLAGS}" --with-ld-opt="${LDFLAGS}" --add-module=../ngx_brotli --with-openssl=${base_dir}/openssl-${OPENSSL_TAG} [ $? -ne 0 ] && exit 1 make -j$(nproc) CC=aarch64-linux-musl-gcc CXX=aarch64-linux-musl-g++ AR=aarch64-linux-musl-ar CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" [ $? -ne 0 ] && exit 2 cd objs aarch64-linux-musl-strip nginx ls -la file ./nginx [ ! -e $result_dir ] && mkdir -p $result_dir cp ./nginx ${result_dir}/nginx_static_${NGINX_TAG} } [ -n "$1" -a "$1" = "reset" ] && { build_libs } build_nginx