help-make
[Top][All Lists]
Advanced

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

Re: unexpected behaviour with match anything rule


From: Philip Guenther
Subject: Re: unexpected behaviour with match anything rule
Date: Fri, 16 Nov 2012 16:14:11 +0000

On Fri, Nov 16, 2012 at 11:34 AM, Christof Warlich
<address@hidden> wrote:
> Am 15.11.2012 21:08, schrieb Britton Kerin:
>> Match-everything rules are really prone to problems of this sort.  The -d
>> flag will give you a big pile of output that will tell you whats going on
>> if you can stand wading though it.

Any if you don't understand why your Makefile is doing what it's
doing, you need to learn to read through it.  There are more buggy
makefiles than there are bugs in make.


>> Really its better to just not use implicit rules.  Compute the set of
>> targets
>> you want your rules to apply to with $(patsubst %.c,%.o,$(wildcard *.c))
>> or so and use a static pattern rule.  It makes it easier to get the
>> correct set
>> of files, and make is more likely to give you a useful error message when
>> things go wrong.

Personally, I disagree.  You lose chaining when you do that, if nothing else.

I'll also note that using $(wildard *.c) to find source files means
that it won't
work with VPATH and is fragile, breaking if someone does something like
    cp main.c orig_main.c
    <edit main.c>
    make


> I nevertheless was hoping for some ideas on how to fix make's behaviour
> w.r.t. match anything rules, which seems to me being rather buggy imho :-(.

It's doing exactly what it's documented to do, no?  So if there's a bug then it
extends to the documentation and you need to be able to describe the behavior
that you think make should have.

Or you can adjust your Makefile to match with make's existing behavior.  If the
"bug" is that you don't want the match anything rule to apply when make tries to
rebuild the Makefile, then give it an explicit rule for the Makefile:

Makefile: ;

(or, if your Makefile includes others and none of them are generated, then use
$(MAKEFILE_LIST):;
at the bottom of your Makefile.)


Philip Guenther



reply via email to

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