"Martin McCann" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Hi there,
>
> I am trying to create a system of make files for my project, so as to make
> adding extra elements to the system is as easy as possible. I have created a
> make file called do_subdirs.mk which has the following -
>
> # ---- do_subdirs.mk --- 
> subdirs:
> $(foreach SUBDIR, $(SUBDIRS), $(MAKE) -C $(SUBDIR);)
>
> # --- eof ---
>
> So to have a makefile enter a list of sub directories I just need -
>
> # ----
>
> SUBDIRS = dir1 dir2 dir3 dir4
> include ../mk/do_subdirs.mk
>
> # ----
>
>
> This all works, which is nice. The one problem being that the macro expands to
>
> make -C dir1; make -C dir2; make -C dir3; make -C dir4;
>
> so if one of the makes fails, it doesn't fail the entire make (I assume to
> only takes the return code from the left/right most make). So my question is,
> how do I achieve the same but have the make fail if any make fails. I know I
> could achieve it with a shell script, but I'd rather avoid it if possible.

IMO this works ...
#---------------do_subdirs.mk--------------------
#
SUBDIRS := 1 qwe/asd 2 3 4

.PHONY: thetarget
thetarget: $(SUBDIRS)

define subdir_specific
.PHONY: $$(subdir)
$$(subdir):
    $$(MAKE) -C $$@
endef

$(foreach subdir,$(SUBDIRS),$(eval $(subdir_specific)))
#
#----------------do_subdirs.mk-------------------


Regards,
Markus.





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

Reply via email to