Properly update revision.h.
authorChristoph Mallon <christoph.mallon@gmx.de>
Tue, 11 Oct 2011 07:51:34 +0000 (09:51 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Tue, 11 Oct 2011 08:06:53 +0000 (10:06 +0200)
revision.h was not updated anymore once it existed.

Makefile

index c5adc5b..635f84a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -82,17 +82,13 @@ config.h:
 %.h:
        @true
 
-REVISION ?= $(shell git describe --always --dirty --match '')
-
-revision.h:
-       @echo "===> GEN $@"
-       @echo "#define cparser_REVISION \"$(REVISION)\"" > .revision.h
-       $(Q)if diff -Nq .revision.h revision.h > /dev/null; then \
-             rm .revision.h;                                    \
-           else                                                 \
-             echo "===> UPDATING revision.h";                   \
-             mv .revision.h revision.h;                         \
-           fi
+REVISION ?= $(shell git describe --abbrev=40 --always --dirty --match '')
+
+# Update revision.h if necessary
+UNUSED := $(shell \
+       REV="\#define cparser_REVISION \"$(REVISION)\""; \
+       echo "$$REV" | cmp -s - revision.h 2> /dev/null || echo "$$REV" > revision.h \
+)
 
 .depend: config.h revision.h $(SOURCES)
        @echo "===> DEPEND"