summaryrefslogtreecommitdiff
path: root/compiler/cpp/Makefile.am
diff options
context:
space:
mode:
authorDavid Reiss <dreiss@apache.org>2008-06-30 20:24:24 +0000
committerDavid Reiss <dreiss@apache.org>2008-06-30 20:24:24 +0000
commitdd08f6d5a5bbc39b4ab30a3cb6996b39f7605f06 (patch)
treef18ff8c85f02430a8c8340d2c8a92efdf9fc0e93 /compiler/cpp/Makefile.am
parent6b082755f0cba0bb8469f5f262f01a4defce348d (diff)
downloadthrift-dd08f6d5a5bbc39b4ab30a3cb6996b39f7605f06.tar.gz
(THRIFT-40) Add -version switch to the compiler to show the Thrift version
The version is determined by configure.ac. After this version is shown the revision. For subversion, it is simply the current revision as given by `svnversion`. For git, the latest svn revision that HEAD includes is shown, followed by the offset of HEAD from that commit, followed by a truncated sha1 for HEAD. If the offset is 0, the offset and sha1 are omitted. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@672900 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'compiler/cpp/Makefile.am')
-rw-r--r--compiler/cpp/Makefile.am29
1 files changed, 29 insertions, 0 deletions
diff --git a/compiler/cpp/Makefile.am b/compiler/cpp/Makefile.am
index d7c708561..2dcdb5e1d 100644
--- a/compiler/cpp/Makefile.am
+++ b/compiler/cpp/Makefile.am
@@ -1,4 +1,5 @@
AM_YFLAGS = -d
+BUILT_SOURCES =
bin_PROGRAMS = thrift
@@ -80,3 +81,31 @@ EXTRA_DIST = README
clean-local:
$(RM) thriftl.cc thrifty.cc thrifty.h
+
+src/main.cc: version.h
+
+# Adding this to BUILT_SOURCES will cause version.h to be
+# regenerated on every "make all" or "make check", which is
+# necessary because it changes whenever we "svn up" or similar.
+# Ideally, we would like this to be regenerated whenever the
+# compiler is rebuilt, but every way we could think of to do
+# that caused unnecessary rebuilds of the compiler.
+BUILT_SOURCES += regen_version_h
+
+THRIFT_VERSION=$(shell /bin/sh $(top_srcdir)/print_version.sh -v)
+THRIFT_REVISION=$(shell /bin/sh $(top_srcdir)/print_version.sh -r)
+
+regen_version_h:
+ @echo -n "Regenerating version.h... "
+ @TMPFILE=`mktemp ./version_h.tmp_XXXXXX` ; \
+ echo "// AUTOGENERATED, DO NOT EDIT" > $$TMPFILE ; \
+ echo '#define THRIFT_VERSION "$(THRIFT_VERSION)"\n' >> $$TMPFILE ; \
+ echo '#define THRIFT_REVISION "$(THRIFT_REVISION)"\n' >> $$TMPFILE ; \
+ if cmp $$TMPFILE version.h >/dev/null ; \
+ then \
+ rm -f $$TMPFILE ; \
+ echo "No changes." ; \
+ else \
+ mv $$TMPFILE version.h ; \
+ echo "Updated." ; \
+ fi