bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Make does not throw an error for target without a recipe?


From: Patrick Donnelly
Subject: Re: Make does not throw an error for target without a recipe?
Date: Thu, 26 Jun 2014 17:05:58 -0400

On Thu, Jun 26, 2014 at 5:02 PM, Martin Dorey <address@hidden> 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:
>
> address@hidden:~/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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]