Hi Matej,

> In my Makefile, I have a series of lines like this:
> 
>       dir := src/foo-01
>       include $(dir)/rules.mk
> 
>       dir := src/foo-02
>       include $(dir)/rules.mk
> 
>       dir := src/foo-03
>       include $(dir)/rules.mk
> 
>       ...
> 
> As I add new and new foo-directories, I have to add new entries to the
> Makefile.
> 
> At "make time", I can enumerate existing foo-directories with
> 
>       $(wildcard src/foo-*)
> 
> but I do not know how to generate those Makefile directives because
> parametrical variables and $(foreach ...) can only expand to one-line
> text where I need expansion to two lines.

Multi-line variables will do the trick, something along the lines:

define DIRS
    dir := src/%1
    include $(dir)/rules.mk
endef

$(foreach i,foo-01 foo-02 foo-03,$(eval $(call DIRS,$i)))

Hope this helps. Cheers,

Chris 
_______________________________________________
Help-make mailing list
Help-make@gnu.org
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to