make-alpha
[Top][All Lists]
Advanced

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

Re: GNU Make enhansment patch - batching compiles


From: Paul D. Smith
Subject: Re: GNU Make enhansment patch - batching compiles
Date: Thu, 3 May 2001 11:33:57 -0400

%% Eli Zaretskii <address@hidden> writes:

  ez> On Thu, 3 May 2001, Jason Wessel wrote:

  >> I needed the ability to change a variable from
  >> inside the command section of a rule.  Doing
  >> this allows me to build a list of files that need
  >> to be compiled, instead of passing the files to
  >> the compiler one at a time.  We have a program
  >> that builds the make files already.  The idea is
  >> to feed the compiler multiple source files at the
  >> same time.

  ez> I'm confused: I don't understand how would you like this to work
  ez> in practice (yes, I looked at the Makefile you attached, but I
  ez> still cannot figure it out).

  ez> First, how do you figure out which files need to be compiled and
  ez> which don't?  If this is based on the files' time stamps only,
  ez> then the Make macro $? should allow you to do that without any
  ez> extra features.

I think it works like this (I didn't look at the makefile, though :)

The rule to build each individual file doesn't actually build it;
instead it adds the name of the file to the make variable.

Then at the end, that variable is used to actually invoke one command
that "does everything".

Because the variable value is only set for rules that would otherwise be
run, you still get the benefit of make's build avoidance, prerequisite
tracking, etc.

I think you could get a "poor man's" version of this by doing something
like this:

  BATCHFILE = /tmp/batch

  _dummy := $(shell rm -f $(BATCHFILE))

  %.class : %.java
          @echo $< >> $(BATCHFILE)

  CompList1: $(OBJECTS)
          if [ -s $(BATCHFILE) ]; then; \
            echo compiling ${CompList1} into outputs; \
          else \
            echo nothing to be done; \
          fi

If you had multiple top-level targets you'd have to do something like
use target-specific variables, maybe:

  CompList1: BATCHFILE = /tmp/batch.CompList1

or whatever.

-- 
-------------------------------------------------------------------------------
 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]