]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bmake/unit-tests/envfirst.mk
Merge bmake-20201117
[FreeBSD/FreeBSD.git] / contrib / bmake / unit-tests / envfirst.mk
1 # $NetBSD: envfirst.mk,v 1.4 2020/11/09 20:50:56 rillig Exp $
2 #
3 # The -e option makes environment variables stronger than global variables.
4
5 .MAKEFLAGS: -e
6
7 .if ${FROM_ENV} != value-from-env
8 .  error ${FROM_ENV}
9 .endif
10
11 # Try to override the variable; this does not have any effect.
12 FROM_ENV=       value-from-mk
13 .if ${FROM_ENV} != value-from-env
14 .  error ${FROM_ENV}
15 .endif
16
17 # Try to append to the variable; this also doesn't have any effect.
18 FROM_ENV+=      appended
19 .if ${FROM_ENV} != value-from-env
20 .  error ${FROM_ENV}
21 .endif
22
23 # The default assignment also cannot change the variable.
24 FROM_ENV?=      default
25 .if ${FROM_ENV} != value-from-env
26 .  error ${FROM_ENV}
27 .endif
28
29 # Neither can the assignment modifiers.
30 .if ${FROM_ENV::=from-condition}
31 .endif
32 .if ${FROM_ENV} != value-from-env
33 .  error ${FROM_ENV}
34 .endif
35
36 # Even .undef doesn't work since it only affects the global context,
37 # which is independent from the environment variables.
38 .undef FROM_ENV
39 .if ${FROM_ENV} != value-from-env
40 .  error ${FROM_ENV}
41 .endif
42
43 all:
44         @: nothing