Home | History | Annotate | Line # | Download | only in unit-tests
varname-dot-newline.mk revision 1.6
      1  1.6     sjg # $NetBSD: varname-dot-newline.mk,v 1.6 2023/01/26 20:48:18 sjg 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.6     sjg # Check that .newline is read-only
     20  1.3  rillig 
     21  1.3  rillig NEWLINE:=	${.newline}
     22  1.3  rillig 
     23  1.3  rillig .newline=	overwritten
     24  1.3  rillig 
     25  1.6     sjg .if ${.newline} != ${NEWLINE}
     26  1.6     sjg .  error The .newline variable can be overwritten.  It should be read-only.
     27  1.3  rillig .endif
     28  1.1  rillig 
     29  1.1  rillig all:
     30  1.3  rillig 	@echo 'first${.newline}second'
     31  1.5  rillig 	@echo 'backslash newline: <${BACKSLASH_NEWLINE}>'
     32