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