Custom "echo" (for colored text) in a Makefile
<p>My (makefile-based) build system outputs quite an amount of diagnostics, and I wish to color them, as explained in <a href="https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux">this question</a> (preferably using <code>tput setaf</code> and <code>tput sgr0</code>).</p>

<p>However, editing all the strings from all my hierarchical Makefiles in my system would be an overwhelming and non-practical task (if I change my mind in the future, it would be another overwhelming task to undo it again).</p>

<p>Ideally, I'd like to have custom constructs like <code>my_warning_echo</code>, <code>my_error_echo</code>, etc..., exactly with the same syntax as <code>echo</code>.</p>

<p>For example, the syntax would be <code>my_warning_echo "some text message"</code> and the implementation would be such that outputs <code>@echo "$$(tput setaf 3)some text message$$(tput sgr0)</code> (the double $$ are because this will be used from inside a Makefile).</p>

<p>The main problem is with the closing <code>tput sgr0</code> (otherwise I could just use a macro that holds <code>@echo "$$(tput setaf 3)</code>).</p>

<p>I could also write a shell function taking one argument (the text message), but the syntax will require adding parentheses at the beginning and at the end of the message.</p>

<p>Is there any approach which would let me keep the same syntax as the standard <code>echo</code>?</p>

<p>Solutions that depend on GNU make would be fine (I prefer to be as standard as possible, but my build system already uses GNU make extensions, so...)</p>