%% Grumble <[EMAIL PROTECTED]> 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

    .PHONY: $(TARGETS) $(SUBDIRS)

    $(TARGETS): $(SUBDIRS)

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

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[EMAIL PROTECTED]>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to