On Tue, Apr 3, 2012 at 9:24 AM, Mark Galeck (CW) <mgal...@brocade.com>wrote:
> Hello, > > I think I understand finally how make works, thanks to Paul's excellent > explanation (being better than the manual's :) ) > > So then this does not work, even with the empty recipe, it won't work, > because make figures out that "foobar.h" could not possibly get updated. I > touch foobar.y, but foobar does not get updated. > > This is a problem, because this represents a common scheme, I think. How > do you deal with this situation Paul (so that it "works"). > > > foobar is a goal that depends on dynamically generated prerequisites such > as subdir/foobar.h. At first build after clean, the prerequisites and the > rules to depend on them do not exist, so we need something else to > "bootstrap" on, that's where target "resources" is needed. resources, > creates the foobar.h dynamically in a subdirectory. The rule for foobar > then, creates an additional dynamically generated dependency (like > explained in the manual) on subdir/foobar.h - this dependency is used in > the next build. I simplified that step for this example, so that rule is > there to begin with, but I am just explaining the "origin" of what I am > trying to do - Paul always asks for that. > > So here is the smallest example, with the origin explained as above: > > > In Makefile: > > > .PHONY: resources > resources: > $(MAKE) -C subdir foobar.h > > subdir/foobar.h: ; # does not matter > > foobar: subdir/foobar.h | resources > touch $@ > > > In subdir/Makefile: > > > foobar.h: foobar.y > touch $@ > > > > So, what is the "canonical" way to handle this common situation? > Mark, Is there a reason that the following won't work? subdir/foobar.h: $(MAKE) -C subdir foobar.h foobar: subdir/foobar.h touch $@ In subdir/Makefile: foobar.h: foobar.y touch $@ Cheers, Lane _______________________________________________ Help-make mailing list Help-make@gnu.org https://lists.gnu.org/mailman/listinfo/help-make