More reliably handle make install from read-only directory

commonly, the make install is run in a compiled directory by a
different user (i.e. an administrator) that doesn't necessarily
have write access to the build directory. This patch fixes it so
that the test that the version.h is up to date doesn't need to
write a temporary file in the build directory.

It also makes sure that if there is a real need to update the
verion.h, and it is not writable, then properly fail the build.
This commit is contained in:
Stephen Williams 2008-04-17 20:33:39 -07:00
parent 6eb9825ab7
commit 844447b995
1 changed files with 3 additions and 3 deletions

View File

@ -189,9 +189,9 @@ iverilog-vpi.pdf: iverilog-vpi.ps
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 $@; \
tmp=`git --git-dir $(srcdir)/.git describe \
| sed -e 's;\(.*\);#define VERSION_TAG "\1";'`; \
echo "$$tmp" | diff - $@ > /dev/null 2>&1 || echo "$$tmp" > $@ || exit 1; \
elif test -r $(srcdir)/$@; then \
echo "Using $(srcdir)/$@ for VERSION_TAG"; \
diff $(srcdir)/$@ $@ > /dev/null 2>&1 || cp $(srcdir)/$@ $@; \