UP | HOME

Make

The fastest way to start building things.

That one Make trick

I used to work with jgc, and he told me about this trick:

print-%: ; @echo '$(subst ','\'',$*=$($*))'

It allows you to print the value of any variable, handy for debugging.

Linking order

I went on a kick of using CMake for a bit and it just handled this transparently. Today, I handwrote a Makefile where I was running into issues building a package with ncurses, then I remembered this dumb fact: with gcc, you need to link the libs last. That is,

$(CC) $(LDLIBS) -o $@ $<

won't work, you need

$(CC) -o $@ $< $(LDLIBS)