dev.mk
perfdir.*
testdir.*
+version.c
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@
.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:
#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"
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':
#ifndef CCACHE_H
#define CCACHE_H
-#define CCACHE_VERSION "3.0pre1"
-
#include "config.h"
#include "mdfour.h"
#define MYNAME "ccache"
#endif
+extern const char CCACHE_VERSION[];
+
/* statistics fields in storage order */
enum stats {
STATS_NONE=0,
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
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
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 \
$(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)