[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: function help
From: |
Markus Mauhart |
Subject: |
Re: function help |
Date: |
Sun, 8 Jun 2003 19:02:29 +0200 |
"Martin McCann" <address@hidden> wrote in message
news:address@hidden
>
> 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.
- function help, Martin McCann, 2003/06/08
- Re: function help,
Markus Mauhart <=