From ceb6ba5100c73f6a2b39475c89f3317d64fc9b48 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Tue, 29 Jul 2014 11:28:51 -0400 Subject: [PATCH] Add --disable-git-version to configure By default, GIT_SOURCE variable is defined to 1. The disable option makes the configure to NOT define it. This way, anyone not wanting the git version like for instance packager building from the git repository, it can be used to remove it. Signed-off-by: David Goulet --- configure.ac | 9 +++++++++ include/Makefile.am | 4 ++-- include/version.h.tmpl | 6 ++++++ src/bin/lttng/commands/version.c | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 21cfab070..bd49df7ba 100644 --- a/configure.ac +++ b/configure.ac @@ -259,6 +259,15 @@ AC_CHECK_LIB([c], [open_memstream], ] ) +AC_ARG_ENABLE([git-version], + [AC_HELP_STRING([--disable-git-version], + [Do not use the git version for the build])], + [disable_git_version=yes], [disable_git_version=no] +) +if test "x${disable_git_version:-no}" = xno; then + AC_DEFINE_UNQUOTED([GIT_SOURCE], 1, [Disable git version.]) +fi + # For Python # SWIG version needed or newer: swig_version=2.0.0 diff --git a/include/Makefile.am b/include/Makefile.am index 89b084d01..d2061f1e0 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -46,8 +46,8 @@ version.h: ## as the one currently in the file (if there is one), as we ## 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 \ - sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ + if [ $$(grep -cE "^#define GIT_VERSION_SED \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \ + sed -i "s'^#define GIT_VERSION_SED.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ fi; \ fi; \ fi) diff --git a/include/version.h.tmpl b/include/version.h.tmpl index 861a477bc..e2ce531d4 100644 --- a/include/version.h.tmpl +++ b/include/version.h.tmpl @@ -20,6 +20,12 @@ #ifndef VERSION_H #define VERSION_H +#ifdef GIT_SOURCE +#define GIT_VERSION_PREFIX " - " +#define GIT_VERSION_SED "" +#else +#define GIT_VERSION_PREFIX "" #define GIT_VERSION "" +#endif #endif /* VERSION_H */ diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c index 768ebb5e1..4e46d724f 100644 --- a/src/bin/lttng/commands/version.c +++ b/src/bin/lttng/commands/version.c @@ -164,7 +164,7 @@ int cmd_version(int argc, const char **argv) if (lttng_opt_mi) { ret = print_mi(); } else { - MSG("lttng version " VERSION " - " VERSION_NAME " - " GIT_VERSION); + MSG("lttng version " VERSION " - " VERSION_NAME GIT_VERSION_PREFIX GIT_VERSION); MSG("\n" VERSION_DESCRIPTION "\n"); MSG("Web site: http://lttng.org"); MSG("\n%s", lttng_license); -- 2.34.1