[lttng-dev] [PATCH lttng-tool] Fix: mi: Make sure GIT_VERSION symbol always exist

Jonathan Rajotte Julien jonathan.r.julien at gmail.com
Mon Jul 28 17:54:36 EDT 2014


The use of GIT_VERSION symbol in mi to express the position in git tree
force the need to have it defined for each type of build.

This make sure that a build from source file only (git scm not present) is possible.

Signed-off-by: Jonathan Rajotte Julien <jonathan.r.julien at gmail.com>
---
 include/Makefile.am    | 15 ++-------------
 include/version.h.tmpl |  6 +++++-
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/include/Makefile.am b/include/Makefile.am
index d40cb4a..ca515da 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -47,19 +47,8 @@ version.h:
 			## don't want to update the file if it is already up to date
 			##
 			if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \
-				if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \
-					##
-					## If there is already a GIT_VERSION defined,
-					## we just replace it by the new version
-					##
-					sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
-				else \
-					##
-					## Else, we add a GIT_VERSION define
-					## containing our new version.
-					##
-					sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
-				fi; \
+				sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
+				sed -i "s'^#define GIT_SOURCE.*$$'#define GIT_SOURCE 1'" "$${version_h}"; \
 			fi; \
 		fi; \
 	fi)
diff --git a/include/version.h.tmpl b/include/version.h.tmpl
index 2cab733..3ef6905 100644
--- a/include/version.h.tmpl
+++ b/include/version.h.tmpl
@@ -20,10 +20,14 @@
 #ifndef VERSION_H
 #define VERSION_H
 
+
+#define GIT_SOURCE 0
+#define GIT_VERSION ""
+
 /*
  * Define the macro containing the FULL version
  */
-#ifdef GIT_VERSION
+#if GIT_SOURCE
 #define FULL_VERSION "" GIT_VERSION
 #else /* GIT_VERSION */
 #define FULL_VERSION "" VERSION
-- 
2.0.0




More information about the lttng-dev mailing list