diff --git a/scripts/build-toolchains.sh b/scripts/build-toolchains.sh index 536a2e57..f11a3cbd 100755 --- a/scripts/build-toolchains.sh +++ b/scripts/build-toolchains.sh @@ -6,9 +6,16 @@ set -e set -o pipefail +# On macOS, use GNU readlink from 'coreutils' package in Homebrew/MacPorts +if [ "$(uname -s)" = "Darwin" ] ; then + READLINK=greadlink +else + READLINK=readlink +fi + # If BASH_SOURCE is undefined, we may be running under zsh, in that case # provide a zsh-compatible alternative -DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]:-${(%):-%x}}")")" +DIR="$(dirname "$($READLINK -f "${BASH_SOURCE[0]:-${(%):-%x}}")")" CHIPYARD_DIR="$(dirname "$DIR")" usage() { diff --git a/scripts/init-submodules-no-riscv-tools-nolog.sh b/scripts/init-submodules-no-riscv-tools-nolog.sh index 0d47dd03..743ea198 100755 --- a/scripts/init-submodules-no-riscv-tools-nolog.sh +++ b/scripts/init-submodules-no-riscv-tools-nolog.sh @@ -17,9 +17,16 @@ if [ "$MINGIT" != "$(echo -e "$MINGIT\n$MYGIT" | sort -V | head -n1)" ]; then false fi +# On macOS, use GNU readlink from 'coreutils' package in Homebrew/MacPorts +if [ "$(uname -s)" = "Darwin" ] ; then + READLINK=greadlink +else + READLINK=readlink +fi + # If BASH_SOURCE is undefined we may be running under zsh, in that case # provide a zsh-compatible alternative -DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]:-${(%):-%x}}")")" +DIR="$(dirname "$($READLINK -f "${BASH_SOURCE[0]:-${(%):-%x}}")")" CHIPYARD_DIR="$(dirname "$DIR")" cd "$CHIPYARD_DIR"