help-make
[Top][All Lists]
Advanced

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

Re: typo in the make manual


From: Philip Guenther
Subject: Re: typo in the make manual
Date: Wed, 20 Apr 2011 19:22:00 -0700

On Sun, Apr 17, 2011 at 5:29 PM, Paul Smith <address@hidden> wrote:
> On Tue, 2011-04-05 at 07:40 +0430, ali hagigat wrote:
>> 6.12 Pattern-specific Variable Values
>> If a target matches more than one pattern, the matching
>> pattern-specific variables with
>> longer stems are interpreted first.
>> -------------------------------------------
>> The above words of the documentation seems to be corrected with
>> "shorter stems".
>
> No, the manual is correct.  The longer stems are preferred over shorter
> stems.

Paul, I'm not sure "preferred" is the right word there.

The patterns-specific variable assignments are applied starting from
the most generic pattern (i.e., the longest stems) to the
most-specific pattern (i.e., the shortest stem).  For normal
assignment (=, :=), that will result in the assignment from the
most-specific pattern having precedence, as if the more generic
assignment wasn't there.  However, for += and ?= assignments, you can
'detect' the assignment from the more generic pattern.  Consider:

$ cat Makefile
%: type1 = generic
%: type2 = generic
%: type3 ?= generic
%.c: type1 = C
%.c: type2 += C
%.c: type3 ?= C

foo.c:
        echo '${type1}'
        echo '${type2}'
        echo '${type3}'
$ make
echo 'C'
C
echo 'generic C'
generic C
echo 'generic'
generic
$

For ${type1}, the %.c assignment overrode the % assignment.
For ${type2}, the %.c assignment added onto the % assignment.
For ${type3}, the %.c assignment had no effect, because type3 was
already set by the % assignment.


So the manual is correct: longer (more generic) stems are interpreted
before shorter (more specific) stems...but you'll probably be using
normal assignment so that the latter will override the former.


Philip Guenther



reply via email to

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