Thursday, April 09, 2015

"The GNU Make Book": probably more than you ever wanted to know about make

So, it's finally here. My second book, entitled The GNU Make Book and published by No Starch Press later this month (electronically it's available now). If you are a long time reader of my blog then you'll know that I've had a very long interest in GNU make and written quite a bit about it. For a while I had self-published all my articles on GNU make as a print on demand book.

The folks at No Starch Press kindly took my self-published effort and did the serious work of actually editing, organizing, indexing and generally sprucing it up. I added some articles that weren't in the old version and updated for GNU make 4.0.

And now it's here.



The book is not intended for people learning GNU make from scratch. If you need to do that go get the FSF's GNU make manual and read it. It covers all that you need to get started with GNU make.

Once you've done that you'll be ready to read mine. It's based on years of working with real makefiles, on having written a complete emulation of GNU make and having created the GNU Make Standard Library project.

It's thoroughly practical and I hope the ideas and techniques in it will prove useful to real-world makefile writers and maintainers. If you're interested there's sample chapter and Table of Contents.


3 comments:

Nick Alcock said...

I cannot recommend this book enough. I bought the previous version, printed it out, and am now trying to convince myself that the updates are surely worth paying for it again :) I suspect I will succumb fairly fast.

David L Ward said...

errata
I have make 3.81 on ubuntu 14.4
p8 env_file lacks line continuation \ chars


p82 @echo "S(subst ",\" - should be $ not S

p92 using gcc -MP
does not compile
# ~/gnumake/g_c/code/ch3/p92-> make
# cc1: error: to generate dependencies you must specify either -M or -MM
# make: *** [hello_fn.o] Error 1
# ~/gnumake/g_c/code/ch3/p92->


p98
include $(addsuffix /makefile,$(SUBDIRS ))
for the code that follows should be 'Makefile'

p125
' make strips all leading and trailing whitespace around function arguments'
I think this only applies to ws before the first argument. You could add that no whitespace should appear between '$(' and function name

p127
if-exists
misplaced '(' ($wildcard $1), ....
should be $(if $(wildcard $1),$2,$3)

p135

$(OUT)foo.o : ... should be $(OUT)/foo.o



p146
basename is /foo/bar/source NOT source

p165
'It converts both x-representation numbers to digits but compares --using $(filter-out) -- the first of them'
should be second


p167
bottom of page
should be make calc="1,3,-,3,21,5,*,+,/" not "3,1...
1,3,- gives 3-1=2
21*5 =105
105 +3 =108
108/2 =54 (LIFO)

p167 and p168
in input_int one too many closing parentheses


p205
$(call repeat 10,A) should be $(call repeat,A,10) --- $2 must be a numerical arg


Feedback

I found your treatment of non-recursive make very helpful and I liked your

David L Ward said...

errata
I have make 3.81 on ubuntu 14.4
p8 env_file lacks line continuation \ chars


p82 @echo "S(subst ",\" - should be $ not S

p92 using gcc -MP
does not compile
# ~/gnumake/g_c/code/ch3/p92-> make
# cc1: error: to generate dependencies you must specify either -M or -MM
# make: *** [hello_fn.o] Error 1
# ~/gnumake/g_c/code/ch3/p92->


p98
include $(addsuffix /makefile,$(SUBDIRS ))
for the code that follows should be 'Makefile'

p125
' make strips all leading and trailing whitespace around function arguments'
I think this only applies to ws before the first argument. You could add that no whitespace should appear between '$(' and function name

p127
if-exists
misplaced '(' ($wildcard $1), ....
should be $(if $(wildcard $1),$2,$3)

p135

$(OUT)foo.o : ... should be $(OUT)/foo.o



p146
basename is /foo/bar/source NOT source

p165
'It converts both x-representation numbers to digits but compares --using $(filter-out) -- the first of them'
should be second


p167
bottom of page
should be make calc="1,3,-,3,21,5,*,+,/" not "3,1...
1,3,- gives 3-1=2
21*5 =105
105 +3 =108
108/2 =54 (LIFO)

p167 and p168
in input_int one too many closing parentheses


p205
$(call repeat 10,A) should be $(call repeat,A,10) --- $2 must be a numerical arg


Feedback

I found your treatment of non-recursive make very helpful and I liked your