Next: , Previous: , Up: Portable Make   [Contents][Index]


12.2 Failure in Make Rules

Posix 2008 requires that make must invoke each command with the equivalent of a ‘sh -e -c’ subshell, which causes the subshell to exit immediately if a subsidiary simple-command fails, although not all make implementations have historically followed this rule. For example, the command ‘touch T; rm -f U’ may attempt to remove U even if the touch fails, although this is not permitted with Posix make. One way to work around failures in simple commands is to reword them 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 Shell Builtins), so if you are worried about porting to buggy BSD shells it may be simpler to migrate complicated make actions into separate scripts.