[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: no rule to build included makefile but make does not fail
From: |
Edward Welbourne |
Subject: |
Re: no rule to build included makefile but make does not fail |
Date: |
Tue, 4 Dec 2018 11:00:36 +0000 |
pacalet (4 December 2018 08:38) wrote:
> Not sure it is a bug but I think it deserves some attention. Here is an
> MCVE:
>
> ```make
> .PHONY: all clean
>
> all:;
>
> include a.mk
>
> a.mk: b
>
> b:
> @touch $@
> @printf '$$(info a.mk included)' > a.mk
>
> clean:
> @rm -f a.mk b
> ```
>
> First make invocation:
>
> ```bash
> $ make
> make: Nothing to be done for 'all'.
> ```
>
> Second make invocation:
>
> ```bash
> make
> a.mk included
> make: Nothing to be done for 'all'.
> ```
>
> So we are in a situation where:
>
> 1. a makefile is included with the `include` directive (no `-include`),
> 2. the included makefile is not found,
> 3. make finds no rule to produce it and decides not to include it,
Doesn't it ? It depends on b, albeit with an empty rule for what to do
when b changes. So exercising b's rule and then a.mk's empty rule is
what I expect it to do. Indeed, omitting your @ from the start of b's
rule commands, I see b is built on the first pass and a.mk is created.
I'm then puzzled that the first run doesn't report that it included
a.mk, though ...
> 4. make executes a recipe for a prerequisite of the included makefile
> that incidentally also produces the included makefile,
> 5. as the included makefile is finally found make does not fail... but
> it does not read the included makefile.
>
> This could be considered as contradictory with the documentation:
>> After all makefiles have been checked, if any have
>> actually been changed, make starts with a clean
>> slate and reads all the makefiles over again.
> Shouldn't make either fail or include?
Well, it shouldn't fail, since it does create a.mk; however, when I
change the redirect > a.mk on b's second command to > b.mk, it still
succeeds, despite there being no a.mk; presumably this is because a.mk
has a rule, that succeeds, so it's happy; but I still don't see why make
doesn't get upset about the unsatisfied include.
Let's see what Paul says when the other side of the Atlantic wakes up,
Eddy.