Suppress make rule error output
Solution 1:
Another way to suppress the make: error ... (ignored)
output is to append || true
to a command that could fail. Example with grep that checks for errors in a LaTeX log file:
undefined:
@grep -i undefined *.log || true
Without the || true
, make complains when grep fails to find any matches.
This works for all commands, not just mkdir; that's why I added this answer.
Solution 2:
The error is ignored already by the leading '-
' on the command line. If you really want to lose the error messages from mkdir
, use I/O redirection:
bin:
-mkdir bin 2> /dev/null
You will still get the 'ignored' warning from make
, though, so it might be better to use the option to mkdir
that doesn't cause it to fail when the target already exists, which is the -p
option:
MKDIR_P = mkdir -p
bin:
${MKDIR_P} $@
The -p
option actually creates all the directories that are missing on the given paths, so it can generate a a number of directories in one invocation, but a side-effect is that it does not generate an error for already existing directories. This does assume a POSIX-ish implementation of mkdir
; older machines may not support it (though it has been standard for a long time now).