When a prerequisite is found through directory search, regardless of type (general or selective), the pathname located may not be the one that make
actually provides you in the prerequisite list. Sometimes the path discovered through directory search is thrown away.
The algorithm make
uses to decide whether to keep or abandon a path found via directory search is as follows:
make
doesn’t need to rebuild the target then you use the path found via directory search. make
must rebuild, then the target is rebuilt locally, not in the directory found via directory search. This algorithm may seem complex, but in practice it is quite often exactly what you want.
Other versions of make
use a simpler algorithm: if the file does not exist, and it is found via directory search, then that pathname is always used whether or not the target needs to be built. Thus, if the target is rebuilt it is created at the pathname discovered during directory search.
If, in fact, this is the behavior you want for some or all of your directories, you can use the GPATH
variable to indicate this to make
.
GPATH
has the same syntax and format as VPATH
(that is, a space- or colon-delimited list of pathnames). If an out-of-date target is found by directory search in a directory that also appears in GPATH
, then that pathname is not thrown away. The target is rebuilt using the expanded path.
Copyright © 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Free Software Foundation, Inc.
Licensed under the GNU Free Documentation License.
https://www.gnu.org/software/make/manual/html_node/Search-Algorithm.html