[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: VPATH and include
From: |
Kaz Kylheku (gmake) |
Subject: |
Re: VPATH and include |
Date: |
Wed, 28 Aug 2019 14:07:24 -0700 |
User-agent: |
Roundcube Webmail/0.9.2 |
On 2019-08-28 06:21, Sébastien Hinderer wrote:
Dear friends,
Trying to use the VPATH variable, it seems to me that it is not taken
into account by the include directive.
That kind of makes sense because VPATH is for searching for
prerequisites;
included makefiles are not the prerequisites of a rule.
Included makefiles are potentially involved in rules, but as targets to
be updated.
That happens long after they have been found.
(The strange thing is that if an include file is not found, then
make looks for prerequisites from which it may be made. That probably
does use VPATH (?). For instance if "inc.mk" can't be found, then
prerequistes like "inc.mk.sh" and others are tried.)
Anyway, there is an -I <dir> command line option for specifying
include search directories. That could provide a solution/workaround.
A workaround for lack of path searching for included makefiles might be
to
use -include (to suppress errors) in combination with some
over-generated
include pattern like:
# ferret out any/all foo.mk three levels deep in the tree:
-include foo.mk */foo.mk */*/foo.mk ...
This could work well if there is a single foo.mk that
must be found anywhere at several levels of the tree, and we
can hide this behind a macro:
# use wildcards to find matches across four levels
FIND = $(1) */$(1) */*/$(1) */*/*/$(1)
-include $(call FIND,foo.mk)
-include $(call FIND,bar.mk)
Another idea is to just shell out to the actual find, or other utility:
include $(sh find . -name foo.mk)
Again, we can macro over this to make it more convenient, and support
multiple locations where to look, and so on.
- VPATH and include, Sébastien Hinderer, 2019/08/28
- Re: VPATH and include,
Kaz Kylheku (gmake) <=