From 6e3765440f92e0232155037a5dd1b1873344222a Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Wed, 19 May 2021 02:35:29 -0700 Subject: [PATCH] Mac: fix build scripts to be compatible with both bash and zsh shells --- mac_build/BuildMacBOINC.sh | 7 +++++-- mac_build/buildFTGL.sh | 13 +++++++------ mac_build/buildWxMac.sh | 19 ++++++++++--------- mac_build/buildc-ares.sh | 15 ++++++++------- mac_build/buildcurl.sh | 16 ++++++++++------ mac_build/buildfreetype.sh | 13 +++++++------ mac_build/buildopenssl.sh | 16 ++++++++++------ 7 files changed, 57 insertions(+), 42 deletions(-) diff --git a/mac_build/BuildMacBOINC.sh b/mac_build/BuildMacBOINC.sh index a0bace0686..a9bcb49d57 100644 --- a/mac_build/BuildMacBOINC.sh +++ b/mac_build/BuildMacBOINC.sh @@ -34,6 +34,7 @@ # Updated 10/19/17 Special handling of screensaver build is no longer needed # Updated 10/14/18 for Xcode 10 (use this script only with BOINC 7.15 or later) # Updated 3/31/21 To eliminate redundant -c++11 arg since C++11 build is now standard +# Updated 5/19/21 for compatibility with zsh # ## This script requires OS 10.8 or later # @@ -100,7 +101,7 @@ while [ $# -gt 0 ]; do -all ) buildall=1 ; shift 1 ;; -lib ) buildlibs=1 ; shift 1 ;; -client ) buildclient=1 ; shift 1 ;; - -target ) shift 1 ; targets="-target $1" ; buildzip=0 ; shift 1 ;; + -target ) shift 1 ; targets="$targets -target $1" ; buildzip=0 ; shift 1 ;; -setting ) shift 1 ; name="$1" ; shift 1 ; unset value ; value=("$1"); settings+=("$name=""${value[@]}") ; @@ -161,7 +162,9 @@ echo "" SDKPATH=`xcodebuild -version -sdk macosx Path` result=0 -xcodebuild -project boinc.xcodeproj ${targets} -configuration ${style} -sdk "${SDKPATH}" ${doclean} build ${uselibcplusplus} "${settings[@]}" +## For unknown reasons, this xcodebuild call generates syntax errors under zsh unless +## we enclose the command in quotes and invoke it with eval +eval "xcodebuild -project boinc.xcodeproj ${targets} -configuration ${style} -sdk \"${SDKPATH}\" ${doclean} build ${uselibcplusplus} ${settings[@]}" result=$? if [ $result -eq 0 ]; then diff --git a/mac_build/buildFTGL.sh b/mac_build/buildFTGL.sh index ed618e62b0..a7caed0331 100644 --- a/mac_build/buildFTGL.sh +++ b/mac_build/buildFTGL.sh @@ -28,6 +28,7 @@ # Updated 2/8/18 to fix linker warning for Xcode 9.2 under OS 10.13 # Updated 1/23/19 use libc++ instead of libstdc++ for Xcode 10 compatibility # Updated 8/22/20 TO build Apple Silicon / arm64 and x86_64 Universal binary +# Updated 5/18/21 for compatibility with zsh # ## This script requires OS 10.8 or later # @@ -92,18 +93,18 @@ fi GCC_can_build_x86_64="no" GCC_can_build_arm64="no" GCC_archs=`lipo -info "${GCCPATH}"` -if [[ "${GCC_archs}" == *"x86_64"* ]]; then GCC_can_build_x86_64="yes"; fi -if [[ "${GCC_archs}" == *"arm64"* ]]; then GCC_can_build_arm64="yes"; fi +if [[ "${GCC_archs}" = *"x86_64"* ]]; then GCC_can_build_x86_64="yes"; fi +if [[ "${GCC_archs}" = *"arm64"* ]]; then GCC_can_build_arm64="yes"; fi if [ "${doclean}" != "yes" ]; then if [ -f "${libPath}/libftgl.a" ]; then alreadyBuilt=1 - if [ $GCC_can_build_x86_64 == "yes" ]; then + if [ $GCC_can_build_x86_64 = "yes" ]; then lipo "${libPath}/libftgl.a" -verify_arch x86_64 if [ $? -ne 0 ]; then alreadyBuilt=0; doclean="yes"; fi fi - if [ $alreadyBuilt -eq 1 ] && [ $GCC_can_build_arm64 == "yes" ]; then + if [ $alreadyBuilt -eq 1 ] && [ $GCC_can_build_arm64 = "yes" ]; then lipo "${libPath}/libftgl.a" -verify_arch arm64 if [ $? -ne 0 ]; then alreadyBuilt=0; doclean="yes"; fi fi @@ -160,7 +161,7 @@ else fi if [ $? -ne 0 ]; then return 1; fi -if [ "${doclean}" == "yes" ]; then +if [ "${doclean}" = "yes" ]; then make clean 1>$stdout_target fi @@ -180,7 +181,7 @@ cd "${SRCDIR}" || return 1 # Now see if we can build for arm64 # Note: Some versions of Xcode 12 don't support building for arm64 -if [ $GCC_can_build_arm64 == "yes" ]; then +if [ $GCC_can_build_arm64 = "yes" ]; then export CC="${GCCPATH}";export CXX="${GPPPATH}" export LDFLAGS="-Wl,-syslibroot,${SDKPATH},-arch,arm64" diff --git a/mac_build/buildWxMac.sh b/mac_build/buildWxMac.sh index 58cf370b14..7dea25b8c3 100644 --- a/mac_build/buildWxMac.sh +++ b/mac_build/buildWxMac.sh @@ -40,6 +40,7 @@ # Update for compatibility with Xcode 10 (this script for BOINC 7.15+ only) 10/14/18 # Add patches to build with Xcode 11 and OS 10.15 sdk 3/1/20 # Updated 8/4/20 TO build Apple Silicon / arm64 and x86_64 Universal binary +# Updated 5/18/21 for compatibility with zsh # ## This script requires OS 10.6 or later ## @@ -309,14 +310,14 @@ if [ "${doclean}" != "clean" ] && [ -f "${libPathRel}/libwx_osx_cocoa_static.a" GCC_can_build_arm64="no" GCC_archs=`lipo -archs "${GCCPATH}"` - if [[ "${GCC_archs}" == *"x86_64"* ]]; then GCC_can_build_x86_64="yes"; fi - if [[ "${GCC_archs}" == *"arm64"* ]]; then GCC_can_build_arm64="yes"; fi - if [ $GCC_can_build_x86_64 == "yes" ]; then + if [[ "${GCC_archs}" = *"x86_64"* ]]; then GCC_can_build_x86_64="yes"; fi + if [[ "${GCC_archs}" = *"arm64"* ]]; then GCC_can_build_arm64="yes"; fi + if [ $GCC_can_build_x86_64 = "yes" ]; then lipo "${libPathRel}/libwx_osx_cocoa_static.a" -verify_arch x86_64 if [ $? -ne 0 ]; then alreadyBuilt=0; doclean="clean"; fi fi - if [ $alreadyBuilt -eq 1 ] && [ $GCC_can_build_arm64 == "yes" ]; then + if [ $alreadyBuilt -eq 1 ] && [ $GCC_can_build_arm64 = "yes" ]; then lipo "${libPathRel}/libwx_osx_cocoa_static.a" -verify_arch arm64 if [ $? -ne 0 ]; then alreadyBuilt=0; doclean="clean"; fi fi @@ -348,7 +349,7 @@ else fi fi -if [ "${nodebug}" == "yes" ]; then +if [ "${nodebug}" = "yes" ]; then return 0 fi @@ -359,14 +360,14 @@ if [ "${doclean}" != "clean" ] && [ -f "${libPathDbg}/libwx_osx_cocoa_static.a" GCC_can_build_arm64="no" GCC_archs=`lipo -archs "${GCCPATH}"` - if [[ "${GCC_archs}" == *"x86_64"* ]]; then GCC_can_build_x86_64="yes"; fi - if [[ "${GCC_archs}" == *"arm64"* ]]; then GCC_can_build_arm64="yes"; fi - if [ GCC_can_build_x86_64 == "yes" ]; then + if [[ "${GCC_archs}" = *"x86_64"* ]]; then GCC_can_build_x86_64="yes"; fi + if [[ "${GCC_archs}" = *"arm64"* ]]; then GCC_can_build_arm64="yes"; fi + if [ GCC_can_build_x86_64 = "yes" ]; then lipo "${libPathDbg}/libwx_osx_cocoa_static.a" -verify_arch x86_64 if [ $? -ne 0 ]; then alreadyBuilt=0; doclean="clean"; fi fi - if [ $alreadyBuilt -eq 1 ] && [ GCC_can_build_arm64 == "yes" ]; then + if [ $alreadyBuilt -eq 1 ] && [ GCC_can_build_arm64 = "yes" ]; then lipo "${libPathDbg}/libwx_osx_cocoa_static.a" -verify_arch arm64 if [ $? -ne 0 ]; then alreadyBuilt=0; doclean="clean"; fi fi diff --git a/mac_build/buildc-ares.sh b/mac_build/buildc-ares.sh index 12a9bf2fec..748b98c416 100644 --- a/mac_build/buildc-ares.sh +++ b/mac_build/buildc-ares.sh @@ -31,7 +31,8 @@ # Updated 1/25/18 for bulding c-ares 1.13.0 (updated comemnts only) # Updated 2/22/18 to avoid APIs not available in earlier versions of OS X # Updated 1/23/19 use libc++ instead of libstdc++ for Xcode 10 compatibility -# Updated 8/22/20 TO build Apple Silicon / arm64 and x86_64 Universal binary +# Updated 8/22/20 to build Apple Silicon / arm64 and x86_64 Universal binary +# Updated 5/18/21 for compatibility with zsh # ## This script requires OS 10.8 or later # @@ -106,19 +107,19 @@ fi GCC_can_build_x86_64="no" GCC_can_build_arm64="no" GCC_archs=`lipo -info "${GCCPATH}"` -if [[ "${GCC_archs}" == *"x86_64"* ]]; then GCC_can_build_x86_64="yes"; fi -if [[ "${GCC_archs}" == *"arm64"* ]]; then GCC_can_build_arm64="yes"; fi +if [[ "${GCC_archs}" = *"x86_64"* ]]; then GCC_can_build_x86_64="yes"; fi +if [[ "${GCC_archs}" = *"arm64"* ]]; then GCC_can_build_arm64="yes"; fi if [ "${doclean}" != "yes" ]; then if [ -f "${libPath}/libcares.a" ]; then alreadyBuilt=1 - if [ $GCC_can_build_x86_64 == "yes" ]; then + if [ $GCC_can_build_x86_64 = "yes" ]; then lipo "${libPath}/libcares.a" -verify_arch x86_64 if [ $? -ne 0 ]; then alreadyBuilt=0; doclean="yes"; fi fi - if [ $alreadyBuilt -eq 1 ] && [ $GCC_can_build_arm64 == "yes" ]; then + if [ $alreadyBuilt -eq 1 ] && [ $GCC_can_build_arm64 = "yes" ]; then lipo "${libPath}/libcares.a" -verify_arch arm64 if [ $? -ne 0 ]; then alreadyBuilt=0; doclean="yes"; fi fi @@ -178,7 +179,7 @@ if [ $? -ne 0 ]; then return 1; fi patch_ares_config -if [ "${doclean}" == "yes" ]; then +if [ "${doclean}" = "yes" ]; then make clean fi @@ -189,7 +190,7 @@ if [ $? -ne 0 ]; then return 1; fi # Now see if we can build for arm64 # Note: Some versions of Xcode 12 don't support building for arm64 -if [ $GCC_can_build_arm64 == "yes" ]; then +if [ $GCC_can_build_arm64 = "yes" ]; then export CC="${GCCPATH}";export CXX="${GPPPATH}" export CPPFLAGS="" diff --git a/mac_build/buildcurl.sh b/mac_build/buildcurl.sh index b5f4c6e9c8..29f02a1240 100644 --- a/mac_build/buildcurl.sh +++ b/mac_build/buildcurl.sh @@ -38,6 +38,7 @@ # Updated 1/23/19 use libc++ instead of libstdc++ for Xcode 10 compatibility # Updated 8/22/20 TO build Apple Silicon / arm64 and x86_64 Universal binary # Updated 12/24/20 for curl 7.73.0 +# Updated 5/18/21 for compatibility with zsh # ## This script requires OS 10.8 or later # @@ -134,19 +135,19 @@ fi GCC_can_build_x86_64="no" GCC_can_build_arm64="no" GCC_archs=`lipo -info "${GCCPATH}"` -if [[ "${GCC_archs}" == *"x86_64"* ]]; then GCC_can_build_x86_64="yes"; fi -if [[ "${GCC_archs}" == *"arm64"* ]]; then GCC_can_build_arm64="yes"; fi +if [[ "${GCC_archs}" = *"x86_64"* ]]; then GCC_can_build_x86_64="yes"; fi +if [[ "${GCC_archs}" = *"arm64"* ]]; then GCC_can_build_arm64="yes"; fi if [ "${doclean}" != "yes" ]; then if [ -f "${libPath}/libcurl.a" ]; then alreadyBuilt=1 - if [ $GCC_can_build_x86_64 == "yes" ]; then + if [ $GCC_can_build_x86_64 = "yes" ]; then lipo "${libPath}/libcurl.a" -verify_arch x86_64 if [ $? -ne 0 ]; then alreadyBuilt=0; doclean="yes"; fi fi - if [ $alreadyBuilt -eq 1 ] && [ $GCC_can_build_arm64 == "yes" ]; then + if [ $alreadyBuilt -eq 1 ] && [ $GCC_can_build_arm64 = "yes" ]; then lipo "${libPath}/libcurl.a" -verify_arch arm64 if [ $? -ne 0 ]; then alreadyBuilt=0; doclean="yes"; fi fi @@ -214,6 +215,9 @@ else # Get the names of the current versions of c-ares and openssl from # the dependencyNames.sh file in the same directory as this script. myScriptPath="${BASH_SOURCE[0]}" + if [ -z ${myScriptPath} ]; then + myScriptPath="$0" # for zsh + fi myScriptDir="${myScriptPath%/*}" source "${myScriptDir}/dependencyNames.sh" if [ $? -ne 0 ]; then return 1; fi @@ -239,7 +243,7 @@ fi patch_curl_config -if [ "${doclean}" == "yes" ]; then +if [ "${doclean}" = "yes" ]; then make clean fi @@ -253,7 +257,7 @@ fi # Now see if we can build for arm64 # Note: Some versions of Xcode 12 don't support building for arm64 -if [ $GCC_can_build_arm64 == "yes" ]; then +if [ $GCC_can_build_arm64 = "yes" ]; then # c-ares configure creates a different ares_build.h file for each architecture # for a sanity check on size of long and socklen_t. But these are identical for diff --git a/mac_build/buildfreetype.sh b/mac_build/buildfreetype.sh index c15f682c33..f3ebd09adc 100644 --- a/mac_build/buildfreetype.sh +++ b/mac_build/buildfreetype.sh @@ -32,6 +32,7 @@ # Updated 1/25/18 for any version of FreeType (changed only comments) # Updated 1/23/19 use libc++ instead of libstdc++ for Xcode 10 compatibility # Updated 8/22/20 TO build Apple Silicon / arm64 and x86_64 Universal binary +# Updated 5/18/21 for compatibility with zsh # ## This script requires OS 10.8 or later # @@ -97,19 +98,19 @@ fi GCC_can_build_x86_64="no" GCC_can_build_arm64="no" GCC_archs=`lipo -info "${GCCPATH}"` -if [[ "${GCC_archs}" == *"x86_64"* ]]; then GCC_can_build_x86_64="yes"; fi -if [[ "${GCC_archs}" == *"arm64"* ]]; then GCC_can_build_arm64="yes"; fi +if [[ "${GCC_archs}" = *"x86_64"* ]]; then GCC_can_build_x86_64="yes"; fi +if [[ "${GCC_archs}" = *"arm64"* ]]; then GCC_can_build_arm64="yes"; fi if [ "${doclean}" != "yes" ]; then if [ -f "${libPath}/libfreetype.a" ]; then alreadyBuilt=1 - if [ $GCC_can_build_x86_64 == "yes" ]; then + if [ $GCC_can_build_x86_64 = "yes" ]; then lipo "${libPath}/libfreetype.a" -verify_arch x86_64 if [ $? -ne 0 ]; then alreadyBuilt=0; doclean="yes"; fi fi - if [ $alreadyBuilt -eq 1 ] && [ $GCC_can_build_arm64 == "yes" ]; then + if [ $alreadyBuilt -eq 1 ] && [ $GCC_can_build_arm64 = "yes" ]; then lipo "${libPath}/libfreetype.a" -verify_arch arm64 if [ $? -ne 0 ]; then alreadyBuilt=0; doclean="yes"; fi fi @@ -164,7 +165,7 @@ export MACOSX_DEPLOYMENT_TARGET=10.7 ./configure --enable-shared=NO --prefix=${lprefix} --without-png --host=x86_64 if [ $? -ne 0 ]; then return 1; fi -if [ "${doclean}" == "yes" ]; then +if [ "${doclean}" = "yes" ]; then make clean fi @@ -173,7 +174,7 @@ if [ $? -ne 0 ]; then return 1; fi # Now see if we can build for arm64 # Note: Some versions of Xcode 12 don't support building for arm64 -if [ $GCC_can_build_arm64 == "yes" ]; then +if [ $GCC_can_build_arm64 = "yes" ]; then export CC="${GCCPATH}";export CXX="${GPPPATH}" export LDFLAGS="-Wl,-syslibroot,${SDKPATH},-arch,arm64" diff --git a/mac_build/buildopenssl.sh b/mac_build/buildopenssl.sh index 3035c7ba2e..20b37c7b62 100644 --- a/mac_build/buildopenssl.sh +++ b/mac_build/buildopenssl.sh @@ -36,6 +36,7 @@ # Updated 1/23/19 use libc++ instead of libstdc++ for Xcode 10 compatibility # Updated 10/20/20 To build Apple Silicon / arm64 and x86_64 Universal binary # Updated 12/24/20 for openssl-1.1.0l +# Updated 5/18/21 for compatibility with zsh # ## This script requires OS 10.8 or later # @@ -87,21 +88,21 @@ fi GCC_can_build_x86_64="no" GCC_can_build_arm64="no" GCC_archs=`lipo -info "${GCCPATH}"` -if [[ "${GCC_archs}" == *"x86_64"* ]]; then GCC_can_build_x86_64="yes"; fi -if [[ "${GCC_archs}" == *"arm64"* ]]; then GCC_can_build_arm64="yes"; fi +if [[ "${GCC_archs}" = *"x86_64"* ]]; then GCC_can_build_x86_64="yes"; fi +if [[ "${GCC_archs}" = *"arm64"* ]]; then GCC_can_build_arm64="yes"; fi if [ "${doclean}" != "yes" ]; then if [ -f ${libPath}/libssl.a ] && [ -f ${libPath}/libcrypto.a ]; then alreadyBuilt=1 - if [ $GCC_can_build_x86_64 == "yes" ]; then + if [ $GCC_can_build_x86_64 = "yes" ]; then lipo "${libPath}/libssl.a" -verify_arch x86_64 if [ $? -ne 0 ]; then alreadyBuilt=0; doclean="yes"; fi lipo "${libPath}/libcrypto.a" -verify_arch x86_64 if [ $? -ne 0 ]; then alreadyBuilt=0; doclean="yes"; fi fi - if [ $alreadyBuilt -eq 1 ] && [ $GCC_can_build_arm64 == "yes" ]; then + if [ $alreadyBuilt -eq 1 ] && [ $GCC_can_build_arm64 = "yes" ]; then lipo "${libPath}/libssl.a" -verify_arch arm64 if [ $? -ne 0 ]; then alreadyBuilt=0; doclean="yes"; fi lipo "${libPath}/libcrypto.a" -verify_arch arm64 @@ -203,7 +204,7 @@ else if [ $? -ne 0 ]; then return 1; fi fi -if [ "${doclean}" == "yes" ]; then +if [ "${doclean}" = "yes" ]; then make clean 1>$stdout_target fi @@ -212,7 +213,7 @@ if [ $? -ne 0 ]; then return 1; fi # Now see if we can build for arm64 # Note: Some versions of Xcode 12 don't support building for arm64 -if [ $GCC_can_build_arm64 == "yes" ]; then +if [ $GCC_can_build_arm64 = "yes" ]; then export CC="${GCCPATH}";export CXX="${GPPPATH}" export LDFLAGS="-Wl,-syslibroot,${SDKPATH},-arch,arm64" @@ -270,6 +271,9 @@ if [ $GCC_can_build_arm64 == "yes" ]; then # Get the names of the current versions of and openssl from the # dependencyNames.sh file in the same directory as this script. myScriptPath="${BASH_SOURCE[0]}" + if [ -z ${myScriptPath} ]; then + myScriptPath="$0" # for zsh + fi myScriptDir="${myScriptPath%/*}" source "${myScriptDir}/dependencyNames.sh"