1*e2eeea75SSimon J. Gerraty# $NetBSD: varname-vpath.mk,v 1.3 2020/11/10 00:19:19 rillig Exp $ 22c3632d1SSimon J. Gerraty# 3*e2eeea75SSimon J. Gerraty# Tests for the special VPATH variable, which is an obsolete way of 4*e2eeea75SSimon J. Gerraty# specifying a colon-separated search path. This search path is not active 5*e2eeea75SSimon J. Gerraty# when the makefiles are read, but only later when the shell commands are run. 6*e2eeea75SSimon J. Gerraty# 7*e2eeea75SSimon J. Gerraty# Instead of the VPATH, better use the -I option or the special target .PATH. 82c3632d1SSimon J. Gerraty 9*e2eeea75SSimon J. Gerraty.if !defined(TEST_MAIN) 10*e2eeea75SSimon J. Gerraty 11*e2eeea75SSimon J. Gerratyall: .SILENT 12*e2eeea75SSimon J. Gerraty rm -rf varname-vpath.dir 13*e2eeea75SSimon J. Gerraty mkdir varname-vpath.dir 14*e2eeea75SSimon J. Gerraty touch varname-vpath.dir/file-in-subdirectory 15*e2eeea75SSimon J. Gerraty rm -rf varname-vpath.dir2 16*e2eeea75SSimon J. Gerraty mkdir varname-vpath.dir2 17*e2eeea75SSimon J. Gerraty touch varname-vpath.dir2/file2-in-subdirectory 18*e2eeea75SSimon J. Gerraty 19*e2eeea75SSimon J. Gerraty TEST_MAIN=yes VPATH=varname-vpath.dir:varname-vpath.dir2 \ 20*e2eeea75SSimon J. Gerraty ${MAKE} -f ${MAKEFILE} -dc 21*e2eeea75SSimon J. Gerraty 22*e2eeea75SSimon J. Gerraty rm -r varname-vpath.dir 23*e2eeea75SSimon J. Gerraty rm -r varname-vpath.dir2 24*e2eeea75SSimon J. Gerraty 25*e2eeea75SSimon J. Gerraty.else 26*e2eeea75SSimon J. Gerraty 27*e2eeea75SSimon J. Gerraty# The VPATH variable does not take effect at parse time. 28*e2eeea75SSimon J. Gerraty# It is evaluated only once, between reading the makefiles and making the 29*e2eeea75SSimon J. Gerraty# targets. Therefore it could also be an ordinary variable, it doesn't need 30*e2eeea75SSimon J. Gerraty# to be an environment variable or a command line variable. 31*e2eeea75SSimon J. Gerraty. if exists(file-in-subdirectory) 32*e2eeea75SSimon J. Gerraty. error 33*e2eeea75SSimon J. Gerraty. endif 34*e2eeea75SSimon J. Gerraty. if exists(file2-in-subdirectory) 35*e2eeea75SSimon J. Gerraty. error 36*e2eeea75SSimon J. Gerraty. endif 372c3632d1SSimon J. Gerraty 382c3632d1SSimon J. Gerratyall: 39*e2eeea75SSimon J. Gerraty : ${exists(file-in-subdirectory):L:?yes 1:no 1} 40*e2eeea75SSimon J. Gerraty : ${exists(file2-in-subdirectory):L:?yes 2:no 2} 41*e2eeea75SSimon J. Gerraty 42*e2eeea75SSimon J. Gerraty.endif 43