From 3d9c2e72fb16e4a71985efac1fd5327ff9eb4dba Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 25 Jan 2008 11:49:16 +0100 Subject: [PATCH] Compile executable with correct version number Updates awesome-version.h every time the version number has actually changed. The normal C header deps will then trigger the appropriate rebuilds. Signed-off-by: Julien Danjou --- Makefile.am | 12 ++++++++++++ awesome.c | 3 ++- configure.ac | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index f0c80c9f..2800c4cf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -82,6 +82,18 @@ widgetgen.h: widget.h @echo "generating widgetgen.h from widget.h" $(top_srcdir)/build-utils/widgetgen.sh "$(top_srcdir)" > widgetgen.h +CLEANFILES += awesome-version.h +BUILT_SOURCES += awesome-version.h.stamp +awesome-version.h.stamp: + @current_ver=`$(SHELL) $(top_srcdir)/build-utils/package-version $(top_srcdir) version-stamp`; \ + { echo '#ifndef AWESOME_VERSION_H'; \ + echo "#define AWESOME_VERSION \"$${current_ver}\""; \ + echo "#endif"; } > "awesome-version.h.new" + @if test -f "awesome-version.h" \ + && cmp "awesome-version.h.new" "awesome-version.h"; then :; \ + else cat "awesome-version.h.new" > "awesome-version.h"; fi; \ + rm -f "awesome-version.h.new" + if USING_GCC # If you are using gcc, and want to deactivate this default set of # compile flags, run make with AWESOME_CFLAGS="". diff --git a/awesome.c b/awesome.c index 24d62a4f..91d4435c 100644 --- a/awesome.c +++ b/awesome.c @@ -38,6 +38,7 @@ #include #include +#include "awesome-version.h" #include "awesome.h" #include "event.h" #include "layout.h" @@ -219,7 +220,7 @@ main(int argc, char *argv[]) args_ok = 0; if(!a_strcmp("-v", argv[1]) || !a_strcmp("--version", argv[1])) { - printf("awesome version " VERSION " (" RELEASE ")\ncompiled"); + printf("awesome version " AWESOME_VERSION " (" AWESOME_RELEASE ")\ncompiled"); #if defined(__DATE__) && defined(__TIME__) printf(" at " __DATE__ " " __TIME__); #endif diff --git a/configure.ac b/configure.ac index 0fe4e898..8500b44b 100644 --- a/configure.ac +++ b/configure.ac @@ -24,7 +24,7 @@ std-options subdir-objects ]) -AC_DEFINE_UNQUOTED([RELEASE], ["Productivity Breaker"], [release code name]) +AC_DEFINE_UNQUOTED([AWESOME_RELEASE], ["Productivity Breaker"], [release code name]) AC_MSG_CHECKING([package version according to autoconf]) AC_MSG_RESULT([${PACKAGE_VERSION}])