[Top][All Lists]

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

GNU Make 3.80: conditional pattern rules?

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


I'm using a profiler (called TAU) for which I need to substantially
change the normal (%.o : %.c) pattern so that another program can
insert the instrumentation at the right point.  Of course, I only want
to do this when doing a profiled build.  

My first stab at the problem was a Makefile like this:

ifeq ($(PROFILE), on)
  TAUROOTDIR = /usr/local/src/tau-2.13.5/
  include $(TAUROOTDIR)/i386_linux/lib/Makefile.tau-linuxtimers-pdt

  CXX       = $(TAU_CXX)
  CC        = $(TAU_CC)
  LIBS      = $(TAU_LIBS) -lm
  PDTPARSE  = $(PDTDIR)/$(CONFIG_ARCH)/bin/cxxparse
  TAUINSTR  = $(TAUROOT)/$(CONFIG_ARCH)/bin/tau_instrumentor

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

TARGET  = junk
all: $(TARGET)

If I leave the profile variable unset, then I get the normal
compilation of (junk.cpp -> junk) using the default implicit
patterns.  If I set (PROFILE=on), I do get the various variables set
and used, but the new (%.o : %.cpp) pattern is ignored.

Is there a simple way to conditionally control which implicit patterns
are used, depending on the value of a variable?  Or is there a better
idiom entirely for achieving this effect?  



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.
The desired state of all of this is to be able to type

$ make profile

and get a build appropriate for profiling, while maintaining the ease
of use of the existing autoconfiscated system.

reply via email to

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