help-make
[Top][All Lists]
Advanced

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

help with the scope of pattern-specific variables


From: Nestor Amaya
Subject: help with the scope of pattern-specific variables
Date: Sat, 4 Aug 2001 11:20:10 -0400

Hi,

According to Stallman & McGrath's book "GNU Make" (version 3.77), the
prerequisites of a target do inherit the values of *target*-specific
variables. This is my desired behaviour, and I have verified this with a
testcase. However, in the next section of the book, the authors describe
*pattern*-specific variables without mention of the scope of the assignment.
As with target-specific variable assignments, I would like the prerequisites
of my target to also inherit the value of the parent target's
*pattern*-specific variables. Is this possible?

For example, given the following makefile:

        ====================== Makfile ================================
        TARGET_SPEC_VAR = tvar_not_ok
        tvar : TARGET_SPEC_VAR = tvar_ok
        tvar : tvar_dep;
        tvar_dep : 
                @echo $(TARGET_SPEC_VAR)

        PATTERN_SPEC_VAR = pvar_not_ok
        %.pvar : PATTERN_SPEC_VAR = pvar_ok
        %.pvar : pvar_dep
                @echo $(PATTERN_SPEC_VAR)
        pvar_dep : 
                @echo $(PATTERN_SPEC_VAR)

If I run the command:
        % make tvar; #As desired, here I get the target-specific value,
which is "tvar_ok"
        tvar_ok

But then if I type:
        % make some.pvar
        pvar_not_ok
        pvar_ok

Note how the prerequisite target "pvar_dep" used the "global" value of
$(PATTERN_SPEC_VAR), namely pvar_not_ok, but then the desired value was
assigned for the parent target. Is this a bug? Is there a way for the
prerequisites to get the pattern-specific variable value?

Thanks in advance,
_______________________________________________________
Nestor A. Amaya                     Catena Networks
I.C. Development                    307 Legget Drive
                                    Kanata, ON
voice 1: (613) 599-6430 x8255       K2K 3C8
voice 2: (613) 599-4166
    fax: (613) 599-0445





reply via email to

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