%% "Fairweather, James" <[EMAIL PROTECTED]> writes: fj> I have something like this:
fj> SUBDIRS = foo bar fj> all: fj> for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir; done fj> which works fine, but it's using the shell's for function. Actually, this doesn't work fine. This is the most common method, but it's poor because it does not handle errors properly. In the above method, if one of the subdirectories fails, then make does not stop but rather continues to run. If you change the loop to check that the subdirectory failed and stop, then using "make -k" behaves incorrectly (it still stops when it should continue). And, even if you should try to solve that by looking for a "k" in MAKEFLAGS or somesuch silliness, it still is not ideal because likely there are a number of directories which _are_ able to be built if another one fails, and there are also some which can't be. You'd have to add a lot of logic to your loop to get this right, and once you looked at it you'd realize that actually, this is exactly what make itself is designed to do. Not to mention that you don't get the full benefit of parallel builds because you're sequentially building every directory. fj> Also, I have this: fj> SUBDIRS = foo bar fj> ALLDIR = $(addsuffix .all,$(SUBDIRS)) fj> all: $(ALLDIR) fj> %.all: fj> $(MAKE) -C $* Something like this is the best solution, and this is what I always use. Also, don't forget to add: .PHONY: all $(ALLDIR) And of course, if you need to ensure that some directory is built before others, be sure to add: foo.all: bar.all baz.all etc. -- ------------------------------------------------------------------------------- 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://mail.gnu.org/mailman/listinfo/help-make
