On 02-Jan-2001, Eric Herring <[EMAIL PROTECTED]> wrote:
> I have a problem with calling makefiles within a
> makefile. The toplevel makefile is calling these
> makefile using a for loop. The problem is whenever a
> low level makefile has an error and reports an error,
> the top level make continues with the next make in the
> loop. I need the top level makefile to stop inside the
> for loop when a low level make has an error.

Simple solution:

        SUBDIRS = a b c d

        subdirs:
                for $$dir in $(SUBDIRS); do \
                        cd $$dir && $(MAKE) || exit 1; \
                done

Note the "|| exit 1", which terminates the loop.

Now, the problem with the simple solution is that it stops
too early in the case of `make -k'.
So another solution is as follows:

        SUBDIRS = a b c d

        subdirs: $(SUBDIRS:%=%.subdir)

        %.subdir:
                cd $* && $(MAKE)

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.

_______________________________________________
Help-make mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/help-make

Reply via email to