
Lazy GNU make variables - jgrahamc
http://blog.jgc.org/2016/07/lazy-gnu-make-variables.html
======
FiloSottile
So, a couple days ago I shared a Makefile with John, meant to become the
standard Go project Makefile at CloudFlare. Here are the comments:

> John: This is very expensive. Can't it be calculated once (:=)?

> Me: The problem is that we don't want to calculate it if we don't need it,
> because we might run make before go is installed, and that would fail.

> John: [http://blog.jgc.org/2016/07/lazy-gnu-make-
> variables.html](http://blog.jgc.org/2016/07/lazy-gnu-make-variables.html)

I think he wrote this piece to answer my question.

That's working with great people right there.

~~~
chubot
Well, it was nice of him to send you a blog link, rather than telling you to
buy his book, which mentions this exact trick :)

[https://www.nostarch.com/gnumake](https://www.nostarch.com/gnumake)

~~~
jgrahamc
Many of the things in my book are on line in different places. The technique I
use in the book is here: [https://www.cmcrossroads.com/article/makefile-
optimization-e...](https://www.cmcrossroads.com/article/makefile-optimization-
eval-and-macro-caching) It uses a different technique and requires replacing
$(FOO) with $(call cache,FOO) everywhere.

The book comprises everything I've written about GNU make edited, rechecked
and cleaned up with additions to cover new GNU make features and a couple of
other things I hadn't written before.

~~~
dknecht
If you start asking him too many questions he does eventually just throw the
book at you (albeit a free autographed copy).

------
dima55
This is a fundamental part of Make. If it's news to anybody, PLEASE go read
the manual. Otherwise we will keep getting more and more new systems that
supposedly improve Make, written by and for people who never bothered to learn
how to use Make.

------
Animats
Make can't decide whether it's a dependency graph or a macro language. That
leads to weird semantics like this.

~~~
dozzie
You have rough corners in every language. Make is actually quite good
(meaning: easy to read, without much gymnastics) in its typical use case of
compiling a software project. The post was written specifically to explore one
of these rough corners everything has.

~~~
jessaustin
Reading it may be easy, but every time I've tried to _use_ make (i.e. write a
Makefile that does what I want) I've found it to be composed almost entirely
of rough corners.

------
typpytyper
Still learning things about GNU make after 20 years. Great software.

