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

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


Signed-off-by: Raphaël Beamonte <raphael.beamonte at gmail.com>
---
 src/bin/lttng/Makefile.am        |    6 +++++-
 src/bin/lttng/commands/version.c |    3 +++
 src/bin/lttng/lttng.c            |    6 +++++-
 3 files changed, 13 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/commands/version.c b/src/bin/lttng/commands/version.c
index 7f69de3..6b315c5 100644
--- a/src/bin/lttng/commands/version.c
+++ b/src/bin/lttng/commands/version.c
@@ -79,6 +79,9 @@ int cmd_version(int argc, const char **argv)
 	}
 
 	MSG("lttng version " VERSION " - " VERSION_NAME);
+#ifdef GIT_VERSION
+	MSG("Git version: " GIT_VERSION);
+#endif
 	MSG("\n" VERSION_DESCRIPTION "\n");
 	MSG("Web site: http://lttng.org");
 	MSG("\nlttng is free software and under the GPL license and part LGPL");
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