[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Gnu Make
From: |
Paul D. Smith |
Subject: |
Re: Gnu Make |
Date: |
02 Jan 2001 11:53:18 -0500 |
User-agent: |
Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7 |
%% Eric Herring <address@hidden> writes:
eh> I have a problem with calling makefiles within a
eh> makefile. The toplevel makefile is calling these
eh> makefile using a for loop. The problem is whenever a
eh> low level makefile has an error and reports an error,
eh> the top level make continues with the next make in the
eh> loop. I need the top level makefile to stop inside the
eh> for loop when a low level make has an error.
The answer is, don't do it with a for loop. Use make features!
Instead of this:
SUBDIRS = foo bar biz baz
all:
@for d in $(SUBDIRS); do cd $$d && $(MAKE); done
Do this:
SUBDIRS = foo bar biz baz
.PHONY: $(SUBDIRS)
all: $(SUBDIRS)
$(SUBDIRS):
cd $@ && $(MAKE)
This will fail as soon as something breaks under normal use, and will
also work correctly with -k. And, as an added bonus, it will work
_much_ better with parallel builds should you ever want to try them. If
you have some dependency between the directories, just declare them as
you normally would; if you can't build directory foo until after
directory bar, add:
foo: bar
to the makefile.
--
-------------------------------------------------------------------------------
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