Include git revision info in version number

This commit is contained in:
Joel Rosdahl 2010-06-09 21:10:03 +02:00
parent 407db453ba
commit 342dae0d59
6 changed files with 19 additions and 9 deletions

1
.gitignore vendored
View File

@ -18,3 +18,4 @@ configure
dev.mk
perfdir.*
testdir.*
version.c

View File

@ -17,7 +17,7 @@ EXEEXT = @EXEEXT@
libs = @LIBS@ -lm
sources = \
ccache.c mdfour.c hash.c execute.c util.c args.c stats.c \
ccache.c mdfour.c hash.c execute.c util.c args.c stats.c version.c \
cleanup.c snprintf.c unify.c manifest.c hashtable.c hashtable_itr.c \
murmurhashneutral2.c hashutil.c getopt_long.c
all_sources = $(sources) @extra_sources@
@ -68,7 +68,7 @@ check: test
.PHONY: distclean
distclean: clean
rm -rf Makefile dev.mk config.h config.log config.status .deps
rm -rf Makefile dev.mk config.h config.log config.status .deps version.c
.PHONY: installcheck
installcheck:

View File

@ -38,7 +38,7 @@
#include <unistd.h>
static const char VERSION_TEXT[] =
"ccache version " CCACHE_VERSION "\n"
"ccache version %s\n"
"\n"
"Copyright (C) 2002-2007 Andrew Tridgell\n"
"Copyright (C) 2009-2010 Joel Rosdahl\n"
@ -1998,7 +1998,7 @@ static int ccache_main(int argc, char *argv[])
while ((c = getopt_long(argc, argv, "hszcCF:M:V", long_options, &option_index)) != -1) {
switch (c) {
case 'V':
fputs(VERSION_TEXT, stdout);
fprintf(stdout, VERSION_TEXT, CCACHE_VERSION);
exit(0);
case 'h':

View File

@ -1,8 +1,6 @@
#ifndef CCACHE_H
#define CCACHE_H
#define CCACHE_VERSION "3.0pre1"
#include "config.h"
#include "mdfour.h"
@ -23,6 +21,8 @@
#define MYNAME "ccache"
#endif
extern const char CCACHE_VERSION[];
/* statistics fields in storage order */
enum stats {
STATS_NONE=0,

View File

@ -290,6 +290,9 @@ cat config.h >>config.h.tmp
echo '#endif' >>config.h.tmp
mv config.h.tmp config.h
version=`(git describe --dirty 2>/dev/null || echo vunknown) | cut -b 2-`
echo "const char CCACHE_VERSION@<:@@:>@ = \"$version\";" >version.c
mkdir -p .deps
if test x$use_bundled_zlib = xyes; then

View File

@ -7,8 +7,9 @@ ASCIIDOC = asciidoc
XSLTPROC = xsltproc
MANPAGE_XSL = /etc/asciidoc/docbook-xsl/manpage.xsl
version = $(shell sed -n 's/^\#define CCACHE_VERSION "\(.*\)"/\1/p' \
$(srcdir)/ccache.h)
version := \
$(shell (git describe --dirty 2>/dev/null || echo vunknown) | cut -b 2-)
dist_dir = ccache-$(version)
dist_archive_tar_bz2 = ccache-$(version).tar.bz2
dist_archive_tar_gz = ccache-$(version).tar.gz
@ -17,7 +18,7 @@ generated_docs = ccache.1 INSTALL.html manual.html NEWS.html README.html
built_dist_files = $(generated_docs)
files_to_clean += $(dist_archive_tar_bz2) $(dist_archive_tar_gz) .deps/*
files_to_clean += $(built_dist_files)
files_to_clean += $(built_dist_files) version.c
source_dist_files = \
$(sources) $(headers) zlib/*.c zlib/*.h \
@ -27,6 +28,11 @@ dist_files = \
$(addprefix $(srcdir)/, $(source_dist_files)) \
$(built_dist_files)
ifneq ($(shell sed 's/.*"\(.*\)".*/\1/' version.c 2>/dev/null),$(version))
$(shell echo 'const char CCACHE_VERSION[] = "$(version)";' >version.c)
endif
version.o: version.c
.PHONY: dist
dist: $(dist_archive_tar_bz2) $(dist_archive_tar_gz)