This creates a generated version number. When not on the master
branch (i.e., a release branch) it uses git describe --tags to return
either the exact release tag or if on a later commit (because there
was a fix made to a released version) then the command returns that
tag plus the number of commits since that tag along with the short
hash. When on the master branch, which has no tags, it returns a
similiar output.
Signed-off-by: Jason Self <j@jxself.org>
-AC_INIT([muddle], [1.0], [muddle@muddlers.org])
+AC_INIT([muddle], m4_esyscmd_s([./version.sh]), [muddle@muddlers.org])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CC
AC_CONFIG_HEADERS([config.h])
--- /dev/null
+# Copyright (C) 2018 Jason Self <j@jxself.org>
+# Copying and distribution of this file, with or without
+# modification, are permitted in any medium without royalty provided
+# the copyright notice and this notice are preserved. This file is
+# offered as-is, without any warranty.
+
+branch=$(git rev-parse --abbrev-ref HEAD)
+if [ "$branch" != "master" ]
+then
+ git describe --tags
+else
+ commit_count=$(git rev-list HEAD --count)
+ short_hash=$(git rev-parse --short HEAD)
+ echo "$branch-$commit_count-$short_hash"
+fi
\ No newline at end of file