[Top][All Lists]

[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: Renaud Pacalet
Subject: Re: no rule to build included makefile but make does not fail
Date: Tue, 4 Dec 2018 12:10:39 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0

On 04/12/2018 12:00, Edward Welbourne wrote:
> 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 ...

Well, to be more accurate, make finds no rule with target `a.mk` *and
with a recipe*. It finds a rule but as it has no recipe make considers
that `a.mk` cannot be created. If you try `make -d` you'll see that it
tries all implicit rules for `a.mk` before giving up.

>> 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,

Yep. Note that I would not be shocked if make was failing in this
situation... if the manual was clear about this. Something like "if a
makefile is included it must be the target of a rule *with a recipe* and
executing this recipe *must* produce the included makefile".


>       Eddy.

Renaud Pacalet
Télécom ParisTech - LabSoC, c/o EURECOM
Campus SophiaTech,
450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
Tel : +33 (0) 4 9300 8402
Web : http://www.telecom-paristech.fr/

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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