aboutsummaryrefslogtreecommitdiff
path: root/contrib/bmake/unit-tests/varmod-path.mk
blob: ebbf755ddbec8edcc1adabad9b83492fee63caf9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# $NetBSD: varmod-path.mk,v 1.3 2020/08/23 08:10:49 rillig Exp $
#
# Tests for the :P variable modifier, which looks up the path for a given
# target.
#
# The phony target does not have a corresponding path, therefore ... oops,
# as of 2020-08-23 it is nevertheless resolved to a path.  This is probably
# unintended.
#
# The real target is located in a subdirectory, and its full path is returned.
# If it had been in the current directory, the difference between its path and
# its name would not be visible.
#
# The enoent target does not exist, therefore the target name is returned.

.MAIN: all

_!=	rm -rf varmod-path.subdir
_!=	mkdir varmod-path.subdir
_!=	> varmod-path.subdir/varmod-path.phony
_!=	> varmod-path.subdir/varmod-path.real

# To have an effect, this .PATH declaration must be after the directory is created.
.PATH: varmod-path.subdir

varmod-path.phony: .PHONY
varmod-path.real:

all: varmod-path.phony varmod-path.real
	@echo ${varmod-path.phony:P}
	@echo ${varmod-path.real:P}
	@echo ${varmod-path.enoent:P}

.END:
	@rm -rf varmod-path.subdir