help-gnu-utils
[Top][All Lists]
Advanced

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

Re: GNU Make 3.80: conditional pattern rules?


From: Dan Katz
Subject: Re: GNU Make 3.80: conditional pattern rules?
Date: Fri, 30 Apr 2004 18:26:45 -0400
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (gnu/linux)

On 30 Apr 2004, Dan Katz wrote:

>
> ------------------------------------------------------------------------
> PROFILE= 
> ifeq ($(PROFILE), on) 
>
[... snip variable stuff inside the ifeq ...]
>
> %.o : %.cpp
>       $(PDTPARSE) $< $(CXXFLAGS) $(CPPFLAGS) 
>       $(TAUINSTR) $*.pdb $< -o $*.inst.cpp
>       $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $*.inst.cpp -o $@ 
> endif
>
> TARGET = junk all: $(TARGET)
> ------------------------------------------------------------------------
>
> If I set (PROFILE=on), I do get the various variables set and used,
> but the new (%.o : %.cpp) pattern is ignored.



My bad -- the problem was that I was overriding the wrong implicit
rule.  It was using a direct rule for (% : %.cpp).  If I also unset
that then it all works.  I.e.

------------------------------------------------------------------------
PROFILE=
ifeq ($(PROFILE), on)
% : %.cpp

%.o : %.cpp
    $(PDTPARSE) $< $(CXXFLAGS) $(CPPFLAGS) 
    $(TAUINSTR) $*.pdb $< -o $*.inst.cpp
    $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $*.inst.cpp -o $@ 
endif
------------------------------------------------------------------------

Then it works fine.  I'd love to switch the conditional off the target
called on the command line rather than off a variable in the file, but
this'll do for now.



> P.S.  This is just the first step.  Once I know how to control the
> patterns this way, I'll be trying to integrate all of this into a
> project which is using the usual automake/autoconf/libtool system.

It turns out that my original approach will be less of a problem using
automake, since that system tends to use the ($.o : $.cpp) rule
directly for the most part.


Dan


reply via email to

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