help-make
[Top][All Lists]
Advanced

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

Is there a way to use include directives in macros?


From: Sébastien Hinderer
Subject: Is there a way to use include directives in macros?
Date: Tue, 21 Mar 2017 13:18:14 +0100

Dear all,

I am trying to design a nice way for a Makefile to include
sub-makefiles.

For the moment I have written code like this:

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)))

This does not quite work and I guess it is not possible at all in
makefiles to define INCLUDE-like macros.

Is there a recommended way to achieve a similar result out of repeating
the three lines in the macro for each subdirectory?

The idea behind this is also that each su-makefile knows its relative
directory and can make use it to generate paths that are relative to the
toplevel source directory.

Any advice greatly appreciated.

Sébastien.



reply via email to

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