xref: /freebsd/contrib/bmake/unit-tests/varmod-path.mk (revision c66ec88fed842fbaad62c30d510644ceb7bd2d71)
1# $NetBSD: varmod-path.mk,v 1.3 2020/08/23 08:10:49 rillig Exp $
2#
3# Tests for the :P variable modifier, which looks up the path for a given
4# target.
5#
6# The phony target does not have a corresponding path, therefore ... oops,
7# as of 2020-08-23 it is nevertheless resolved to a path.  This is probably
8# unintended.
9#
10# The real target is located in a subdirectory, and its full path is returned.
11# If it had been in the current directory, the difference between its path and
12# its name would not be visible.
13#
14# The enoent target does not exist, therefore the target name is returned.
15
16.MAIN: all
17
18_!=	rm -rf varmod-path.subdir
19_!=	mkdir varmod-path.subdir
20_!=	> varmod-path.subdir/varmod-path.phony
21_!=	> varmod-path.subdir/varmod-path.real
22
23# To have an effect, this .PATH declaration must be after the directory is created.
24.PATH: varmod-path.subdir
25
26varmod-path.phony: .PHONY
27varmod-path.real:
28
29all: varmod-path.phony varmod-path.real
30	@echo ${varmod-path.phony:P}
31	@echo ${varmod-path.real:P}
32	@echo ${varmod-path.enoent:P}
33
34.END:
35	@rm -rf varmod-path.subdir
36