help-make
[Top][All Lists]
Advanced

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

Re: if there are multiple pattern rules


From: ali hagigat
Subject: Re: if there are multiple pattern rules
Date: Mon, 4 Apr 2011 12:08:50 +0430

Please consider the following makefile and it result in 3.81:
-----------------------------------------
e12: e13
        @echo 12complete        
%13: e14
        @echo 13complete_1
%13: e14
        @echo 13complete_2
%14:
        @echo 14complete
e15:
        @echo 15complete

14complete
13complete_2
12complete
-----------------------------------------
Dear Paul, as you wrote in 3.81 the first pattern rule is executed
according to the manual. But why the second recipe is executed in the
above example?
I wonder if any body has tested the above for Fedora, make 3.82.
My second question is that why the recipe of pattern rules is taken
differently with regular rules in 3.81? Please consider the following:
-----------------------------------------
e12: e13
        @echo 12complete
e13: e14
        @echo 13complete_1
e13: e15
        @echo 13complete_2
e14:
        @echo 14complete
e15:
        @echo 15complete

15complete
14complete
13complete_2
12complete
-----------------------------------------
For regular targets, it continues to the last target. But for pattern
targets it deals with the first target in 3.81!!


On Mon, Apr 4, 2011 at 2:39 AM, Paul Smith <address@hidden> wrote:
> On Sun, 2011-04-03 at 13:42 +0430, ali hagigat wrote:
>> If I have two pattern rules for a target in a makefile, which one will
>> be selected?
>
> Before 3.82, the GNU make manual says:
>
>           The order in which pattern rules appear in the makefile is
>        important since this is the order in which they are considered.
>        Of equally applicable rules, only the first one found is used.
>        The rules you write take precedence over those that are built
>        in.
>
>
> In 3.82 a more intelligent scheme is used: the GNU make manual says:
>
>        It is possible that more than one pattern rule will meet these
>        criteria.  In that case, @code{make} will choose the rule with
>        the shortest stem (that is, the pattern that matches most
>        specifically). If more than one pattern rule has the shortest
>        stem, @code{make} will choose the first one found in the
>        makefile.
>
> However, we've seen incompatibilities and problems with this.  It's not
> clear exactly how this will play out.
>
> Most of the time rules can easily be written to work the same in both
> versions.
>
> --
> -------------------------------------------------------------------------------
>  Paul D. Smith <address@hidden>          Find some GNU make tips at:
>  http://www.gnu.org                      http://make.mad-scientist.net
>  "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
>
>



reply via email to

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