manpagez: man pages & more
info autoconf
Home | html | info | man

File: autoconf.info,  Node: Newlines in Make Rules,  Next: Comments in Make Macros,  Prev: Comments in Make Rules,  Up: Portable Make

12.12 Newlines in Make Rules
============================

In shell scripts, newlines can be used inside string literals.  But in
the shell statements of ‘Makefile’ rules, this is not possible: a
newline not preceded by a backslash separates commands, whereas a
newline preceded by a backslash becomes part of the shell statement.
So, how can a newline be used in a string literal?

   The trick is to set up a shell variable ‘nl’ that contains a newline.
For example, the following uses a multi-line ‘sed’ expression that
appends an empty line after every line of a file:

     output: input
             eval "$$(printf 'nl="\n"\n')"; \
             sed "a\\$$nl" input >$@

© manpagez.com 2000-2026
Individual documents may contain additional copyright information.