1# $NetBSD: opt-env.mk,v 1.4 2022/03/26 13:32:31 rillig Exp $ 2# 3# Tests for the -e command line option, which looks up environment variables 4# before those from the global scope. It has no influence on variables from 5# the command line though. 6# 7# This option is required by POSIX. 8 9# The variable FROM_ENV is defined in ./Makefile. 10 11.MAKEFLAGS: -e 12 13.if ${FROM_ENV} != value-from-env 14. error ${FROM_ENV} 15.endif 16 17# Try to override the variable; this does not have any effect. 18FROM_ENV= value-from-mk 19.if ${FROM_ENV} != value-from-env 20. error ${FROM_ENV} 21.endif 22 23# Try to append to the variable; this also doesn't have any effect. 24FROM_ENV+= appended 25.if ${FROM_ENV} != value-from-env 26. error ${FROM_ENV} 27.endif 28 29# The default assignment also cannot change the variable. 30FROM_ENV?= default 31.if ${FROM_ENV} != value-from-env 32. error ${FROM_ENV} 33.endif 34 35# Neither can the assignment modifiers. 36.if ${FROM_ENV::=from-condition} 37.endif 38.if ${FROM_ENV} != value-from-env 39. error ${FROM_ENV} 40.endif 41 42# Even .undef doesn't work since it only affects the global scope, 43# which is independent from the environment variables. 44.undef FROM_ENV 45.if ${FROM_ENV} != value-from-env 46. error ${FROM_ENV} 47.endif 48 49all: .PHONY 50