From 7fa05b29b6cd06a5914a16234f7c8315255b09fc Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sun, 29 Oct 2017 13:10:09 +1300 Subject: [PATCH 1/2] Use g-prefixed coreutils commands if they are available If they are present on the system, it means that the non-prefixed ones are not necessarily the versions we want, while the prefixed ones are highly likely to be the ones from GNU Coreutils. --- zcutil/build.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/zcutil/build.sh b/zcutil/build.sh index 5e6b318f5..570ad3abb 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -2,6 +2,21 @@ set -eu -o pipefail +function cmd_pref() { + if type -p "$2" > /dev/null; then + eval "$1=$2" + else + eval "$1=$3" + fi +} + +# If a g-prefixed version of the command exists, use it preferentially. +function gprefix() { + cmd_pref "$1" "g$2" "$2" +} + +gprefix READLINK readlink + # Allow user overrides to $MAKE. Typical usage for users who need it: # MAKE=gmake ./zcutil/build.sh -j$(nproc) if [[ -z "${MAKE-}" ]]; then @@ -58,7 +73,7 @@ EOF fi set -x -cd "$(dirname "$(readlink -f "$0")")/.." +cd "$(dirname "$("$READLINK" -f "$0")")/.." # If --enable-lcov is the first argument, enable lcov coverage support: LCOV_ARG='' From e4cd34126063beb5dfa7b01909f8ea8b204e1d86 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 30 Oct 2017 01:22:55 +1300 Subject: [PATCH 2/2] Replace hard-coded defaults for HOST and BUILD with config.guess --- zcutil/build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zcutil/build.sh b/zcutil/build.sh index 570ad3abb..f665088ac 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -16,6 +16,7 @@ function gprefix() { } gprefix READLINK readlink +cd "$(dirname "$("$READLINK" -f "$0")")/.." # Allow user overrides to $MAKE. Typical usage for users who need it: # MAKE=gmake ./zcutil/build.sh -j$(nproc) @@ -26,10 +27,10 @@ fi # Allow overrides to $BUILD and $HOST for porters. Most users will not need it. # BUILD=i686-pc-linux-gnu ./zcutil/build.sh if [[ -z "${BUILD-}" ]]; then - BUILD=x86_64-unknown-linux-gnu + BUILD="$(./depends/config.guess)" fi if [[ -z "${HOST-}" ]]; then - HOST=x86_64-unknown-linux-gnu + HOST="$BUILD" fi # Allow override to $CC and $CXX for porters. Most users will not need it. @@ -73,7 +74,6 @@ EOF fi set -x -cd "$(dirname "$("$READLINK" -f "$0")")/.." # If --enable-lcov is the first argument, enable lcov coverage support: LCOV_ARG=''