Skip to content

Commit 5bb907b

Browse files
authored
Merge pull request #9251 from oech3/prefer-g
build-gnu.sh: Use system tools
2 parents fe64077 + 44ae621 commit 5bb907b

File tree

2 files changed

+8
-41
lines changed

2 files changed

+8
-41
lines changed

util/build-gnu.sh

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,11 @@
88

99
set -e
1010

11-
# Use GNU version for make, nproc, readlink and sed on *BSD
12-
case "$OSTYPE" in
13-
*bsd*)
14-
MAKE="gmake"
15-
NPROC="gnproc"
16-
READLINK="greadlink"
17-
SED="gsed"
18-
;;
19-
*)
20-
MAKE="make"
21-
NPROC="nproc"
22-
READLINK="readlink"
23-
SED="sed"
24-
;;
25-
esac
11+
# Use system's GNU version for make, nproc, readlink and sed on *BSD
12+
MAKE=$(command -v gmake||command -v make)
13+
NPROC=$(command -v gnproc||command -v nproc)
14+
READLINK=$(command -v greadlink||command -v readlink)
15+
SED=$(command -v gsed||command -v sed)
2616

2717
ME="${0}"
2818
ME_dir="$(dirname -- "$("${READLINK}" -fm -- "${ME}")")"
@@ -49,24 +39,8 @@ path_GNU="$("${READLINK}" -fm -- "${path_GNU:-${path_UUTILS}/../gnu}")"
4939

5040
###
5141

52-
# On MacOS there is no system /usr/bin/timeout
53-
# and trying to add it to /usr/bin (with symlink of copy binary) will fail unless system integrity protection is disabled (not ideal)
54-
# ref: https://support.apple.com/en-us/102149
55-
# On MacOS the Homebrew coreutils could be installed and then "sudo ln -s /opt/homebrew/bin/timeout /usr/local/bin/timeout"
56-
# Set to /usr/local/bin/timeout instead if /usr/bin/timeout is not found
57-
SYSTEM_TIMEOUT="timeout"
58-
if [ -x /usr/bin/timeout ]; then
59-
SYSTEM_TIMEOUT="/usr/bin/timeout"
60-
elif [ -x /usr/local/bin/timeout ]; then
61-
SYSTEM_TIMEOUT="/usr/local/bin/timeout"
62-
fi
63-
64-
SYSTEM_YES="yes"
65-
if [ -x /usr/bin/yes ]; then
66-
SYSTEM_YES="/usr/bin/yes"
67-
elif [ -x /usr/local/bin/yes ]; then
68-
SYSTEM_YES="/usr/local/bin/yes"
69-
fi
42+
SYSTEM_TIMEOUT=$(command -v timeout)
43+
SYSTEM_YES=$(command -v yes)
7044

7145
###
7246

util/show-utils.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@
55
# spell-checker:ignore (jq) deps startswith
66

77
# Use GNU version for realpath on *BSD
8-
case "$OSTYPE" in
9-
*bsd*)
10-
REALPATH="grealpath"
11-
;;
12-
*)
13-
REALPATH="realpath"
14-
;;
15-
esac
8+
REALPATH=$(command -v grealpath||command -v realpath)
169

1710
ME="${0}"
1811
ME_dir="$(dirname -- "${ME}")"

0 commit comments

Comments
 (0)