summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-04-19 06:19:52 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-04-19 06:19:52 -0700
commit35ae145926959146adce3d19ec844c2584a05ee4 (patch)
tree3332c8cae624e6693090f55c380a1a435379ddcb
parent97e3ec94410e02ca28174fc55aa7d781632e5b34 (diff)
downloadtxr-35ae145926959146adce3d19ec844c2584a05ee4.tar.gz
txr-35ae145926959146adce3d19ec844c2584a05ee4.tar.bz2
txr-35ae145926959146adce3d19ec844c2584a05ee4.zip
Makefile: detect when y.tab.h doesn't change.
When we touch the parser.y file, yacc regenerates y.tab.h. Then everything which depends on that is rebuilt. However, this is not necessary if the parser.y change doesn't actually modify the contents of y.tab.h. A build system based on file hashes wouldn't have this problem, but make works strictly with modification timestamps. * Makefile (y.tab.c): Preserve the old y.tab.h, if it exists, as y.tab.h.old. Then if the new y.tab.h is exactly the same according to cmp, restore the old y.tab.h in its place. (clean): Remove y.tab.h.old.
-rw-r--r--Makefile5
1 files changed, 5 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 7bf1d3db..b1b2db11 100644
--- a/Makefile
+++ b/Makefile
@@ -239,11 +239,15 @@ y.tab.h: y.tab.c
y.tab.c: $(top_srcdir)parser.y
$(call ABBREV,YACC)
+ $(V)if [ -e y.tab.h ]; then mv y.tab.h y.tab.h.old ; fi
$(V)rm -f y.tab.c
$(V)if $(TXR_YACC) -v -d $< ; then \
chmod a-w y.tab.c ; \
sed -e '/yyparse/d' < y.tab.h > y.tab.h.tmp && \
mv y.tab.h.tmp y.tab.h ; \
+ if cmp -s y.tab.h y.tab.h.old ; then \
+ mv y.tab.h.old y.tab.h ; \
+ fi ; \
else \
rm y.tab.c ; \
false ; \
@@ -285,6 +289,7 @@ rebuild: clean repatch $(PROG)
clean: conftest.clean tests.clean
rm -f $(PROG)$(EXE) $(PROG)-dbg$(EXE) y.tab.c lex.yy.c y.tab.h y.output
+ rm -f y.tab.h.old
rm -f $(PROG)-win$(EXE) $(PROG)-win-dbg$(EXE)
rm -rf opt dbg $(EXTRA_OBJS-y)