[master] cf78444 Rename svn_version.c to vcs_version.c, simplify generation

Tollef Fog Heen tfheen at varnish-cache.org
Tue Feb 22 11:46:59 CET 2011


commit cf7844436784aa61763a702f3dfef8a6bf934f75
Author: Tollef Fog Heen <tfheen at varnish-software.com>
Date:   Tue Feb 22 11:44:14 2011 +0100

    Rename svn_version.c to vcs_version.c, simplify generation
    
    Fix up the generation of vcs_version.c with the assumption that if you
    have a .git directory at the top, you have git installed.  Drop logic
    for handling svn checkouts.

diff --git a/include/libvarnish.h b/include/libvarnish.h
index f21b1db..0493a2e 100644
--- a/include/libvarnish.h
+++ b/include/libvarnish.h
@@ -100,7 +100,7 @@ void varnish_version(const char *);
 int vtmpfile(char *);
 char *vreadfile(const char *pfx, const char *fn);
 
-const char* svn_version(void);
+const char* vcs_version(void);
 
 /* Safe printf into a fixed-size buffer */
 #define bprintf(buf, fmt, ...)						\
diff --git a/lib/libvarnish/Makefile.am b/lib/libvarnish/Makefile.am
index 9d1056c..3a01d76 100644
--- a/lib/libvarnish/Makefile.am
+++ b/lib/libvarnish/Makefile.am
@@ -1,5 +1,3 @@
-# $Id$
-
 INCLUDES = -I$(top_srcdir)/include @PCRE_CFLAGS@
 
 lib_LTLIBRARIES = libvarnish.la
@@ -16,7 +14,7 @@ libvarnish_la_SOURCES = \
 	cli_serve.c \
 	flopen.c \
 	num.c \
-	svn_version.c \
+	vcs_version.c \
 	time.c \
 	tcp.c \
 	vct.c \
@@ -35,12 +33,12 @@ libvarnish_la_SOURCES = \
 libvarnish_la_CFLAGS = -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"'
 libvarnish_la_LIBADD = ${RT_LIBS} ${NET_LIBS} ${LIBM} @PCRE_LIBS@
 
-DISTCLEANFILES = svn_version.c
-svn_version.c: FORCE
-	V="$$(sh -c "git log -n 1 --pretty=format:%h" 2>/dev/null || LANG=C svnversion -n $(top_srcdir))" \
-	H="$$(head -n 1 svn_version.c 2>/dev/null || true)"; \
-	[ "$$V" = "exported" ] && [ -e svn_version.c ] && exit 0 ; \
-	if [ "/* $$V */" != "$$H" ]; then \
+DISTCLEANFILES = vcs_version.c
+vcs_version.c: FORCE
+	if [ -d "$(top_srcdir)/.git" ]; then \
+		V="$$(git describe --always)" \
+		H="$$(head -n 1 vcs_version.c 2>/dev/null || true)"; \
+		if [ "/* $$V */" != "$$H" ]; then \
 		( \
 		  echo "/* $$V */" ;\
 		  echo '/*' ;\
@@ -51,12 +49,13 @@ svn_version.c: FORCE
 		  echo ' */' ;\
 		  echo '' ;\
 		  echo "#include <libvarnish.h>" ;\
-		  echo "const char* svn_version(void)" ;\
+		  echo "const char* vcs_version(void)" ;\
 		  echo "{" ;\
-		  echo "	const char* SVN_Version = \"$$V\";" ;\
-		  echo "	return SVN_Version;" ;\
+		  echo "	const char* VCS_Version = \"$$V\";" ;\
+		  echo "	return VCS_Version;" ;\
 		  echo "}" ;\
-		) > svn_version.c ; \
+		) > vcs_version.c ; \
+		fi \
 	fi
 FORCE:
 
diff --git a/lib/libvarnish/version.c b/lib/libvarnish/version.c
index 5df094a..e5472a1 100644
--- a/lib/libvarnish/version.c
+++ b/lib/libvarnish/version.c
@@ -41,8 +41,8 @@ SVNID("$Id$")
 void
 varnish_version(const char *progname)
 {
-	fprintf(stderr, "%s (%s-%s SVN %s)\n", progname,
-		PACKAGE_TARNAME, PACKAGE_VERSION, svn_version());
+	fprintf(stderr, "%s (%s-%s revision %s)\n", progname,
+		PACKAGE_TARNAME, PACKAGE_VERSION, vcs_version());
 	fprintf(stderr,
 	    "Copyright (c) 2006-2009 Linpro AS / Verdens Gang AS\n");
 }
diff --git a/lib/libvarnishapi/Makefile.am b/lib/libvarnishapi/Makefile.am
index 9aa49ce..5879f74 100644
--- a/lib/libvarnishapi/Makefile.am
+++ b/lib/libvarnishapi/Makefile.am
@@ -12,7 +12,7 @@ libvarnishapi_la_SOURCES = \
 	\
 	../libvarnish/assert.c \
 	../libvarnish/argv.c \
-	../libvarnish/svn_version.c \
+	../libvarnish/vcs_version.c \
 	../libvarnish/version.c \
 	../libvarnish/vin.c \
 	../libvarnish/vmb.c \



More information about the varnish-commit mailing list