[Top][All Lists]

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

Re: Question about substituting $(MAKE) and recursive makes.

From: Paul D. Smith
Subject: Re: Question about substituting $(MAKE) and recursive makes.
Date: Tue, 9 Sep 2003 08:23:40 -0400

%% Kelley Cook <address@hidden> writes:

  kc> For the GCC project, there are numberous places where we have something 
  kc> similar to

  kc> dep:

  kc> which proved to be prone to mistakes in maintenance of the Makefile.

  kc> So, I attempted to define a


  kc> and then replace those constructs with

  kc> dep:
  kc>   $(REMAKE) newstage

  kc> but any parallel build ended up being serialized once it recursed.

Didn't you get any warnings?  You should have received a warning, and
if you look up the warning in the error messages section of the GNU make
manual you'd find some info there about this.

  kc> It was suggested to try

  kc> dep:
  kc>   +$(REMAKE) newstage

You can put the + inside the REMAKE variable as well; that's probably
less work and safer as people won't forget it:


The one downside to this style is that you can't use this form of
$(REMAKE) anywhere except the beginning of a command script.  For
example this will not work if you include the "+" in the variable:

        cd foo && $(REMAKE)

  kc> which does *seem* to work, but I cannot see where in the manual
  kc> that this construct is supposed to allow parallel builds to work
  kc> again.  From what I can tell the '+' should only affect '-n',
  kc> '-t', and '-q'.  Though the 'MAKE' variable page does mention that
  kc> the special variable '$(MAKE)' acts like it was specified with
  kc> '+$(MAKE)'.

  kc> Can you please shed some light on this?  Is it valid, and if not
  kc> is their a better way to do this.

It is valid.  In order for the make "jobserver" feature (that controls
the total number of jobs being invoked across all the different possible
instances of make and sub-makes) to work, make needs to know which
commands are sub-makes and which aren't.

It determines that by the "usual" method as described in the manual:
either by $(MAKE) or ${MAKE} appearing verbatim in the script (before
expansion), or by having the script begin with the "+" special

Any command that is marked in this way will eligible to participate in
the jobserver feature; any command that is not marked in this way will
not be eligible.  If a make is invoked and finds that it's a submake of
a parallel build, but is not eligible for jobserver, it will print a
warning about needing to add "+" to the parent makefile and it will
continue as a serial build.

As for "a better way to do this", I'm not sure what "this" you're
talking about.  I guess you mean the whole idea of providing flags to

The simplest thing to do is append your variables to the MAKEFLAGS


I believe that will work fine.  I suppose you might want to check to
make sure those variables are not already present first.  See the GNU
make manual for more info on MAKEFLAGS.

 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]