linux # vpath

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.

VPATH用于指定一個目錄列表,以便于make的時候在其中搜索。
這些目錄中一般包含一些make必須的文件。

The VPATH is a list of directories to be searched for missing source files (actually for missing prerequisites: they don't have to be source files, but VPATH and vpath are best only used for source files).

The vpath directive has both a search path and a pattern.
Only missing prerequisites matching the pattern are searched using the associated path.
So vpath makes it possible, for example, to specify just a path to search for header (.h) files:

vpath %.h /usr/include

The % is the wildcard and matches anything, so that vpath directive solves the problem of the missing string.h in the example Makefile.

three forms

The vpath syntax is a little more complicated than VPATH and has three forms:

1. vpath pattern path 

This sets the search path (colon or blank separated) for the pattern.

2. vpath pattern 

This clears the path for the specified pattern.

3. vpath 

Clears all vpath settings

examples
vpath %.h /usr/include
vpath %.c ../src
INCLUDE_DIRECTORIES = ../include
vpath %.h $(INCLUDE_DIRECTORIES)

ffmpeg的主Makefile中也用到了vpath:

MAIN_MAKEFILE=1
include ffbuild/config.mak

vpath %.c    $(SRC_PATH)
vpath %.cpp  $(SRC_PATH)
vpath %.h    $(SRC_PATH)
vpath %.inc  $(SRC_PATH)
vpath %.m    $(SRC_PATH)
vpath %.S    $(SRC_PATH)
vpath %.asm  $(SRC_PATH)
vpath %.rc   $(SRC_PATH)
vpath %.v    $(SRC_PATH)
vpath %.texi $(SRC_PATH)
vpath %.cu   $(SRC_PATH)
vpath %.ptx  $(SRC_PATH)
vpath %/fate_config.sh.template $(SRC_PATH)

References:

https://www.cmcrossroads.com/article/basics-vpath-and-vpath
https://www.gnu.org/software/make/manual/html_node/General-Search.html

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,854評論 0 10
  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 11,119評論 0 23
  • 關于android權(quán)限適配的問題現(xiàn)在網(wǎng)上可以說是一大堆了,開源的框架也有不少,如TedPermission、And...
    wanghai328閱讀 393評論 0 0
  • 你站在我的手心看日月星辰 你跪在我的手心乞討 你躺在我的手心死去 斃命的你在我手心燃燒 無休止地燃燒 看著你一直在...
    留子堯閱讀 297評論 3 4

友情鏈接更多精彩內(nèi)容