Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In a makefile, how VPATH works?

Tags:

linux

makefile

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

the author says:

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.

what does this mean?

like image 541
Y.L. Avatar asked May 03 '12 16:05

Y.L.


2 Answers

It means exactly what it says. 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.

like image 160
HonkyTonk Avatar answered Oct 20 '22 21:10

HonkyTonk


The GNU Make manual says that you can use VPATH to find targets. Paul Smith is saying that you generally shouldn't. (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.

like image 5
Beta Avatar answered Oct 20 '22 20:10

Beta