xref: /freebsd/contrib/bmake/unit-tests/varmod-path.mk (revision 02e9120893770924227138ba49df1edb3896112a)
1# $NetBSD: varmod-path.mk,v 1.4 2023/05/10 15:53:32 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# In this test, the real target is located in a subdirectory, and its full
11# path is returned.  If it had been in the current directory, the difference
12# between its path and its name would not be visible.
13#
14# The enoent target does not exist, therefore the plain name of the target
15# is returned.
16
17.MAIN: all
18
19_!=	rm -rf varmod-path.subdir
20_!=	mkdir varmod-path.subdir
21_!=	> varmod-path.subdir/varmod-path.phony
22_!=	> varmod-path.subdir/varmod-path.real
23
24# To have an effect, this .PATH declaration must be processed after the
25# directory has been created.
26.PATH: varmod-path.subdir
27
28varmod-path.phony: .PHONY
29varmod-path.real:
30
31all: varmod-path.phony varmod-path.real
32	@echo ${varmod-path.phony:P}
33	@echo ${varmod-path.real:P}
34	@echo ${varmod-path.enoent:P}
35
36.END:
37	@rm -rf varmod-path.subdir
38