VPATH and include

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

VPATH and include

Sébastien Hinderer
Dear friends,

Trying to use the VPATH variable, it seems to me that it is not taken
into account by the include directive.

Is there a way to change this behaviour?

Thanks!

Sébastien.

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: VPATH and include

Kaz Kylheku (gmake)
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.

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: VPATH and include

Sébastien Hinderer
Dear Kaz,

Many thanks for your response, which makes perfect sense to me.

To give a bit of context I asked the question mainly about the inclusion
of .depend files for a project that can at the moment not be built out
of source tree and for which I was experimenting with VPATH. I think for
.depend files I should just hardcode their paths in the makefiles so
that they can be found in the source tree.

Thanks again for the enlightening response!

Sébastien.

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: VPATH and include

Paul Smith-20
In reply to this post by Sébastien Hinderer
On Wed, 2019-08-28 at 15:21 +0200, Sébastien Hinderer wrote:
> Trying to use the VPATH variable, it seems to me that it is not taken
> into account by the include directive.
>
> Is there a way to change this behaviour?

No.  This is a long-standing enhancement request:

https://savannah.gnu.org/bugs/?15224

Cheers!


_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: VPATH and include

Sébastien Hinderer
Paul Smith (2019/09/02 23:56 -0400):
> On Wed, 2019-08-28 at 15:21 +0200, Sébastien Hinderer wrote:
> > Trying to use the VPATH variable, it seems to me that it is not taken
> > into account by the include directive.
> >
> > Is there a way to change this behaviour?
>
> No.  This is a long-standing enhancement request:
>
> https://savannah.gnu.org/bugs/?15224

Thanks a lot for having taken the time to respond, Paul!

It is okay to do without that. Would have made things simpler but not a
strict requirement.

Sébastien.

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make