bug-make
[Top][All Lists]
Advanced

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

Re: Strange GNU make behavior with -include ?


From: Grégoire Sutre
Subject: Re: Strange GNU make behavior with -include ?
Date: Wed, 4 Dec 2002 18:09:44 +0100

On Tuesday 03 December 2002 21:44, you wrote:
> %% Grégoire Sutre <address@hidden> writes:
>
>   gs> I was having errors with my Makefiles (for Objective Caml), and I
> could gs> pinpoint the problem with the attached very simple Makefile.
>
>   gs> Basically (please see the attached Makefile), I use a:
>
>   gs> -include fake.depend
>
>   gs> statement to include a dependencies makefile 'fake.depend', but
>   gs> this included makefile does not exists and cannot be made.
>   gs> Indeed, fake.depend can be made from fake.c, but fake.c does not
>   gs> exist, and it isn't the target of any rule -- explicit or
>   gs> implicit).
>
>   gs> So I expected make to simply ignore fake.depend (as explained in
>   gs> GNU make's manual).
>
> Not quite.  The manual says that if the makefile does not exist and
> cannot be remade, then it will be ignored.  By "cannot be remade", the
> manual really means "make doesn't know of any way to remake it".

Ok.


> Because make can imagine a way to recreate the included makefile, it
> tries to do so (this is a result of the auto-re-exec feature of GNU
> make; it has nothing to do with whether fake.c is a prerequisite or
> not).  If the rebuild fails (in this case because there is no fake.c)
> then it stops with an error.

Yes, this is what I had understood from the manual.

I believe my explanation above was not precise enough.  Please let me give 
more details.

The following makefile goes through:

---------------------------------------
all:

dummy-fake:

%.depend : %.c
        touch $@

# Dependencies

-include fake.depend
---------------------------------------
localhost $ gmake
make: Nothing to be done for `all'.
---------------------------------------

This is precisely what I want: gmake could try to make fake.c in order to 
make fake.depend (because of the implicit rule in the makefile), but it 
doesn't since it can't find a way to make fake.c.


But this makefile doesn't go through:

---------------------------------------
all:

dummy-fake: fake.c

%.depend : %.c
        touch $@

# Dependencies

-include fake.depend
---------------------------------------
localhost $ gmake
make: *** No rule to make target `fake.c', needed by `fake.depend'.  Stop.
---------------------------------------


The only difference between the two is the rule with target dummy-fake.  This 
rule isn't used at all during this invocation of gmake.  I understand that if 
this rule had to be used during this invocation of gmake, then it would be 
smart to try to make fake.c but this is not the case here.


I could produce this behavior with both versions 3.79.1 and 3.80.

So I guessed (but this is a user's guess) that on this example, the fact that 
"fake.c" appears as a pre-requisite of an explicit rule plays a role (even if 
the rule isn't used).


Thanks for your answer, and for your great work on GNU make,

Gregoire Sutre.

-- 
Grégoire Sutre                         Bureau 211
address@hidden                         LaBRI - CNRS UMR 5800
http://www.labri.fr/~sutre             Domaine Universitaire
Tel: +33 5 56 84 33 36                 351, cours de la Libération
Fax: +33 5 56 84 66 69                 33405 Talence Cedex, FRANCE




reply via email to

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