[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:00:47 -0400 |
Hi Paul,
On Thu, Jun 26, 2014 at 4:48 PM, Paul Smith <address@hidden> wrote:
>> File 'foo' does not exist.
>> Looking for an implicit rule for 'foo'.
>> [...]
>> No implicit rule found for 'foo'.
>> Considering target file '/etc/passwd'.
>> Looking for an implicit rule for '/etc/passwd'.
>> [...]
>> No implicit rule found for '/etc/passwd'.
>> Finished prerequisites of target file '/etc/passwd'.
>> No need to remake target '/etc/passwd'.
>> Finished prerequisites of target file 'foo'.
>> Must remake target 'foo'.
>> Successfully remade target file 'foo'.
>> make: Nothing to be done for 'foo'.
>>
>> So the interesting thing here is that Make decides it needs to remake
>> `foo' but it doesn't do anything (based on strace output). Then it
>> decides it was successful?
>
> See:
> http://www.gnu.org/software/make/manual/html_node/Force-Targets.html
I read that part of the manual, my interpretation of
"If a rule has no prerequisites or recipe, and the target of the rule
is a nonexistent file, then make imagines this target to have been
updated whenever its rule is run."
only applies if a rule has no prerequisites AND no recipe, a special
case of FORCE or "empty" targets like a not-yet-written uninstall
target. I guess I'm confused by the wording there.
>> That doesn't make any sense... How do I get Make to fail if it can't
>> make the target?
>
> You have to give make a recipe to run. Then if the recipe fails (exits
> with a non-zero error code), make will fail.
This is a little inconvenient when you're relying on implicit rules. e.g.
%.o: %.c
cc -o $@ $<
%: %.o
ld $@ $^
foo: bar.a
Even if foo.c is missing, Make still succeeds. This is actually what
I'm dealing with and I'd like a method of catching a mistake like a
missing .c file in the future.
--
Patrick Donnelly
Re: Make does not throw an error for target without a recipe?, Paul Smith, 2014/06/26
- Re: Make does not throw an error for target without a recipe?,
Patrick Donnelly <=
Re: Make does not throw an error for target without a recipe?, Paul Smith, 2014/06/26