[talk] very handy gmake trick

Marc Spitzer mspitzer at gmail.com
Fri Apr 10 17:50:09 EDT 2015


the core is:

If you're using GNU make and you need help debugging a makefile then
there's a single line your should add. And it's so useful that you should
add it to every makefile you create.

It's:

    print-%: ; @echo $*=$($*)

It allows you to quickly get the value of any makefile variable. For
example, suppose you want to know the value of a variable called
SOURCE_FILES. You'd just type:

    make print-SOURCE_FILES

If you are using GNU make 3.82 or above it's not even necessary to modify
the makefile itself. Just do

    make --eval="print-%: ; @echo $*=$($*)" print-SOURCE_FILES

to get the value of SOURCE_FILES. It 'adds' the line above to the makefile
by evaluating it. The --eval parameteris a handy way of adding to an
existing makefile without modifying it.

And a bit more at the below link

http://blog.jgc.org/2015/04/the-one-line-you-should-add-to-every.html


File under stupid, but handy, unix tricks

Marc
-- 
Freedom is nothing but a chance to be better.
--Albert Camus

The inherent vice of capitalism is the unequal sharing of blessings; the
inherent virtue of socialism is the equal sharing of miseries.
-- Winston Churchill

Do the arithmetic or be doomed to talk nonsense.
--John McCarthy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nycbug.org/pipermail/talk/attachments/20150410/e557113d/attachment.html>


More information about the talk mailing list