On NixOS, there is no `/bin/echo`, instead
`which echo` will return
/home/benpicco/.nix-profile/bin/echo
so hard-coding the path will break here.
Use `/usr/bin/env` to get the path of `echo`.
This should be availiable on all systems at the same location.
If CC_NOCOLOR was not set by the user it was set according to the
terminal support of colored output.
But since CC_NOCOLOR is also used to set `-fdiagnostics-color` flags
this means changing `CFLAGS` according to terminal support of colored
output.
This is not needed for `-fdiagnostics-color` since this option is by
default `auto` if the compiler supports colored output, and `auto`
means it will only use color when standard error is a terminal.
The current code for detecting whether colors should be used by default
was not working. Normally what programs such as git or grep do is check
if they are writing to a pipe.
To see the issue by yourself:
$ BOARD=samr21-xpro make -C tests/periph_qdec > I_SHOULD_NOT_HAVE_COLORS 2>&1
This commit uses MAKE_TERMOUT, MAKE_TERMERR and if ANY of them is NOT
a terminal, colors are disabled.