Revise handling of version.h to avoid build problems.
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.
This commit is contained in:
parent
44767d8f70
commit
bfb33230aa
21
Makefile.in
21
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue