En un makefile, ¿cómo funciona VPATH?

in the following website http://make.paulandlesley.org/vpath.html

el autor dice:

VPATH was designed to find sources, not targets.

but in GNU make's manual, it says:

The value of the make variable VPATH specifies a list of directories that make should search. Most often, the directories are expected to contain prerequisite files that are not in the current directory; however, make uses VPATH as a search list for both prerequisites and targets of rules.

¿Qué significa esto?

preguntado el 03 de mayo de 12 a las 17:05

2 Respuestas

Significa exactamente lo que dice. make will look both for things needed to build something and things already built to see if it needs to be rebuilt.

A typical scenario is if you use a temporary build directory where you place object files before linking or creating an archive. Then you want make to look there too to see what needs to be rebuilt.

contestado el 03 de mayo de 12 a las 17:05

@CyberRusher I'm not sure I understand your comment. Either make uses it to search for targets, or it does not. As far as I know, it does. What do you mean with "not good" in this context? I've used VPATH for just this in my own makefiles and it works very well. - Honky Tonk

The GNU Make manual says that you puede use VPATH to find targets. Paul Smith is saying that you generally no debe. (Whether VPATH was or wasn't originally designed for that purpose is moot.)

There are a few reasons why using VPATH this way can cause problems (none of them damning) but the page at paulandlesley is specifically talking about using VPATH naively to build targets in remote locations (which just doesn't work), in the context of multi-architecture builds.

contestado el 03 de mayo de 12 a las 18:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.