Usually I am using echo -e "\e[1:32mMessage\e[0m"
to print colourful messages out of the makefile. But now I want to print message inside of the ifndef
block, so I am using $(info Message)
style. Is it possible to make this kind of message colourful ?
Yes. You can use a tool like tput
to output the literal escape sequences needed instead of using echo -e
(which isn't a good idea anyway) to do the same thing.
For example:
$(info $(shell tput setaf 1)Message$(shell tput sgr0))
Though that requires two shells to be spawned and two external commands to be run as opposed to the echo
(or similar) methods in a recipe context so that's comparatively more expensive.
You could (and should if you plan on using the colors in more than one place) save the output from tput
in a variable and then just re-use that.
red:=$(shell tput setaf 1)
reset:=$(shell tput sgr0)
$(info $(red)Message$(reset))
$(info $(red)Message$(reset))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With