From: Paul Eggert Date: Sat, 1 Jun 2024 16:07:38 +0000 (-0700) Subject: Document Solaris ‘make’ glitch with ‘!’ X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e51e789ac9953ad75574784cf3cb5d04c703805b;p=thirdparty%2Fautoconf.git Document Solaris ‘make’ glitch with ‘!’ * doc/autoconf.texi (Failure in Make Rules): Document that there are some complicated exceptions to the idea that sh -e exits if any subcommand fails. (Command Line Prefixes): New section. --- diff --git a/doc/autoconf.texi b/doc/autoconf.texi index c36eefdbe..9c05eceea 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -527,7 +527,8 @@ Portable Make Programming * $< in Ordinary Make Rules:: $< in ordinary rules * Failure in Make Rules:: Failing portably in rules -* Special Chars in Names:: Special Characters in Macro Names +* Command Line Prefixes:: What's at the start of makefile command lines +* Special Chars in Names:: Special characters in macro names * Backslash-Newline-Empty:: Empty lines after backslash-newline * Backslash-Newline Comments:: Spanning comments across line boundaries * Long Lines in Makefiles:: Line length limitations @@ -20379,7 +20380,8 @@ itself. @menu * $< in Ordinary Make Rules:: $< in ordinary rules * Failure in Make Rules:: Failing portably in rules -* Special Chars in Names:: Special Characters in Macro Names +* Command Line Prefixes:: What's at the start of makefile command lines +* Special Chars in Names:: Special characters in macro names * Backslash-Newline-Empty:: Empty lines after backslash-newline * Backslash-Newline Comments:: Spanning comments across line boundaries * Long Lines in Makefiles:: Line length limitations @@ -20411,10 +20413,13 @@ later) @command{make} diagnoses these uses and errors out. @node Failure in Make Rules @section Failure in Make Rules +Unless errors are being ignored +(e.g., because a makefile command line is preceded by a @samp{-} prefix), Posix 2008 requires that @command{make} must invoke each command with the equivalent of a @samp{sh -e -c} subshell, which causes the subshell to exit immediately if a subsidiary simple-command fails, -although not all @command{make} implementations have historically +with some complicated exceptions. +Historically not all @command{make} implementations followed this rule. For example, the command @samp{touch T; rm -f U} may attempt to remove @file{U} even if the @command{touch} fails, although this is not @@ -20428,6 +20433,24 @@ are worried about porting to buggy BSD shells it may be simpler to migrate complicated @command{make} actions into separate scripts. +@node Command Line Prefixes +@section Makefile Command Line Prefixes + +Makefile command lines can be preceded by zero or more of +the command line prefixes @samp{-}, @samp{@@}, and @samp{+}, +which modify how @command{make} processes the command. +Although Posix says these are the only command line prefixes, +some @command{make} implementations, such as Solaris @command{make}, +support the additional prefixes @samp{!} and @samp{?}. +Portable makefiles should therefore avoid using these two characters at +the start of a makefile command line. +For example: + +@example +mishandled-by-Solaris-make:; ! grep FIXME foo.c +portable-to-Solaris-make:; :;! grep FIXME foo.c +@end example + @node Special Chars in Names @section Special Characters in Make Macro Names