1 1.5 rillig # $NetBSD: varname-dot-newline.mk,v 1.5 2023/01/17 19:42:47 rillig Exp $ 2 1.1 rillig # 3 1.5 rillig # Tests for the special .newline variable, which contains a single newline 4 1.5 rillig # character (U+000A). 5 1.5 rillig 6 1.5 rillig 7 1.5 rillig # https://austingroupbugs.net/view.php?id=1549 proposes: 8 1.5 rillig # > After all macro expansion is complete, when an escaped <newline> is 9 1.5 rillig # > found in a command line in a makefile, the command line that is executed 10 1.5 rillig # > shall contain the <backslash>, the <newline>, and the next line, except 11 1.5 rillig # > that the first character of the next line shall not be included if it is 12 1.5 rillig # > a <tab>. 13 1.3 rillig # 14 1.5 rillig # The above quote assumes that each resulting <newline> character has a "next 15 1.5 rillig # line", but that's not how the .newline variable works. 16 1.5 rillig BACKSLASH_NEWLINE:= \${.newline} 17 1.5 rillig 18 1.5 rillig 19 1.3 rillig # Contrary to the special variable named "" that is used in expressions like 20 1.3 rillig # ${:Usome-value}, the variable ".newline" is not protected against 21 1.3 rillig # modification. Nobody exploits that though. 22 1.3 rillig 23 1.3 rillig NEWLINE:= ${.newline} 24 1.3 rillig 25 1.3 rillig .newline= overwritten 26 1.3 rillig 27 1.3 rillig .if ${.newline} == ${NEWLINE} 28 1.4 rillig . info The .newline variable cannot be overwritten. Good. 29 1.3 rillig .else 30 1.4 rillig . info The .newline variable can be overwritten. Just don't do that. 31 1.3 rillig .endif 32 1.1 rillig 33 1.3 rillig # Restore the original value. 34 1.3 rillig .newline= ${NEWLINE} 35 1.1 rillig 36 1.1 rillig all: 37 1.3 rillig @echo 'first${.newline}second' 38 1.5 rillig @echo 'backslash newline: <${BACKSLASH_NEWLINE}>' 39