help-make
[Top][All Lists]
Advanced

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

Multiple patterns (or Wildcards) in targets?


From: Nestor Amaya
Subject: Multiple patterns (or Wildcards) in targets?
Date: Tue, 7 Aug 2001 17:39:31 -0400

This is somewhat related to my previous posting titled "help with the scope
of pattern-specific variables".

I have searched books, websites, man pages, and cannot find any clues as to
how one might define a pattern-specific variable (or target, for that
matter) when the pattern is neither a suffix nor a prefix to the target. For
example, I need:

        %pattern% : PAT_DEP_VAR = success

To match any target that has "pattern" in it. A simple testcase follows:
        ====================== Makfile ================================
        %.1.% : PAT_DEP_VAR = yes
        first.1.1 :
                @echo $(PAT_DEP_VAR)
        second.1.2 :
                @echo $(PAT_DEP_VAR)

The output of either "make first.1.1" or "make second.1.2" should yield
"yes". In this case, I am not particularly interested in the/either "stem"
(but note that the "prefix-stem" and the "suffix-stem" usually do differ).

Note that I cannot automatically generate a list of the possible targets
from an "ls", since the files may or may not exist, and the combinations may
be too many... So in other words, I cannot search a variable
$(POSSIBLE_TARGETS) for a match.

I have a feeling that I have overlooked something very obvious here. Your
help is much appreciated, since my head is numb from being banged against
the wall ;)

 <<help with the scope of pattern-specific variables>> 
_______________________________________________________
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


--- Begin Message --- Subject: help with the scope of pattern-specific variables Date: Sat, 4 Aug 2001 11:20:06 -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



--- End Message ---

reply via email to

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