Re: make -- generate missing include files
Robert Clausecker <[email protected]>
| Newsgroups | gmane.os.netbsd.devel.toolchain |
|---|---|
| Message-ID | <[email protected]> |
Hi Tobias, Am Sun, Nov 06, 2022 at 06:02:23PM +0100 schrieb Tobias Nygren: > > What does "include file is not found" mean? Do you mean "foo.h is a > > dependency of bar.c, but foo.h does not exist, and there is no rule to > > make foo.h?" If so, why aren't there rules? If not, please clarify. > > The feature that is suggested is to make this work: > > ---8<--- > on-the-fly.mk: > printf ".PHONY: greet\ngreet:\n\t@echo Hello, world\n" > $@ > > .include "on-the-fly.mk" > ---8<--- > $ make greet > > This works with GNU make if you change the include line to > "include on-the-fly.mk". Correct, that's exactly the feature. > Is this feature supported by any BSD derived make? At least it doesn't > seem to work on FreeBSD. It looks difficult to implement because > parsing and target execution happen in separate stages ... The way I believe this is implemented is that when a missing include file is encountered, GNU make stops parsing and pretends the makefile ends right there. Then, make tries to build the missing include file as a target. If that succeeds, the parsing process is restarted from the top. Some logic is added to ensure that each iteration of a missing include makes progress, preventing infinite loops. Other implementations are thinkable, but this one seems reasonably straightforward: just add a mechanism to abort the parsing and substitute the target given on the command line for the missing include file and add a flag to tell make "what you just built is a missing include file; start again with the real target after it has been built." > Kind regards, > -Tobias Yours, Robert Clausecker -- () ascii ribbon campaign - for an 8-bit clean world /\ - against html email - against proprietary attachments