From a492d87510d8bed92f742f3111ca6a4f3a71e58e Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 7 Apr 2010 08:52:09 +0200 Subject: [PATCH] build: keep --version strictly up to date Before this change, in development, gzip's --version output could lag behind reality by a couple deltas or by a "-dirty" suffix. That would lead to spurious failure of the new --version-$VERSION PATH cross-check. * Makefile.am (version.c, version.h): New rules. (BUILT_SOURCES): Set/append. (noinst_LIBRARIES, noinst_libver_a_SOURCES): Define. (gzip_LDADD): Add libver.a. (DISTCLEANFILES): Define. * gzip.c (license): Use Version, not VERSION. --- Makefile.am | 22 +++++++++++++++++++++- gzip.c | 3 ++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 129c453..f9db12b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,6 +18,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ALL_RECURSIVE_TARGETS = +BUILT_SOURCES = SUBDIRS = lib doc . tests ACLOCAL_AMFLAGS = -I m4 @@ -27,6 +28,10 @@ AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) # Tell the linker to omit references to unused shared libraries. AM_LDFLAGS = $(IGNORE_UNUSED_LIBRARIES_CFLAGS) +noinst_LIBRARIES = libver.a +nodist_libver_a_SOURCES = version.c version.h +DISTCLEANFILES = version.c version.h + man_MANS = gunzip.1 gzexe.1 gzip.1 \ zcat.1 zcmp.1 zdiff.1 zforce.1 zgrep.1 zless.1 zmore.1 znew.1 @@ -53,9 +58,24 @@ bin_SCRIPTS = gunzip gzexe zcat zcmp zdiff \ gzip_SOURCES = \ bits.c crypt.c deflate.c gzip.c inflate.c lzw.c \ trees.c unlzh.c unlzw.c unpack.c unzip.c util.c zip.c -gzip_LDADD = lib/libgzip.a +gzip_LDADD = libver.a lib/libgzip.a gzip_LDADD += $(LIB_CLOCK_GETTIME) +BUILT_SOURCES += version.c +version.c: Makefile + $(AM_V_GEN)rm -f $@ + $(AM_V_at)printf '#include \n' > $@t + $(AM_V_at)printf 'char const *Version = "$(PACKAGE_VERSION)";\n' >> $@t + $(AM_V_at)chmod a-w $@t + $(AM_V_at)mv $@t $@ + +BUILT_SOURCES += version.h +version.h: Makefile + $(AM_V_GEN)rm -f $@ + $(AM_V_at)printf 'extern char const *Version;\n' > $@t + $(AM_V_at)chmod a-w $@t + $(AM_V_at)mv $@t $@ + gzip.doc: gzip.1 $(AM_V_GEN)groff -man -Tascii $(srcdir)/gzip.1 | col -b | uniq > $@-t \ && mv $@-t $@ diff --git a/gzip.c b/gzip.c index 41322ec..4762e88 100644 --- a/gzip.c +++ b/gzip.c @@ -73,6 +73,7 @@ static char const *const license_msg[] = { #include "getopt.h" #include "ignore-value.h" #include "stat-time.h" +#include "version.h" /* configuration */ @@ -383,7 +384,7 @@ local void license() { char const *const *p = license_msg; - printf ("%s %s\n", program_name, VERSION); + printf ("%s %s\n", program_name, Version); while (*p) printf ("%s\n", *p++); } -- 2.47.2