Skip to content

Make

Much to my chagrin, I seem to be finding myself in need of understanding and making fundamental changes to Makefiles for various projects I’m not familiar with, every few months.

I’ve found the

$(warning "foo")
and
$(error "foo")
directives pretty useful in this capacity, the former printing some text during a Makefile’s evaluation, and the latter printing and then stopping execution.

I’ve also found Make’s manual surprisingly well-written and handy. :|

Make’s syntax can get pretty hairy, and it’s important to hold your project’s Makefiles up to the same standards as you would your own code. That is - commenting (where appropriate) and hopefully also code reviews.

It would be nice if more projects could use alternative build tools, maybe I’ll write more about that some other time.

{ 2 } Comments

  1. Yossi Kreinin MonsterID Icon Yossi Kreinin | May 20, 2008 at 11:04 am | Permalink

    Um, yeah, $(error) and $(warning) sure are damn useful, ‘CAUSE MAKE DOESN’T HAVE ANY OTHER FRIGGING WAY TO PRINT ANYTHING!! Oh, and neither of those kludges can help you figure out the order in which rules are looked up and checked, among other things. It’s a good thing we have make -d and (gasp) remake to sorta kinda approximate debugging.

    But, c’mon, give us some details! Is it the standard subset of make or GNU make? Do you use the brain-crippled functional facilities such as $(call) and $(foreach)? What about indirection via $($x)? How do you deal with slowdowns caused by command evaluation - by trying hard to not invoke the shell, or by checking for $(MAKELEVEL) to cache results of process invocations? Is the whole dependency tree checked by one hairy Makefile or is make invoked recursively? Do home-made tools count on make’s cute habit of exporting variables as env vars or is it all orderly command line argument passing?

    The public wants to know! At least the parts of it buried in the stinky trenches of Makefile maintenance.

  2. Jeremy MonsterID Icon Jeremy | May 20, 2008 at 8:13 pm | Permalink

    Yeh, makefiles get really ugly really fast…

    On my present project we try to keep things very simple and organized, no obscure make features I think the worst we do is $(patsubst).

    Of course, our codebase is much much smaller than the one you have to wrangle so we don’t need all that “power”.

Post a Comment

Your email is never published nor shared. Required fields are marked *