# HG changeset patch # User "Yann E. MORIN" # Date 1321202897 -3600 # Node ID d77d04661cd9af11afea5d62e447667bdaeee4c7 # Parent e312ed42d7a50bd9b2e20a1df6664161e95e1ac6 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 -r e312ed42d7a5 -r d77d04661cd9 configure --- a/configure Sun Nov 13 17:39:55 2011 +0100 +++ b/configure Sun Nov 13 17:48:17 2011 +0100 @@ -536,21 +536,35 @@ # 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" #---------------------------------------------------------------------