diff --git a/Makefile.in b/Makefile.in index faac3b481b..a132527cfa 100644 --- a/Makefile.in +++ b/Makefile.in @@ -182,10 +182,23 @@ iverilog-vpi.ps: $(srcdir)/iverilog-vpi.man iverilog-vpi.pdf: iverilog-vpi.ps ps2pdf iverilog-vpi.ps iverilog-vpi.pdf -version.h: .git/index - git --git-dir $(srcdir)/.git describe \ - | sed -e 's;\(.*\);#define VERSION_TAG "\1";' > $@tmp - diff $@tmp $(srcdir)/$@ > /dev/null 2>&1 || mv $@tmp $(srcdir)/$@ +# For VERSION_TAG in driver/main.c, first try git-describe, then look for a +# version.h file in the source tree (included in snapshots and releases), and +# finally use nothing. +.PHONY: version.h +version.h: + @if test -d $(srcdir)/.git; then \ + echo "Using git-describe for VERSION_TAG"; \ + git --git-dir $(srcdir)/.git describe \ + | sed -e 's;\(.*\);#define VERSION_TAG "\1";' > $@tmp; \ + diff $@tmp $@ > /dev/null 2>&1 || mv $@tmp $@; \ + elif test -r $(srcdir)/$@; then \ + echo "Using $(srcdir)/$@ for VERSION_TAG"; \ + diff $(srcdir)/$@ $@ > /dev/null 2>&1 || cp $(srcdir)/$@ $@; \ + else \ + echo "Using empty VERSION_TAG"; \ + echo '#define VERSION_TAG ""' > $@; \ + fi ifeq (@MING32@,yes) INSTALL_DOC = $(prefix)/iverilog-vpi.pdf $(mandir)/man1/iverilog-vpi.1