help-make
[Top][All Lists]
Advanced

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

Re: Is there a way to use include directives in macros?


From: Paul Smith
Subject: Re: Is there a way to use include directives in macros?
Date: Tue, 21 Mar 2017 08:31:00 -0400

On Tue, 2017-03-21 at 13:18 +0100, Sébastien Hinderer wrote:
> define INCLUDE
>   curdir := $(1)
>   include $(1)/Makefile
>   unset curdir
> 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.

You need eval for that:

  $(foreach d,$(subdirectories),$(eval $(call INCLUDE,$(d))))




reply via email to

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