[PATCH 1/2] cpukit: Add the git hash to the version if built from git source.

Chris Johns chrisj at rtems.org
Sun Nov 5 07:45:09 UTC 2017


Update #3217.
---
 cpukit/aclocal/git-version.m4 | 16 ++++++++++++++++
 cpukit/aclocal/rtems-top.m4   |  7 ++++---
 cpukit/configure.ac           |  2 +-
 3 files changed, 21 insertions(+), 4 deletions(-)
 create mode 100644 cpukit/aclocal/git-version.m4

diff --git a/cpukit/aclocal/git-version.m4 b/cpukit/aclocal/git-version.m4
new file mode 100644
index 0000000000..ab15cad137
--- /dev/null
+++ b/cpukit/aclocal/git-version.m4
@@ -0,0 +1,16 @@
+AC_DEFUN([RTEMS_GIT_VERSIONING],[
+ AC_REQUIRE([RTEMS_VERSIONING])
+ AC_MSG_CHECKING([git version])
+ RTEMS_GIT_HASH=
+ RTEMS_GIT_VERSION=_RTEMS_VERSION
+ cd "$srcdir" && git rev-parse --git-dir > /dev/null 2>&1 && cd "$ac_pwd"
+ AS_IF([test $? == 0],[
+        RTEMS_GIT_HASH=$(cd "$srcdir" && git describe --always && cd "$ac_pwd")
+        RTEMS_GIT_VERSION=_RTEMS_VERSION.$RTEMS_GIT_HASH
+	AC_MSG_RESULT([$RTEMS_GIT_HASH])
+       ],[
+        AC_MSG_RESULT([not a git repo])
+       ])
+ AC_SUBST([RTEMS_GIT_HASH],[${RTEMS_GIT_HASH}])
+ AC_SUBST([RTEMS_GIT_VERSION],[${RTEMS_GIT_VERSION}])
+])
diff --git a/cpukit/aclocal/rtems-top.m4 b/cpukit/aclocal/rtems-top.m4
index b0cdaaa4d7..d5d182cdd2 100644
--- a/cpukit/aclocal/rtems-top.m4
+++ b/cpukit/aclocal/rtems-top.m4
@@ -3,12 +3,13 @@ AC_PREREQ(2.62)
 
 dnl
 dnl RTEMS_TOP($1)
-dnl 
+dnl
 dnl $1 .. relative path from this configure.ac to the toplevel configure.ac
 dnl
 AC_DEFUN([RTEMS_TOP],
 [dnl
 AC_REQUIRE([RTEMS_VERSIONING])
+AC_REQUIRE([RTEMS_GIT_VERSIONING])
 AC_REQUIRE([AM_SET_LEADING_DOT])
 AC_REQUIRE([AC_DISABLE_OPTION_CHECKING])
 AC_CONFIG_AUX_DIR([$1])
@@ -25,7 +26,7 @@ rtems_updir=m4_if([$2],[],[`echo "$1/" | sed 's,^\.\.\/,,'`],[$2/])
 AS_IF([test -n "$with_multisubdir"],
   [MULTIBUILDTOP=`echo "/$with_multisubdir" | sed 's,/[[^\\/]]*,../,g'`])
 AC_SUBST(MULTIBUILDTOP)
- 
+
 AS_IF([test -n "$with_multisubdir"],
   [MULTISUBDIR="/$with_multisubdir"])
 AC_SUBST(MULTISUBDIR)
@@ -53,7 +54,7 @@ esac],[
 ## Defaults: Note: Two different defaults!
 ## ../ for multilib
 ## '.' for non-multilib
-AS_IF([test "$enable_multilib" = "yes"],[ 
+AS_IF([test "$enable_multilib" = "yes"],[
   PROJECT_ROOT='$(top_builddir)'/${rtems_updir}'../$(MULTIBUILDTOP)'],[
   PROJECT_ROOT='$(top_builddir)'/${rtems_updir}])
 ])
diff --git a/cpukit/configure.ac b/cpukit/configure.ac
index 427b64987a..d2eba74666 100644
--- a/cpukit/configure.ac
+++ b/cpukit/configure.ac
@@ -231,7 +231,7 @@ RTEMS_CPUOPT([RTEMS_DRVMGR_STARTUP],
 
 RTEMS_CPUOPT([RTEMS_VERSION],
   [true],
-  ["]_RTEMS_VERSION["],
+  ["$RTEMS_GIT_VERSION"],
   [RTEMS version string])
 
 ## Header file differences that need to be known in .h after install
-- 
2.13.2



More information about the devel mailing list