The GNU Make Book - Demystifying Linux Build Automation

The GNU Make Book
The GNU Make Book.

As well as writing about Linux and writing reviews and tutorials about distributions and tools I am also heavily involved in software development. Unfortunately, 99.9% of that software development takes place on the Windows platform.

I have over 20 years experience as a C++, Visual Basic, VB.NET, and C# developer and I am also a dab hand with SQL Server both as a DBA and a developer.

What I am not so good at is developing software for Linux. It is just something I have never really bothered with. The main reason is that after developing software during the day the last thing I want to do is sit around of an evening writing more software.

I do obviously like tinkering with scripting and writing the odd small program. These are usually for electronics based projects on the Raspberry PI.

One thing that many developers on the Windows platform will have trouble with when they first move over to Linux is learning about the tools required to build and package applications.

By far the easiest type of application to develop are web applications because generally they don't require compiled code (PHP, Perl, Python) and the files are deployed to a set place on the web server.

A large number of applications built for Linux are developed using C, C++ or Python. Compiling a single C program is relatively easy but when you need to compile a number of C programs with multiple dependencies things get a bit more tricky.

GNU Make is a build automation scripting tool which helps you compile your applications again and again and in different ways. For example, you can supply a parameter which depending on the value will compile an application using 64-bit or 32-bit.

The GNU Make book has been written by John Graham-Cumming to help users of GNU Make get a firmer grip of the complexities associated with GNU Make.

The book is split into six chapters:

  1. The Basics Revisited
  2. Makefile Debugging
  3. Building and Rebuilding
  4. Pitfalls and Problems
  5. Pushing The Envelope
  6. The GNU Make Standard Library

I don't believe that the book is really aimed at beginners because it lacks certain clarifications that you would expect when learning a new subject such as "What is GNU Make?", "How do I create a Make file?", "Why is using Make better than compiling each program one by one?" and "How do I compile programs using GNU Make?". All of these subject areas are covered in the GNU Make manual.

The fact that the first chapter is called "The Basics Revisited" as opposed to "The Basics" clearly shows that you are expected to have a grounding in the subject matter before you begin.

The first chapter covers all the basics such as the use of variables, environments used by commands and the $(Shell) environment. As the chapter moves on you get into the subject of comparison, lists, and user defined functions.

If you have been using GNU Make for a little while but do not yet consider yourself an expert there are some nice hints and tips which will help you understand certain intricacies that may not be immediately apparent.

The second chapter will be a godsend for those of you who have been trying to trap errors in build scripts. The "Makefile Debugging" section is full of excellent hints and tips for debugging Makefiles and includes sections on printing variable values and even dumping the value of every variable. Further on into the chapter, there is a guide to the GNU Debugger which you can use to step through scripts.

The third chapter includes example makefiles but more than that shows you how to create Makefiles that you can run again and again.

"Pitfalls and Problems" looks at the differences between certain terms such as = and :=, and ifndef and ?=.

I found as I went further through the book that because I am not actively trying to use GNU Make and because my knowledge is at a very basic level some of the subject matter went very much over my head.

By the time I got to the "Pushing The Envelope" chapter my eyes glazed over somewhat.

My main summary, if I had to sum up this book, is that the author clearly knows his stuff and has tried to pass on as much information as possible.

The problem is that sometimes when a subject matter expert tries to write something down they have this "oh its easy, all you have to do is ...." aura about them.

The rubber seal on my back door came off last week and as it is just a couple of years old I called the company that fitted it as it is still in warranty.

The lady on the phone said, "oh that is ok, I will send you a new seal out".

I said "Oh do I have to fit it myself? Is that something I can do".

The response was "Sure you can, all you have to do is take off the door, fit the seal and put the door back on".

Now my instant thought was "woah, rewind a bit there. take off the door?!?". I am not qualified to remove a door, fit a seal and refit the door. I leave that to the experts.

With this book, I feel that you need another book and a certain amount of experience writing Makefiles before you would find it useful.

I think the hints, tips, and knowledge provided would help some people say "Oh, so that is why that does that" or "I didn't realize that you could do it that way".

My assessment is therefore that you should buy this book if you are seeking clarification or more intermediate to advanced knowledge on GNU Make but it isn't a book for beginners.