Maybe that's why my code always uses https://www.gnu.org/software/make/manual/make.html#Static-Pattern:
martind@swiftboat:~/tmp/batrick-2014-06-26$ cat test.mk .SUFFIXES: TARGETS = foo $(addsuffix .o,$(TARGETS)): %.o: %.c; cc -o $@ $< $(TARGETS): %: %.o; ld -o $@ $^ %::; @echo no recipe for $@ 1>&2 && exit 1 martind@swiftboat:~/tmp/batrick-2014-06-26$ make -f test.mk foo no recipe for foo.c make: *** [foo.c] Error 1 martind@swiftboat:~/tmp/batrick-2014-06-26$ echo 'int main() {}' > foo.c martind@swiftboat:~/tmp/batrick-2014-06-26$ make -f test.mk foo cc -o foo.o foo.c ld -o foo foo.o ld: error in foo.o(.eh_frame); no .eh_frame_hdr table will be created. martind@swiftboat:~/tmp/batrick-2014-06-26$ make -f test.mk foo make: `foo' is up to date. martind@swiftboat:~/tmp/batrick-2014-06-26$ -----Original Message----- From: Patrick Donnelly [mailto:batr...@batbytes.com] Sent: Thursday, June 26, 2014 14:06 To: Martin Dorey Cc: bug-make@gnu.org Subject: Re: Make does not throw an error for target without a recipe? On Thu, Jun 26, 2014 at 5:02 PM, Martin Dorey <martin.do...@hds.com> wrote: >> I'm afraid none of this exercise is helpful for solving the problem > > Perhaps putting my point in different words will better convey it: you could > simply adjust your expectation, to regard this as a failure: > > make: Nothing to be done for `foo'. > > But... > >> To put it concisely: how do I get Make to *fail* if it cannot >> create one of the targets? > > ... if you're really insistent on "get Make to return a non-zero exit status > if I haven't told it how to create one of the targets" then, per > http://www.gnu.org/software/make/manual/make.html#Last-Resort, you could do: > > martind@swiftboat:~/tmp/batrick-2014-06-26$ cat test.mk > TARGETS = foo > > all: $(TARGETS) > > $(TARGETS): /etc/passwd > > %::; @echo no recipe for $@ 1>&2 && exit 1 Is there a way to get last-resort rules to play nicely with e.g.: %.o: %.c cc -o $@ $< %: %.o ld -o $@ $^ ... The last-resort rule is preferred over the the %.c -> %.o -> % chain of rules. -- Patrick Donnelly _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make