[Top][All Lists]

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

Re: Batch building and make -j

From: Paul D. Smith
Subject: Re: Batch building and make -j
Date: Fri, 22 Apr 2005 12:59:53 -0400

%% "Casper Hornstrup" <address@hidden> writes:

  ch> For batch building using a RAM disk for intermediate files, I
  ch> would like to delete generated object files as soon as possible.

  ch> all: moduleA.a
  ch> moduleA_OBJS = moduleA_1.o
  ch> moduleA.a: $(moduleA_OBJS)
  ch>                       ar -rc $@ $(moduleA_OBJS)
  ch>                       rm -f $(moduleA_OBJS)
  ch> moduleA_1.o: moduleA_1.c
  ch>                       gcc -c moduleA_1.c -o moduleA_1.o

  ch> Using multiple jobs however, say 50, make tends to create the
  ch> object files for a whole lot of modules, then create the archives
  ch> for these modules, then delete the object files for these
  ch> modules. This causes the disk space requirements to go way up.  Is
  ch> there any way I can achieve my goal for make -j also?

This is very tricky to do.  The only way to do it is to have all the
objects for moduleA depend on moduleB.a so that no objects for moduleA
are built until moduleB.a is completed (and the objects are removed).
For example, using your example above and another library moduleB.a that
should be built first, you'd add a line like:

    moduleA.a $(moduleA_OBJS) : | moduleB.a

(the "|" marks an order-only prerequisite: see the GNU make manual for
details.  You need a sufficiently newer version of GNU make to use this).

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "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]