[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is there a way to use include directives in macros?
From: |
Sébastien Hinderer |
Subject: |
Re: Is there a way to use include directives in macros? |
Date: |
Tue, 21 Mar 2017 13:50:38 +0100 |
Dear Paul,
Many thanks for your so prompt and helpful response!
Paul Smith (2017/03/21 08:31 -0400):
> On Tue, 2017-03-21 at 13:18 +0100, Sébastien Hinderer wrote:
> > define INCLUDE
> > curdir := $(1)
> > include $(1)/Makefile
> > unset curdir
(That should have been undefine, by the way)
> > endef
> >
> > # List of subdirectories containing a Makefile that should be included
> >
> > subdirectories := foo bar baz
> >
> > # Include all the specified sub-makefiles
> > $(foreach subdirectory, $(subdirectories), $(call INCLUDE, $(subdirectory)))
>
> The expansion of the foreach loop has to be a valid single line of
> makefile syntax; it will be considered a logical line. You can't use
> call to invoke a multiline function containing make syntax like this.
Okay.
> You need eval for that:
>
> $(foreach d,$(subdirectories),$(eval $(call INCLUDE,$(d))))
Ah, thanks! Actually I was aware of eeval but did not realise its link
with what I was trying to do. Reading its documentation with this new
light makes everything much clearer. Thaks again!
Sébastien.