[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to advise or override the libtool make rules?
From: |
Dan Katz |
Subject: |
How to advise or override the libtool make rules? |
Date: |
Wed, 02 Jun 2004 16:18:20 -0400 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.3 (gnu/linux) |
Hi.
I have a moderately large application that I'm working with which is
built using autoconf, automake, and libtool. I want to profile the
application, and the profiler I want to use (TAU) is adds code
instrumentation prior to compilation.
Essentially, I need to run a parser and an instrumentation program to
generate instrumented sources (*.inst.cpp), which should then be used
in the usual way by libtool and automake to get object files. I've
managed to get this to work by overriding the automake/libtool
generated suffix rules in the Makefile.am as follows (I use GNU make,
so I did the override using pattern rules):
------------------------------------------------------------------------
if TAU # defined via autoconf --enable-tau option
[... set a bunch of variables here ...]
#With libtool we seem to need these
%.o : %.cpp
$(PDTPARSE) $< $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES)
$(TAUINSTR) $*.pdb $< -o $*.inst.cpp
if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@
$*.inst.cpp; \
then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f
"$(DEPDIR)/$*.Tpo"; exit 1; fi
%.lo : %.cpp
$(PDTPARSE) $< $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES)
$(TAUINSTR) $*.pdb $< -o $*.inst.cpp
if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@
$*.inst.cpp; \
then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f
"$(DEPDIR)/$*.Tpo"; exit 1; fi
profile :
${MAKE} "CC=$(TAU_CC) CXX=$(TAU_CXX)"
endif
------------------------------------------------------------------------
where what I've really done is just copy the normally generated suffix
rules into Makefile.am, insert the calls to the parser ($PDTPARSE) and
the instrumentor ($TAUINSTR), and run normally on the instrumented
code, effectively giving "advice" of the form
%.lo : %.cpp
# Parse step here
# Instrumentation step
# Do whatever you normally do, just do it to *.inst.cpp instead
While all this works, I don't like it much. In the first place, I'm
overriding two suffix rules (and would be overriding a third
".obj.cpp" rule if I wanted to support cygwin) which is messy and not
very easy to understand. In the second place, it exposes too much of
the libtool/automake internals for my taste, making my Makefile.am
relatively brittle in the face of changes to the automake/libtool
interaction mechanism.
Is there a better way to "advise" the generated suffix rules in this
sort of way?
Thanks.
Dan
P.S. It wasn't clear to me whether this question belonged in the
libtool mailing list or the automake list. If I guessed wrong, I
apologize.
- How to advise or override the libtool make rules?,
Dan Katz <=