Make Knowledge

Kip Landergren

My Make knowledge base that evolves as I learn more.

Contents

Overview

make is build automation software which specializes in compiling C/C++ projects but can be used generally in any scenario where your desired outputs are files.

A makefile—typically with the name Makefile—stores rules which contain information on when and how to create these outputs.

A rule is comprised of:

This information is then used when make is invoked with a target name.

Using prerequisites allows the creation of a dependency graph for the desired output. make makes the assumption that if an output’s inputs are newer than the output, it should be rebuilt. The proxy used for this “newer” assumption is the file’s modified time. The contents of the file are not compared between invocations.

Core Idea

The big idea here is that make allows the creation of a dependency graph of deterministic build steps—targets—of which only a subset may need to be rebuilt. This efficiency allows make to rebuild projects very quickly.

You can think of a makefile as a recipe book and make as a hyper-efficient cook obsessed with freshness who refuses to remake a component ingredient unless its own ingredients are fresher.

So, in essence:

You now have all the outputs of your project captured in a single place that is easily viewed, modified, and able to be efficiently invoked.

Make Terminology

makefile
a file that contains rules which tell make what to do
phony target
a target that does not generate a file of the same name
prerequisite
a file that is used as input to create the target
recipe
the action—commands—that make carries out for a rule
rule
the collection of information used to determine when and how to remake certain files
target
the name of a file generated by the rule, except in special cases like phony targets