%% "Derick" <[EMAIL PROTECTED]> writes:

  d> Hello... I was wondering if anyone could give me some insight
  d> (==help). I am writing a makefile that has a SINGLE command that
  d> generates multiple output files. The difficulty I am running into
  d> is that the command is executed for each dependency, where the
  d> command actually takes care of all of them in one run.

  d> Specifically (simplified greatly):

  d>    all: MyStuff.a

  d>    GENERATED_CXX=MyStuff.cpp MyStuff_skel.cpp

  d>    $(GENERATED_CXX) : MyStuff.idl
  d>            $(IDLGEN) $(IDLGENFLAGS) $<

That's what this syntax is defined to do; multiple targets in a single
rule don't specify all are made from a single invocation, they specify
that each target can be built using the same script (but individual
invocations).

IOW, this:

  foo bar: baz
            some command

is just syntactic sugar for this:

  foo: baz
            some command
  bar: baz
            some command

See the GNU make manual.

  d> with the usual %.o:%.cpp rule elsewhere. What ends up happening is that
  d> $(IDLGEN) is run twice (once for MyStuff.cpp, once for MyStuff_skel.cpp),
  d> where I only want it done once.

You have to use pattern rules for this.  GNU make (and only GNU
make) has a special feature where multiple patterns on the left-hand
side of a pattern rule means that a single invocation of the command
creates all the targets at once, just as you want:

  %.cpp %_skel.cpp : %.idl
          $(IDLGEN) $(IDLGENFLAGS) $<

  all: MyStuff.a

  GENERATED_CXX=MyStuff.cpp MyStuff_skel.cpp

  MyStuff.a : $(GENERATED_CXX:.cpp=.o)
        # archive them here

will do what you want.

Again, see the GNU make manual.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[EMAIL PROTECTED]>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

_______________________________________________
Help-make mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/help-make

Reply via email to