configure: add support for helper script to compute version string
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Nov 13 17:48:17 2011 +0100 (2011-11-13)
changeset 2744d77d04661cd9
parent 2743 e312ed42d7a5
child 2745 3cd375ecdd72
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" <yann.morin.1998@anciens.enib.fr>
configure
     1.1 --- a/configure	Sun Nov 13 17:39:55 2011 +0100
     1.2 +++ b/configure	Sun Nov 13 17:48:17 2011 +0100
     1.3 @@ -536,21 +536,35 @@
     1.4  # If this version is n hg clone, try to get the revision number
     1.5  # If we can't get the revision number, use date
     1.6  printf "\nComputing version string... "
     1.7 -case "${VERSION}" in
     1.8 -    *+hg|hg)
     1.9 -        REVISION="$( hg id -n 2>/dev/null || true )"
    1.10 -        case "${REVISION}" in
    1.11 -            "")
    1.12 -                VERSION="${VERSION}_unknown@$( date +%Y%m%d.%H%M%S )";;
    1.13 -            *)
    1.14 -                VERSION="${VERSION}_$( hg id -b )@${REVISION%%+}_$( hg id -i )"
    1.15 -                ;;
    1.16 -        esac
    1.17 -        # Arrange to have no / in the directory name, no need to create an
    1.18 -        # arbitrarily deep directory structure
    1.19 -        VERSION="$( printf "${VERSION}\n" |"${sed}" -r -e 's|/+|_|g;' )"
    1.20 -        ;;
    1.21 -esac
    1.22 +
    1.23 +# Pass the version to the version helper script, if present, to compute
    1.24 +# a local version string, if needed.
    1.25 +if [ -f version.sh -a -x version.sh ]; then
    1.26 +    V="$( ./version.sh "${VERSION}" 2>/dev/null |head -n 1 )"
    1.27 +fi
    1.28 +
    1.29 +# If the script returns an empty string, revert to using the version
    1.30 +# we just computed, above.
    1.31 +if [ -n "${V}" ]; then
    1.32 +    VERSION="${V}"
    1.33 +else
    1.34 +    case "${VERSION}" in
    1.35 +        *+hg|hg)
    1.36 +            REVISION="$( hg id -n 2>/dev/null || true )"
    1.37 +            case "${REVISION}" in
    1.38 +                "")
    1.39 +                    VERSION="${VERSION}_unknown@$( date +%Y%m%d.%H%M%S )";;
    1.40 +                *)
    1.41 +                    VERSION="${VERSION}_$( hg id -b )@${REVISION%%+}_$( hg id -i )"
    1.42 +                    ;;
    1.43 +            esac
    1.44 +            # Arrange to have no / in the directory name, no need to create an
    1.45 +            # arbitrarily deep directory structure
    1.46 +            VERSION="$( printf "${VERSION}\n" |"${sed}" -r -e 's|/+|_|g;' )"
    1.47 +            ;;
    1.48 +    esac
    1.49 +fi
    1.50 +
    1.51  printf "${VERSION}\n"
    1.52  
    1.53  #---------------------------------------------------------------------