Trailing backslashes in Makefile

Michael H. Warfield mhw at
Thu Dec 3 16:16:31 GMT 1998

Alexandre Oliva enscribed thusly:
> On Dec  3, 1998, "Michael H. Warfield" <mhw at> wrote:

> > Alexandre Oliva enscribed thusly:

> >> The problem is when a line ended with a backslash is followed by a
> >> blank line.  This breaks various make programs :-(

> > 	The problem there is that the blank line becomes part of the
> > "continued" line (the \) and you are then no longer left with the
> > prerequisit blank separator line between it and the next...

> Huh?  IMO, there's nothing wrong with the following Makefile snippet,
> but various make programs disagree:

> --->cut<---
> FOO = whatever \
> # note the blank lines above
> BAR = something else
> --->cut<---

	Right!  You have TWO blank lines in there.  The '\' on the FOO =
line says to continue and append the next line.  Then you have an additional
separator line below it.  This is also a set of definition lines and they
can be stacked one after another, anyways.

> Broken makes will just go berzerk when presented a Makefile containing
> a trailing backslash followed by a blank line, no matter how many
> blank lines you have.  They will end up printing random error messages 
> in unrelated lines.  This kind of Makefile program is very annoying
> and hard to find :-(

	I would agree that if the make program generates an error with
a trailing '\' followed by two blank lines, it's definitely broken, but
I haven't seen that.  A make program that complains when a line with a
trailing '\' is followed by one blank line in a dependency is IMHO not
broken.  It's merely following the established rules for concatenating
continuation lines.  The test I would apply in this case would be to
remove the trailing '\' and the blank line below it and see if the
error remains the same.  If the error changes, then I agree, the make
program is buggy.  If the error remains the same, then evaluate the
syntax error in that circumstance.

> > I'm actually surprised that gnu make accepts this since it implies
> > that either they have 1) special case code for a continuation line
> > followed by a terminating blank line

> Although it's unrelated with the bug we were discussing, there's no
> requirement that a set of commands is followed by a blank line.  The
> sequence of commands can be broken by a line containing another
> dependency, as long as it does not start with a TAB.

	That also may be where some of the differences are at.  Some versions
of make DO require the blank line.  Yes, these are the older make programs
in the AT&T lineage, but they do exist.

	There is also a difference between sections that are merely defining
symbols, where you can stack them one right after another, or defining
dependencies, relationships, and commands.

	In any case, we do have these makes out there and it's simple
enough to avoid the problem.  I have yet to hear any reason why we should
have the trailing backslash, so I would argue the old country doctor's
advice that if it hurts when you do that then stop doing that...

> -- 
> Alexandre Oliva  aoliva@{}
> oliva@{,,,}
> Universidade Estadual de Campinas, SP, Brasil

 Michael H. Warfield    |  (770) 985-6132   |  mhw at
  (The Mad Wizard)      |  (770) 925-8248   |
  NIC whois:  MHW9      |  An optimist believes we live in the best of all
 PGP Key: 0xDF1DD471    |  possible worlds.  A pessimist is sure of it!

More information about the samba-technical mailing list