[Top][All Lists]

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

Re: Recursive make

From: Paul D. Smith
Subject: Re: Recursive make
Date: Wed, 30 Mar 2005 08:49:34 -0500

%% Grumble <address@hidden> writes:

  g> SUBDIRS = (a list of subdirectories)

  g> default clobber clean debug:
  g>    for dir in $(SUBDIRS); do make -C $$dir $@; done

  g> 1) One shouldn't call make explicitely.
  g> => Instead, one should call $(MAKE) or prefix the whole command with +

Correct.  Actually you should always use $(MAKE): using "+" is better
than nothing but not equivalent.

  g> 2) The 'for' loop ignores errors, and runs to completion.
  g> => The manual suggests using .PHONY targets.

  g> I don't see how I can use .PHONY targets to get rid of the loop.

  g> For example, if I run 'make debug', make should recursively run
  g> 'make debug' within every subdirectory. Is there a simple way to
  g> do that?

In simple cases you can do something like this:

    SUBDIRS = (list of subdirectories)
    TARGETS = all default clobber clean debug



            $(MAKE) -C $@ $(MAKECMDGOALS)

 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]