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 <julien@danjou.info>
This commit is contained in:
Hans Ulrich Niedermann 2008-01-25 11:49:16 +01:00 committed by Julien Danjou
parent e719d6d0b6
commit 3d9c2e72fb
3 changed files with 15 additions and 2 deletions

View File

@ -82,6 +82,18 @@ widgetgen.h: widget.h
@echo "generating widgetgen.h from widget.h" @echo "generating widgetgen.h from widget.h"
$(top_srcdir)/build-utils/widgetgen.sh "$(top_srcdir)" > widgetgen.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 USING_GCC
# If you are using gcc, and want to deactivate this default set of # If you are using gcc, and want to deactivate this default set of
# compile flags, run make with AWESOME_CFLAGS="". # compile flags, run make with AWESOME_CFLAGS="".

View File

@ -38,6 +38,7 @@
#include <X11/extensions/shape.h> #include <X11/extensions/shape.h>
#include <X11/extensions/Xrandr.h> #include <X11/extensions/Xrandr.h>
#include "awesome-version.h"
#include "awesome.h" #include "awesome.h"
#include "event.h" #include "event.h"
#include "layout.h" #include "layout.h"
@ -219,7 +220,7 @@ main(int argc, char *argv[])
args_ok = 0; args_ok = 0;
if(!a_strcmp("-v", argv[1]) || !a_strcmp("--version", argv[1])) 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__) #if defined(__DATE__) && defined(__TIME__)
printf(" at " __DATE__ " " __TIME__); printf(" at " __DATE__ " " __TIME__);
#endif #endif

View File

@ -24,7 +24,7 @@ std-options
subdir-objects 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_CHECKING([package version according to autoconf])
AC_MSG_RESULT([${PACKAGE_VERSION}]) AC_MSG_RESULT([${PACKAGE_VERSION}])