From 535040aab88508e4c43b7d29a96ea74aa5d0883a Mon Sep 17 00:00:00 2001 From: Chris Wong Date: Fri, 8 May 2015 22:26:26 +1200 Subject: [PATCH 1/3] Generate CFG_FILENAME_EXTRA from the version The code takes a prefix of the MD5 hash of the version string. Since the hash command differs across GNU and BSD platforms, we scan for the right one in the configure script. Closes #25007 --- configure | 14 ++++++++++++++ mk/main.mk | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 9aebfe07967..814626481f5 100755 --- a/configure +++ b/configure @@ -709,6 +709,20 @@ else probe_need CFG_GIT git fi +# Use `md5sum` on GNU platforms, or `md5 -q` on BSD +probe CFG_MD5 md5 +probe CFG_MD5SUM md5sum +if [ -n "$CFG_MD5" ] +then + CFG_HASH_COMMAND="$CFG_MD5 -q | head -c 8" +elif [ -n "$CFG_MD5SUM" ] +then + CFG_HASH_COMMAND="$CFG_MD5SUM | head -c 8" +else + err 'could not find one of: md5 md5sum' +fi +putvar CFG_HASH_COMMAND + probe CFG_CLANG clang++ probe CFG_CCACHE ccache probe CFG_GCC gcc diff --git a/mk/main.mk b/mk/main.mk index 9ac96aa90f6..20323adaea1 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -20,7 +20,9 @@ CFG_RELEASE_NUM=1.1.0 # versions (section 9) CFG_PRERELEASE_VERSION=.1 -CFG_FILENAME_EXTRA=4e7c5e5c +# Append a version-dependent hash to each library, so we can install different +# versions in the same place +CFG_FILENAME_EXTRA=$(shell echo -n $(CFG_RELEASE) | $(CFG_HASH_COMMAND)) ifeq ($(CFG_RELEASE_CHANNEL),stable) # This is the normal semver version string, e.g. "0.12.0", "0.12.0-nightly" From 939c53ea42bc677dbce9755a77bd55a5d47f8185 Mon Sep 17 00:00:00 2001 From: Chris Wong Date: Fri, 8 May 2015 22:35:40 +1200 Subject: [PATCH 2/3] configure: display correct version for md5sum The old code simply scanned for the first digit, then munched anything after that. This didn't work for md5sum, as it would see the "5" and treat "5sum" as the version instead. This patch tweaks the algorithm so that it looks for a second consecutive digit (or dot) after the first. Since "md5sum" has only one digit, the new code skips over it as intended. --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 814626481f5..50d24c1bec9 100755 --- a/configure +++ b/configure @@ -104,8 +104,8 @@ probe() { T=$(command -v $P 2>&1) if [ $? -eq 0 ] then - VER0=$($P --version 2>/dev/null | head -1 \ - | sed -e 's/[^0-9]*\([vV]\?[0-9.]\+[^ ]*\).*/\1/' ) + VER0=$($P --version 2>/dev/null \ + | grep -o '[vV]\?[0-9][0-9.][a-z0-9.-]*' | head -1 ) if [ $? -eq 0 -a "x${VER0}" != "x" ] then VER="($VER0)" From 2c0db5e331b2b15633fc9028cf019f6a2fe48a6f Mon Sep 17 00:00:00 2001 From: Chris Wong Date: Wed, 13 May 2015 09:56:25 +1200 Subject: [PATCH 3/3] Use `printf %s` instead of `echo -n` in build script According to POSIX, the behavior of `echo -n` is "implementation defined". So we can't guarantee that it gives the same result everywhere. See also: * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html * http://unix.stackexchange.com/q/65803/9814 --- mk/main.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/main.mk b/mk/main.mk index 20323adaea1..60f5114f0ae 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -22,7 +22,7 @@ CFG_PRERELEASE_VERSION=.1 # Append a version-dependent hash to each library, so we can install different # versions in the same place -CFG_FILENAME_EXTRA=$(shell echo -n $(CFG_RELEASE) | $(CFG_HASH_COMMAND)) +CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE) | $(CFG_HASH_COMMAND)) ifeq ($(CFG_RELEASE_CHANNEL),stable) # This is the normal semver version string, e.g. "0.12.0", "0.12.0-nightly"