varname-dot-curdir.mk revision 1.7 1 1.7 rillig # $NetBSD: varname-dot-curdir.mk,v 1.7 2020/10/08 19:09:08 rillig Exp $
2 1.1 rillig #
3 1.7 rillig # Tests for the special .CURDIR variable, which is initially set to the
4 1.7 rillig # canonical path of the current working directory, when make started.
5 1.1 rillig
6 1.7 rillig # In all normal situations, the current directory exists, and its name can
7 1.7 rillig # be resolved. If not, make fails at startup.
8 1.7 rillig #
9 1.7 rillig # It would be possible on some systems to remove the current directory, even
10 1.7 rillig # while a process runs in it, but this is so unrealistic that it's no worth
11 1.7 rillig # testing.
12 1.7 rillig .if !exists(${.CURDIR})
13 1.7 rillig . error
14 1.7 rillig .endif
15 1.7 rillig .if !exists(${.CURDIR}/)
16 1.7 rillig . error
17 1.7 rillig .endif
18 1.7 rillig .if !exists(${.CURDIR}/.)
19 1.7 rillig . error
20 1.7 rillig .endif
21 1.7 rillig .if !exists(${.CURDIR}/..)
22 1.7 rillig . error
23 1.7 rillig .endif
24 1.1 rillig
25 1.6 rillig # Until 2020-10-04, assigning the result of a shell assignment to .CURDIR
26 1.6 rillig # tried to add the shell command ("echo /") to the .PATH instead of the
27 1.6 rillig # output of the shell command ("/"). Since "echo /" does not exist, the
28 1.6 rillig # .PATH was left unmodified. See VarAssign_Eval.
29 1.6 rillig #
30 1.6 rillig # Since 2020-10-04, the output of the shell command is added to .PATH.
31 1.6 rillig .CURDIR!= echo /
32 1.6 rillig .if ${.PATH:M/} != "/"
33 1.6 rillig . error
34 1.6 rillig .endif
35 1.6 rillig
36 1.6 rillig # A normal assignment works fine, as does a substitution assignment.
37 1.6 rillig # Appending to .CURDIR does not make sense, therefore it doesn't matter that
38 1.6 rillig # this code path is buggy as well.
39 1.6 rillig .CURDIR= /
40 1.6 rillig .if ${.PATH:M/} != "/"
41 1.6 rillig . error
42 1.6 rillig .endif
43 1.6 rillig
44 1.1 rillig all:
45 1.1 rillig @:;
46