diff --git a/_build.sh b/_build.sh index 040cd370e..791d7a95d 100755 --- a/_build.sh +++ b/_build.sh @@ -208,13 +208,13 @@ my_time='time' [ -n "${CW_NOTIME:-}" ] && my_time= # Detect host OS -export _OS +export _HOSTOS case "$(uname)" in - *_NT*) _OS='win';; - Linux*) _OS='linux';; - Darwin*) _OS='mac';; - *BSD) _OS='bsd';; - *) _OS='unrecognized';; + *_NT*) _HOSTOS='win';; + Linux*) _HOSTOS='linux';; + Darwin*) _HOSTOS='mac';; + *BSD) _HOSTOS='bsd';; + *) _HOSTOS='unrecognized';; esac # Form suffix for alternate builds @@ -238,7 +238,7 @@ fi # `configure: WARNING: using cross tools not prefixed with host triplet` # Even with `_CCPREFIX` provided. # https://clang.llvm.org/docs/CrossCompilation.html -case "${_OS}" in +case "${_HOSTOS}" in win) _BUILD_HOST="${unamem}-pc-mingw32";; linux) _BUILD_HOST="${unamem}-pc-linux";; bsd) _BUILD_HOST="${unamem}-pc-bsd";; @@ -271,7 +271,7 @@ export _REVSUFFIX="${_REV}"; [ -z "${_REVSUFFIX}" ] || _REVSUFFIX="_${_REVSUFFIX . ./_dl.sh # Install required component -if [ "${_OS}" = 'mac' ]; then +if [ "${_HOSTOS}" = 'mac' ]; then if [ ! -d .venv ]; then python3 -m venv .venv PIP_PROGRESS_BAR=off .venv/bin/python3 -m pip --disable-pip-version-check --no-cache-dir --require-virtualenv install pefile @@ -433,7 +433,7 @@ build_single_target() { # Reset for each target PATH="${_ori_path}" - if [ "${_OS}" = 'win' ]; then + if [ "${_HOSTOS}" = 'win' ]; then export PATH if [ "${_TOOLCHAIN}" = 'llvm-mingw' ]; then PATH="${CW_LLVM_MINGW_PATH}/bin:${_ori_path}" @@ -448,7 +448,7 @@ build_single_target() { else if [ "${_TOOLCHAIN}" = 'llvm-mingw' ]; then export PATH="${CW_LLVM_MINGW_PATH}/bin:${_ori_path}" - elif [ "${_CC}" = 'llvm' ] && [ "${_OS}" = 'mac' ]; then + elif [ "${_CC}" = 'llvm' ] && [ "${_HOSTOS}" = 'mac' ]; then _MAC_LLVM_PATH='/usr/local/opt/llvm/bin' export PATH="${_MAC_LLVM_PATH}:${_ori_path}" fi @@ -459,16 +459,16 @@ build_single_target() { _CCPREFIX="${_TRIPLET}-" # mingw-w64 sysroots if [ "${_TOOLCHAIN}" != 'llvm-mingw' ]; then - if [ "${_OS}" = 'mac' ]; then + if [ "${_HOSTOS}" = 'mac' ]; then _SYSROOT="/usr/local/opt/mingw-w64/toolchain-${_machine}" - elif [ "${_OS}" = 'linux' ]; then + elif [ "${_HOSTOS}" = 'linux' ]; then _SYSROOT="/usr/${_TRIPLET}" fi fi _WINE='echo' - if [ "${_OS}" = 'linux' ] || \ - [ "${_OS}" = 'bsd' ]; then + if [ "${_HOSTOS}" = 'linux' ] || \ + [ "${_HOSTOS}" = 'bsd' ]; then # Run x64 targets on same CPU: if [ "${_CPU}" = 'x64' ] && \ [ "${unamem}" = 'x86_64' ]; then @@ -478,13 +478,13 @@ build_single_target() { _WINE='wine' fi fi - elif [ "${_OS}" = 'mac' ]; then + elif [ "${_HOSTOS}" = 'mac' ]; then # Run x64 targets on Intel and ARM (requires Wine 6.0.1): if [ "${_CPU}" = 'x64' ] && \ command -v wine64 >/dev/null 2>&1; then _WINE='wine64' fi - elif [ "${_OS}" = 'win' ]; then + elif [ "${_HOSTOS}" = 'win' ]; then # Skip ARM64 target on 64-bit Intel, run all targets on ARM64: if [ "${unamem}" = 'x86_64' ] && \ [ "${_CPU}" != 'a64' ]; then @@ -545,7 +545,7 @@ build_single_target() { [ "${_CPU}" = 'x64' ] && _RCFLAGS_GLOBAL="${_RCFLAGS_GLOBAL} --target=pe-x86-64" [ "${_CPU}" = 'a64' ] && _RCFLAGS_GLOBAL="${_RCFLAGS_GLOBAL} --target=${_TRIPLET}" # llvm-windres supports triplets here. https://github.com/llvm/llvm-project/blob/main/llvm/tools/llvm-rc/llvm-rc.cpp - if [ "${_OS}" = 'win' ]; then + if [ "${_HOSTOS}" = 'win' ]; then # '-G MSYS Makefiles' command-line option is problematic due to spaces # and unwanted escaping/splitting. Pass it via envvar instead. export CMAKE_GENERATOR='MSYS Makefiles' @@ -577,7 +577,7 @@ build_single_target() { _CC_GLOBAL="${_CC_GLOBAL} --sysroot=${_SYSROOT}" _CONFIGURE_GLOBAL="${_CONFIGURE_GLOBAL} --with-sysroot=${_SYSROOT}" fi - if [ "${_OS}" = 'linux' ]; then + if [ "${_HOSTOS}" = 'linux' ]; then # We used to pass this via CFLAGS for CMake to make it detect llvm/clang, # so we need to pass this via CMAKE_C_FLAGS, though meant for the linker. if [ "${_TOOLCHAIN}" = 'llvm-mingw' ]; then @@ -634,7 +634,7 @@ build_single_target() { _BINUTILS_PREFIX='llvm-' _BINUTILS_SUFFIX="${_CCSUFFIX}" _LDFLAGS_GLOBAL="${_LDFLAGS_GLOBAL} -fuse-ld=lld${_CCSUFFIX}" - if [ "${_OS}" = 'mac' ]; then + if [ "${_HOSTOS}" = 'mac' ]; then _RCFLAGS_GLOBAL="${_RCFLAGS_GLOBAL} -I${_SYSROOT}/${_TRIPLET}/include" fi fi @@ -698,7 +698,7 @@ build_single_target() { export RC="${_BINUTILS_PREFIX}windres${_BINUTILS_SUFFIX}" if [ "${_CC}" = 'llvm' ] && \ [ "${_TOOLCHAIN}" != 'llvm-mingw' ] && \ - [ "${_OS}" = 'linux' ] && \ + [ "${_HOSTOS}" = 'linux' ] && \ [ -n "${_BINUTILS_SUFFIX}" ]; then # FIXME: llvm-windres present, but unable to find its clang counterpart # when suffixed: @@ -734,7 +734,7 @@ build_single_target() { chmod +x "${AR_NORMALIZE}" fi - if [ "${_OS}" = 'mac' ]; then + if [ "${_HOSTOS}" = 'mac' ]; then if [ "${_TOOLCHAIN}" = 'llvm-mingw' ]; then _CMAKE_GLOBAL="${_CMAKE_GLOBAL} -DCMAKE_AR=${CW_LLVM_MINGW_PATH}/bin/${AR}" elif [ "${_CC}" = 'llvm' ]; then @@ -776,7 +776,7 @@ build_single_target() { mingwver="${mingwver} ${CW_LLVM_MINGW_VER_:-?}" versuffix="${versuffix_llvm_mingw}" else - case "${_OS}" in + case "${_HOSTOS}" in mac) mingwver="$(HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_FROM_API=1 brew info --json=v2 --formula mingw-w64 | jq --raw-output '.formulae[] | select(.name == "mingw-w64") | .versions.stable')";; linux) @@ -908,7 +908,7 @@ if [ "${_BRANCH#*x64*}" = "${_BRANCH}" ] && \ build_single_target x86 fi -case "${_OS}" in +case "${_HOSTOS}" in mac) rm -f -P "${SIGN_CODE_KEY}";; linux) [ -w "${SIGN_CODE_KEY}" ] && srm "${SIGN_CODE_KEY}";; esac diff --git a/_dl.sh b/_dl.sh index 578f42c30..4981f509a 100755 --- a/_dl.sh +++ b/_dl.sh @@ -527,7 +527,7 @@ echo "Build: REV(${_REVSUFFIX})" # Quit if any of the lines fail set -e -if [ "${_OS}" = 'mac' ]; then +if [ "${_HOSTOS}" = 'mac' ]; then tar() { gtar "$@"; } fi @@ -631,13 +631,13 @@ EOF if [ "${CW_LLVM_MINGW_DL:-}" = '1' ] && \ [ ! -d 'llvm-mingw' ]; then name=''; vers=''; hash=''; arch="$(uname -m)" - if [ "${_OS}-${arch}" = 'linux-x86_64' ]; then + if [ "${_HOSTOS}-${arch}" = 'linux-x86_64' ]; then name='llvm-mingw-linux-x86-64'; vers="${LLVM_MINGW_LINUX_X86_64_VER_}"; hash="${LLVM_MINGW_LINUX_X86_64_HASH}" - elif [ "${_OS}-${arch}" = 'linux-aarch64' ]; then + elif [ "${_HOSTOS}-${arch}" = 'linux-aarch64' ]; then name='llvm-mingw-linux-aarch64'; vers="${LLVM_MINGW_LINUX_AARCH64_VER_}"; hash="${LLVM_MINGW_LINUX_AARCH64_HASH}" - elif [ "${_OS}" = 'mac' ]; then + elif [ "${_HOSTOS}" = 'mac' ]; then name='llvm-mingw-mac'; vers="${LLVM_MINGW_MAC_VER_}"; hash="${LLVM_MINGW_MAC_HASH}" - elif [ "${_OS}" = 'win' ]; then + elif [ "${_HOSTOS}" = 'win' ]; then name='llvm-mingw-win'; vers="${LLVM_MINGW_WIN_VER_}"; hash="${LLVM_MINGW_WIN_HASH}" fi if [ -n "${name}" ]; then diff --git a/_pkg.sh b/_pkg.sh index 52dffb41e..3a278b149 100755 --- a/_pkg.sh +++ b/_pkg.sh @@ -8,7 +8,7 @@ set -o xtrace -o errexit -o nounset; [ -n "${BASH:-}${ZSH_NAME:-}" ] && set -o p cd "$(dirname "$0")" -if [ "${_OS}" = 'mac' ]; then +if [ "${_HOSTOS}" = 'mac' ]; then tar() { gtar "$@"; } fi @@ -53,11 +53,11 @@ create_pkg() { fi # Alter filename for non-release packages if [ "${_BRANCH#*main*}" != "${_BRANCH}" ]; then - if [ "${PUBLISH_PROD_FROM}" != "${_OS}" ]; then - _suf="${_suf}-built-on-${_OS}" + if [ "${PUBLISH_PROD_FROM}" != "${_HOSTOS}" ]; then + _suf="${_suf}-built-on-${_HOSTOS}" fi else - _suf="${_suf}-test-built-on-${_OS}" + _suf="${_suf}-test-built-on-${_HOSTOS}" fi _pkg="${_OUT}${_suf}${arch_ext}" @@ -66,7 +66,7 @@ create_pkg() { ( cd "${_DST}/.." - case "${_OS}" in + case "${_HOSTOS}" in win) find "${_BAS}" -exec attrib +A -R '{}' \; esac @@ -87,7 +87,7 @@ create_pkg() { rm -f "${_FLS}" # : bytes - case "${_OS}" in + case "${_HOSTOS}" in bsd|mac) TZ=UTC stat -f '%N: %z bytes %Sm' -t '%Y-%m-%d %H:%M' "${_pkg}";; *) TZ=UTC stat --format='%n: %s bytes %y' "${_pkg}";; esac diff --git a/_sign-code.sh b/_sign-code.sh index 40e37264a..ed3cffdb9 100755 --- a/_sign-code.sh +++ b/_sign-code.sh @@ -12,7 +12,7 @@ if [ -s "${SIGN_CODE_KEY}" ] && \ _ref="$1" shift - case "${_OS}" in + case "${_HOSTOS}" in bsd|mac) unixts="$(TZ=UTC stat -f '%m' "${_ref}")";; *) unixts="$(TZ=UTC stat --format='%Y' "${_ref}")";; esac diff --git a/_ul.sh b/_ul.sh index fc3d27de4..0d8c8027b 100755 --- a/_ul.sh +++ b/_ul.sh @@ -55,7 +55,7 @@ touch -c -r "${_ALL}" "${_ALL}.txt" # Official deploy DEPLOY_KEY="$(realpath '.')/deploy.key" -if [ "${PUBLISH_PROD_FROM}" = "${_OS}" ] && \ +if [ "${PUBLISH_PROD_FROM}" = "${_HOSTOS}" ] && \ [ "${_BRANCH#*main*}" != "${_BRANCH}" ] && \ [ -s "${DEPLOY_KEY}.asc" ] && \ [ -n "${DEPLOY_GPG_PASS:+1}" ]; then @@ -107,7 +107,7 @@ EOF 'curl-for-win@silly.haxx.se:.' fi - case "${_OS}" in + case "${_HOSTOS}" in mac) rm -f -P "${DEPLOY_KEY}";; linux) [ -w "${DEPLOY_KEY}" ] && srm "${DEPLOY_KEY}";; esac diff --git a/curl-pkg.sh b/curl-pkg.sh index a94068d18..3b6f4572c 100755 --- a/curl-pkg.sh +++ b/curl-pkg.sh @@ -35,7 +35,7 @@ # Tests # Show the reference timestamp in UTC. - case "${_OS}" in + case "${_HOSTOS}" in bsd|mac) TZ=UTC stat -f '%N: %Sm' -t '%Y-%m-%d %H:%M' "${_ref}";; *) TZ=UTC stat --format='%n: %y' "${_ref}";; esac diff --git a/openssl.sh b/openssl.sh index 3a608fe81..21b3d8ab0 100755 --- a/openssl.sh +++ b/openssl.sh @@ -15,11 +15,11 @@ _VER="$1" cd "${_NAM}" || exit 0 # Required on MSYS2 for pod2man and pod2html in 'make install' phase - [ "${_OS}" = 'win' ] && export PATH="${PATH}:/usr/bin/core_perl" + [ "${_HOSTOS}" = 'win' ] && export PATH="${PATH}:/usr/bin/core_perl" readonly _ref='CHANGES.md' - case "${_OS}" in + case "${_HOSTOS}" in bsd|mac) unixts="$(TZ=UTC stat -f '%m' "${_ref}")";; *) unixts="$(TZ=UTC stat --format='%Y' "${_ref}")";; esac