Skip to content

Commit

Permalink
Revise handling of version.h to avoid build problems.
Browse files Browse the repository at this point in the history
A patch to insert the version string from git broke compilation when
the source was not a git repository or when building in a read-only
source tree.  This patch avoids breaking compilation by using a
graceful failure mechanism for generating the version string and does
not write to the source tree.
  • Loading branch information
J Varshney authored and steveicarus committed Apr 12, 2008
1 parent 44767d8 commit bfb3323
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions Makefile.in
Expand Up @@ -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
Expand Down

0 comments on commit bfb3323

Please sign in to comment.