diff options
author | Peter Johnson <peter@tortall.net> | 2011-08-27 09:25:30 -0700 |
---|---|---|
committer | Peter Johnson <peter@tortall.net> | 2011-08-27 09:25:30 -0700 |
commit | 0ed2cc445131663b07b547cf5aefac893b619e9a (patch) | |
tree | a050603fb8a3e7edbab258779448691792d654db /YASM-VERSION-GEN.sh | |
parent | 8281be0c256a42fd2eab894c5788ace7674ed3cb (diff) | |
download | yasm-0ed2cc445131663b07b547cf5aefac893b619e9a.tar.gz |
Generate version number information from git history.
Due to the svn import structure, a special case is currently implemented
to look for the 1.1.0 branchpoint instead of the most recent tag on the
master branch. This will be removed after the first release is tagged
on the master branch in git.
Specific details:
autogen.sh: More aggressively clean autoconf cache.
This is needed to ensure the version number is actually regenerated.
Don't generate PACKAGE_PATCHLEVEL or PACKAGE_BUILD variables. The
genversion program now parses PACKAGE_VERSION directly.
For Mkfiles builds, YASM-VERSION.h is generated and included by the custom
config.h. This avoids the need to edit config.h for versioning.
Diffstat (limited to 'YASM-VERSION-GEN.sh')
-rwxr-xr-x | YASM-VERSION-GEN.sh | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/YASM-VERSION-GEN.sh b/YASM-VERSION-GEN.sh new file mode 100755 index 00000000..00c0136f --- /dev/null +++ b/YASM-VERSION-GEN.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +YVF=YASM-VERSION-FILE +DEF_VER=v1.1.0 + +LF=' +' + +# First see if there is a version file (included in release tarballs), +# then try git-describe, then default. +if test -f version +then + VN=$(cat version) || VN="$DEF_VER" +elif test -d .git -o -f .git && + VN=$(git describe --match "v[0-9]*" --abbrev=4 HEAD 2>/dev/null) && + case "$VN" in + *$LF*) (exit 1) ;; + v0.1.0*) + # Special handling until we get a more recent tag on the + # master branch + MERGE_BASE=$(git merge-base $DEF_VER HEAD 2>/dev/null) + VN1=$(git rev-list $MERGE_BASE..HEAD | wc -l 2>/dev/null) + VN2=$(git rev-list --max-count=1 --abbrev-commit --abbrev=4 HEAD 2>/dev/null) + VN=$(echo "v$DEF_VER-$VN1-g$VN2" | sed -e 's/ //g') + git update-index -q --refresh + test -z "$(git diff-index --name-only HEAD --)" || + VN="$VN-dirty" ;; + v[0-9]*) + git update-index -q --refresh + test -z "$(git diff-index --name-only HEAD --)" || + VN="$VN-dirty" ;; + esac +then + VN=$(echo "$VN" | sed -e 's/-/./g'); +else + VN="$DEF_VER" +fi + +VN=$(expr "$VN" : v*'\(.*\)') + +if test -r $YVF +then + VC=$(cat $YVF) +else + VC=unset +fi +test "$VN" = "$VC" || { + echo >&2 "$VN" + echo "$VN" >$YVF + echo "#define PACKAGE_STRING \"yasm $VN\"" > YASM-VERSION.h + echo "#define PACKAGE_VERSION \"$VN\"" >> YASM-VERSION.h +} |