help-make
[Top][All Lists]
Advanced

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

Re: How to have one command make several intermediate files?


From: Paul D. Smith
Subject: Re: How to have one command make several intermediate files?
Date: Wed, 8 Aug 2001 16:37:17 -0400

%% "Lindner, Mike" <address@hidden> writes:

  lm> I have a program that generates several source code files, that
  lm> are subsequently compiled. If I run "make" all works well, and the
  lm> code generator is run once. If, however, I run "make -jX", the
  lm> code generator runs "X" times.

Yes.

  lm> By way of example, consider the following Makefile:

  lm>   INTS = b c

  lm>   $(INTS):
  lm>           echo b > b
  lm>           echo c > c

Multiple explicit targets doesn't mean "one invocation of this rule
makes all targets", it means "all these targets use the same rule to
build, so run that rule to update every target".

The fact that it works without -j is merely an accident: the first
execution builds the targets so when make goes to try to build them they
look like they're up-to-date.

See the GNU make manual for more info.

  lm> Is there any way to tell GNU make that the commands make all the
  lm> targets?

Not for explicit rules.

If your targets all share a common prefix (or suffix), you can write an
implicit pattern rule which contains multiple target patterns; this
syntax _IS_ interpreted as one instance of the command creating all the
targets:

  %.x %.y %.z : %.a
        echo $< > %*.x
        echo $< > %*.y
        echo $< > %*.z

does what you expect.

Again, see the GNU make manual for more details.

  lm> I thought of making a "contrived" dependency of all of the
  lm> generated files on one file, but that solution doesn't seem clean
  lm> or correct.

That's the only solution if you can't use pattern rules.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          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



reply via email to

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