From a37a5856371a357583a7ee9e9d05b945eba555f1 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Sun, 13 Nov 2011 17:48:17 +0100 Subject: configure: add support for helper script to compute version string Some projects are using (or planning to use) crosstool-NG, and are storing it in their VCS, which might not be Mercurial. At the same time, those projects may want to track development snapshots versions the way we do with the Hg identity string (hg id). Provide a way for these project to do so, without having to patch ./configure, and maintain that patch over-and-over again. Signed-off-by: "Yann E. MORIN" diff --git a/configure b/configure index 6a68b38..76194b9 100755 --- a/configure +++ b/configure @@ -536,21 +536,35 @@ has_or_abort lib="${ncurses_libs}" \ # If this version is n hg clone, try to get the revision number # If we can't get the revision number, use date printf "\nComputing version string... " -case "${VERSION}" in - *+hg|hg) - REVISION="$( hg id -n 2>/dev/null || true )" - case "${REVISION}" in - "") - VERSION="${VERSION}_unknown@$( date +%Y%m%d.%H%M%S )";; - *) - VERSION="${VERSION}_$( hg id -b )@${REVISION%%+}_$( hg id -i )" - ;; - esac - # Arrange to have no / in the directory name, no need to create an - # arbitrarily deep directory structure - VERSION="$( printf "${VERSION}\n" |"${sed}" -r -e 's|/+|_|g;' )" - ;; -esac + +# Pass the version to the version helper script, if present, to compute +# a local version string, if needed. +if [ -f version.sh -a -x version.sh ]; then + V="$( ./version.sh "${VERSION}" 2>/dev/null |head -n 1 )" +fi + +# If the script returns an empty string, revert to using the version +# we just computed, above. +if [ -n "${V}" ]; then + VERSION="${V}" +else + case "${VERSION}" in + *+hg|hg) + REVISION="$( hg id -n 2>/dev/null || true )" + case "${REVISION}" in + "") + VERSION="${VERSION}_unknown@$( date +%Y%m%d.%H%M%S )";; + *) + VERSION="${VERSION}_$( hg id -b )@${REVISION%%+}_$( hg id -i )" + ;; + esac + # Arrange to have no / in the directory name, no need to create an + # arbitrarily deep directory structure + VERSION="$( printf "${VERSION}\n" |"${sed}" -r -e 's|/+|_|g;' )" + ;; + esac +fi + printf "${VERSION}\n" #--------------------------------------------------------------------- -- cgit v0.10.2-6-g49f6