diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2017-01-23 10:28:55 +0100 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2017-01-23 20:33:06 +0100 |
commit | 47349482ee7b737c3cd2a8a1acb18fc3d9b95b0a (patch) | |
tree | d4fb09d11b2998124032c7d1be70841cc42a9df1 | |
parent | 31a21cc0187ceea70a826010476eb260823c5a45 (diff) |
Provide scm version define.
This can be used by code to provide a more exact definition than a release
version.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile.am | 11 | ||||
-rw-r--r-- | scm-version.h.in | 8 | ||||
-rwxr-xr-x | setlocalversion | 83 |
4 files changed, 104 insertions, 0 deletions
@@ -23,6 +23,8 @@ /install-sh /missing /stamp-h1 +/scm-version.h +/scm-version.h.tmp Makefile Makefile.in compile diff --git a/Makefile.am b/Makefile.am index 55c5745..514f16d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,3 +11,14 @@ AM_CPPFLAGS = -DAX25_SYSCONFDIR=\""$(sysconfdir)/ax25/"\" \ AX25_SYSCONFDIR=@sysconfdir@/ax25/ AX25_LOCALSTATEDIR=@localstatedir@/ax25/ + +BUILT_SOURCES = scm-version.h + +.PHONY: scm-version.h +scm-version.h: + sed -e 's/@RELEASE_VER@/@VERSION@/' \ + -e 's/@SCM_VER@/'$$(./setlocalversion)'/' \ + scm-version.h.in > scm-version.h.tmp && \ + (cmp -s scm-version.h.tmp scm-version.h 2>/dev/zero || \ + mv scm-version.h.tmp scm-version.h) + rm scm-version.h.tmp diff --git a/scm-version.h.in b/scm-version.h.in new file mode 100644 index 0000000..d385a72 --- /dev/null +++ b/scm-version.h.in @@ -0,0 +1,8 @@ +#ifndef __SCM_VERSION_H +#define __SCM_VERSION_H + +#define RELEASE_VER "@RELEASE_VER@" +#define SCM_VER "@SCM_VER@" +#define FULL_VER RELEASE_VER SCM_VER + +#endif /* __SCM_VERSION_H */ diff --git a/setlocalversion b/setlocalversion new file mode 100755 index 0000000..e353d68 --- /dev/null +++ b/setlocalversion @@ -0,0 +1,83 @@ +srctree=. +if test $# -gt 0; then + srctree=$1 + shift +fi +if test $# -gt 0 -o ! -d "$srctree"; then + usage +fi + +scm_version() +{ + cd "$srctree" + + # Check for git and a git repo. + if test -z "$(git rev-parse --show-cdup 2>/dev/null)" && + head=`git rev-parse --verify --short HEAD 2>/dev/null`; then + + # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore + # it, because this version is defined in the top level Makefile. + if [ -z "`git describe --exact-match 2>/dev/null`" ]; then + # If we are past a tagged commit (like + # "v2.6.30-rc5-302-g72357d5"), we pretty print it. + if atag="`git describe 2>/dev/null`"; then + echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' + + # If we don't have a tag at all we print -g{commitish}. + else + printf '%s%s' -g $head + fi + fi + + # Is this git on svn? + if git config --get svn-remote.svn.url >/dev/null; then + printf -- '-svn%s' "`git svn find-rev $head`" + fi + + # Check for uncommitted changes + if git diff-index --name-only HEAD | grep -qv "^scripts/package"; then + printf '%s' -dirty + fi + + # All done with git + return + fi + + # Check for mercurial and a mercurial repo. + if test -d .hg && hgid=`hg id 2>/dev/null`; then + # Do we have an tagged version? If so, latesttagdistance == 1 + if [ "`hg log -r . --template '{latesttagdistance}'`" == "1" ]; then + id=`hg log -r . --template '{latesttag}'` + printf '%s%s' -hg "$id" + else + tag=`printf '%s' "$hgid" | cut -d' ' -f2` + if [ -z "$tag" -o "$tag" = tip ]; then + id=`printf '%s' "$hgid" | sed 's/[+ ].*//'` + printf '%s%s' -hg "$id" + fi + fi + + # Are there uncommitted changes? + # These are represented by + after the changeset id. + case "$hgid" in + *+|*+\ *) printf '%s' -dirty ;; + esac + + # All done with mercurial + return + fi + + # Check for svn and a svn repo. + if rev=`LANG= LC_ALL= LC_MESSAGES=C svn info 2>/dev/null | grep '^Last Changed Rev'`; then + rev=`echo $rev | awk '{print $NF}'` + printf -- '-svn%s' "$rev" + + # All done with svn + return + fi +} + +# full scm version string +res="$res$(scm_version)" + +echo "$res" |