help-make
[Top][All Lists]
Advanced

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

Re: [Help-make] foreach, recursion, and exit codes


From: Fergus Henderson
Subject: Re: [Help-make] foreach, recursion, and exit codes
Date: Wed, 20 Sep 2000 04:00:27 +1100

On 19-Sep-2000, Sankaranarayanan K V <address@hidden> wrote:
> SUBDIRS = ok-dir-1 bad-dir ok-dir-2 
> 
> all.simple:
>       $(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) all;)
...
> Are there other ways?

Sure.  Using portable Make, you can write

        all.simple:
                for dir in $(SUBDIRS); do \
                        $(MAKE) -C $$dir || exit 1; \
                done

or using GNU extensions

        all.simple:
                $(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) all || exit 1;)

Neither of these handle `make -k' nicely or `make -j' nicely, though,
so you may want a different solution, e.g. one along the lines of
this
        
        all.simple: $(SUBDIRS)

        .PHONY: $(SUBDIRS)
        $(SUBDIRS):
                $(MAKE) -C $*

or this

        all.simple: $(SUBDIRS:=.dir)

        %.dir:
                $(MAKE) -C $*

(I didn't test any of these.)

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]