Next: , Previous: $< in Ordinary Make Rules, Up: Portable Make


11.2 Failure in Make Rules

Since 1992 Posix has required that make must invoke each command with the equivalent of a `sh -c' subshell. However, many make implementations, including BSD make through 2004, use `sh -e -c' instead, and the -e option causes the subshell to exit immediately if a subsidiary simple-command fails. For example, the command `touch T; rm -f U' always attempts to remove U with Posix make, but incompatible make implementations skip the rm if the touch fails. One way to work around this is to reword the affected simple-commands so that they always succeed, e.g., `touch T || :; rm -f U'. However, even this approach can run into common bugs in BSD implementations of the -e option of sh and set (see Limitations of Builtins), so if you are worried about porting to buggy BSD shells it may be simpler to migrate complicated make actions into separate scripts.