|
From: | tom honermann |
Subject: | Re: Static multiple target rules |
Date: | Mon, 29 Mar 2010 19:03:47 -0700 |
User-agent: | Thunderbird 2.0.0.24 (Windows/20100228) |
This isn't working as well as I had at first thought. For example, updating grammar.y doesn't always result in y.tab.o getting rebuilt. This can be reproduced consistently in parallel make invocations:.INTERMEDIATE: yacc.ts all: y.tab.h y.tab.c y.output y.tab.o clean: rm -f y.tab.h y.tab.c y.output y.tab.o grammar.y: @touch $@ yacc.ts: grammar.y @echo "Running yacc..." @sleep 1 @touch y.tab.h y.tab.c y.output y.tab.h y.tab.c y.output: yacc.ts y.tab.o: y.tab.c y.tab.h @echo "Compiling y.tab.c..." @sleep 1 @touch $@The only problem I could find with this approach is that downstream targets might not get rebuilt as expected. For example, run gmake once to build everything, then remove y.output and run gmake again. Using make 3.81 on Linux, y.output is rebuilt which also rebuilds y.tab.c and y.tab.h, but y.tab.o is not rebuilt (as might be expected since y.tab.h and y.tab.c were regenerated). This makes sense because gmake has no way of knowing that rebuilding y.output would also regenerate y.tab.h and y.tab.c. A full solution for static multiple target rules would recognize that these files had been regenerated and would also rebuild y.tab.o. But, I think this is good enough for my use cases.
rtdc60007stdb:$ gmake clean rm -f y.tab.h y.tab.c y.output y.tab.o rtdc60007stdb:$ gmake Running yacc... Compiling y.tab.c... rtdc60007stdb:$ touch grammar.y rtdc60007stdb:$ gmake Running yacc... Compiling y.tab.c... rtdc60007stdb:$ gmake gmake: Nothing to be done for `all'. rtdc60007stdb:$ gmake clean rm -f y.tab.h y.tab.c y.output y.tab.o rtdc60007stdb:$ gmake -j Running yacc... Compiling y.tab.c... rtdc60007stdb:$ touch grammar.y rtdc60007stdb:$ gmake -j Running yacc... rtdc60007stdb:$ gmake -j Compiling y.tab.c... rtdc60007stdb:$ gmake -j gmake: Nothing to be done for `all'.Note that the second run using '-j' required an extra 'gmake' invocation before everything was up to date. Bummer.
Tom.
[Prev in Thread] | Current Thread | [Next in Thread] |