1*f6f18f84Ssjg# $NetBSD: varname-dot-newline.mk,v 1.6 2023/01/26 20:48:18 sjg Exp $
21fb97e4bSrillig#
3cac038deSrillig# Tests for the special .newline variable, which contains a single newline
4cac038deSrillig# character (U+000A).
5cac038deSrillig
6cac038deSrillig
7cac038deSrillig# https://austingroupbugs.net/view.php?id=1549 proposes:
8cac038deSrillig# > After all macro expansion is complete, when an escaped <newline> is
9cac038deSrillig# > found in a command line in a makefile, the command line that is executed
10cac038deSrillig# > shall contain the <backslash>, the <newline>, and the next line, except
11cac038deSrillig# > that the first character of the next line shall not be included if it is
12cac038deSrillig# > a <tab>.
13b0182658Srillig#
14cac038deSrillig# The above quote assumes that each resulting <newline> character has a "next
15cac038deSrillig# line", but that's not how the .newline variable works.
16cac038deSrilligBACKSLASH_NEWLINE:=	\${.newline}
17cac038deSrillig
18cac038deSrillig
19*f6f18f84Ssjg# Check that .newline is read-only
201fb97e4bSrillig
21b0182658SrilligNEWLINE:=	${.newline}
22b0182658Srillig
23b0182658Srillig.newline=	overwritten
24b0182658Srillig
25*f6f18f84Ssjg.if ${.newline} != ${NEWLINE}
26*f6f18f84Ssjg.  error The .newline variable can be overwritten.  It should be read-only.
27b0182658Srillig.endif
28b0182658Srillig
291fb97e4bSrilligall:
30b0182658Srillig	@echo 'first${.newline}second'
31cac038deSrillig	@echo 'backslash newline: <${BACKSLASH_NEWLINE}>'
32