1# $NetBSD: posix-varassign.mk,v 1.1 2025/04/13 09:29:33 rillig Exp $ 2# 3# https://pubs.opengroup.org/onlinepubs/9799919799/utilities/make.html#tag_20_76_13_05 4# 5# Test that variable assignments work in the same way as in default mode. 6# 7# The assignment operators "::=" and ":::=" are intentionally not supported, 8# as they would introduce the distinction between eagerly and lazily evaluated 9# macros, in addition to the eagerly and lazily evaluated assignments, and 10# this would add too much complexity to the user's mental model, for too 11# little benefit. 12 13.POSIX: 14 15 16VAR= value 17.if ${VAR} != "value" 18. error 19.endif 20 21 22# Deviation from POSIX: The "::=" assignment operator is not supported, 23# instead, the variable named "VAR:" is defined. 24VAR= before 25VAR::= posix-immediate-expansion 26.if ${VAR} != "before" 27. error 28.elif ${${:UVAR\:}} != "posix-immediate-expansion" 29. error 30.endif 31 32 33# Deviation from POSIX: The ":::=" assignment operator is not supported, 34# instead, the variable named "VAR::" is defined. 35VAR:::= posix-delayed-expansion 36.if ${VAR} != "before" 37. error 38.elif ${${:UVAR\:\:}} != "posix-delayed-expansion" 39. error 40.endif 41 42 43VAR!= echo from shell command 44.if ${VAR} != "from shell command" 45. error 46.endif 47 48 49VAR= value 50VAR?= fallback 51.if ${VAR} != "value" 52. error 53.endif 54.undef VAR 55VAR?= fallback 56.if ${VAR} != "fallback" 57. error 58.endif 59 60 61VAR= value 62VAR+= appended 63.if ${VAR} != "value appended" 64. error 65.endif 66 67 68# In POSIX mode, the ":=" assignment operator is available as well, even 69# though it is not specified by POSIX, due to the differences in existing 70# make implementations. 71REF= before 72VAR:= immediate ${REF} 73REF= after 74.if ${VAR} != "immediate before" 75. error 76.endif 77 78 79all: 80