How can I highlight the warning and error lines in the make output?

Viewed 31033

Sometimes, make's output fills the screen. It's a little bit hard to identify all the warning and error message lines. I know may shell color output can help Can anyone can help me?

8 Answers

On Mac, it worked by printing tput color codes around the error string.

First export tput color codes as below:

export red=`tput setaf 1`
export reset=`tput sgr0`

then, add a target to Makefile as below:

...
check-env:
ifndef ENV
    $(error ${red}ENV is undefined. Please export it using command [ export ENV=dev ]${reset})
endif
...

then, run it as make check-env

Screen shot - enter image description here

GCC has an environment variable for that:

export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
Related