summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-09-13 10:32:57 +0200
committerThomas Haller <thaller@redhat.com>2016-09-14 14:11:07 +0200
commit1c3098cc13d71a401225ff05cd133831dbe9434b (patch)
tree3a9915c5e2367c323cab9fc4804c0c555c8720c9 /m4
parentd953df1c3c86c86a2ef6c22005795eee46e487ea (diff)
build: move detection of NM_GIT_SHA to separate "m4/git-sha-record.m4"
We want to embed the current commit-id in the ./configure script. That way the generated ./configure file in the source tarball references the commit-id from which the tarball was created. Then, in a second step, a script can check ./configure to find the parent commit. This is for example done by the 'makerepo.sh' script. This is generally useful, and also done by network-manager-applet and libnl3 projects. Move the function to a separate m4 macro to reuse it. It should also be re-used in NetworkManager's VPN plugins.
Diffstat (limited to 'm4')
-rw-r--r--m4/git-sha-record.m415
1 files changed, 15 insertions, 0 deletions
diff --git a/m4/git-sha-record.m4 b/m4/git-sha-record.m4
new file mode 100644
index 000000000..e259b39fb
--- /dev/null
+++ b/m4/git-sha-record.m4
@@ -0,0 +1,15 @@
+dnl GIT_SHA_RECORD($1, $2)
+dnl
+dnl $1: the name of the assigned variable. For example NM_GIT_SHA,
+dnl NMA_GIT_SHA, LIBNL_GIT_SHA.
+dnl $2: by default, a define to config.h is added. This can be
+dnl suppressed by passing "no-config-h".
+dnl
+AC_DEFUN([GIT_SHA_RECORD], [
+ m4_define([git_sha_record_v],
+ [m4_esyscmd([ ( [ -d ./.git/ ] && [ "$(readlink -f ./.git/)" = "$(readlink -f "$(git rev-parse --git-dir 2>/dev/null)" 2>/dev/null)" ] && git rev-parse --verify -q HEAD 2>/dev/null ) || true ])])
+$1=git_sha_record_v
+if test ""$2"" != "no-config-h" ; then
+ AC_DEFINE_UNQUOTED($1,"$$1",[git commit id of the original source code version])
+fi
+])