[lttng-dev] [lttng-tools PATCH] Add a git version line in LTTng versions compiled from git sources.

Raphaël Beamonte raphael.beamonte at gmail.com
Tue Mar 12 22:07:50 EDT 2013


Signed-off-by: Raphaël Beamonte <raphael.beamonte at gmail.com>
---
 src/bin/lttng/Makefile.am |    6 +++++-
 src/bin/lttng/lttng.c     |    6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/bin/lttng/Makefile.am b/src/bin/lttng/Makefile.am
index 21eebab..1b1219b 100644
--- a/src/bin/lttng/Makefile.am
+++ b/src/bin/lttng/Makefile.am
@@ -1,5 +1,9 @@
+git_version_string=$$(git describe --long --all 2>/dev/null)
+git_version=$$(test -n "${git_version_string}" && echo "-DGIT_VERSION=\"${git_version_string}\"")
+
 AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src \
-			  -DINSTALL_BIN_PATH=\""$(bindir)"\"
+			  -DINSTALL_BIN_PATH=\""$(bindir)"\" \
+			  ${git_version}
 
 bin_PROGRAMS = lttng
 
diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c
index 8562144..28f8fec 100644
--- a/src/bin/lttng/lttng.c
+++ b/src/bin/lttng/lttng.c
@@ -81,7 +81,11 @@ static struct cmd_struct commands[] =  {
 
 static void usage(FILE *ofp)
 {
-	fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n");
+	fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n");
+#ifdef GIT_VERSION
+	fprintf(ofp, "Git version: " GIT_VERSION"\n");
+#endif
+	fprintf(ofp, "\n");
 	fprintf(ofp, "usage: lttng [OPTIONS] <COMMAND> [<ARGS>]\n");
 	fprintf(ofp, "\n");
 	fprintf(ofp, "Options:\n");
-- 
1.7.10.4




More information about the lttng-dev mailing list