The GNU Make Programming Language

Published on 11 July 2023 (Updated: 05 October 2025)

Welcome to the GNU Make page! Here, you'll find a description of the language as well as a list of sample programs in that language.

This article was written by:

  • rzuckerm

Description

According to Wikipedia, make is an automated tool for building software. It was created in 1976 by Stuart Freedman for Unix systems, and it is still used today on Unix and Unix-like systems (such as Linux and MacOS). For such systems, GNU make is the most prevelant.

In general, make gets it instructions on what to build based on a Makefile. The syntax for a Makefile is like this:

target1 [target2 ...]: dependency1 [dependency2 ...]
    command1
    command2
    ...

The "target" is what is being built, "dependencies" are what the target depends upon, and "commands" are what is executed when the target is built. It should be noted make is a whitespace-sensitive language. Before each command, is a tab character. It you try to use spaces, you'll get this error:

*** missing separator.  Stop.

The way make works is that a target will be built if it does not exist or it is older that its dependencies.

Here's an example of file called Makefile (which is the default filename that make looks for):

hello: hello.c
    cc hello.c -o hello

It build a single C program called hello.c into a executable called hello. The command perform this build is this:

make hello

If hello does not exist, or if hello.c was modified after hello was built, the cc command is executed the builds the code. If the make command is run again, it will indicate 'hello' is up to date.

In addition to being a build system, GNU make also has a number of other useful features:

  • Variables that can be used for everything from simple assignment to defining user-defined functions in the form of macros.
  • Built-in functions for manipulating text.
  • Conditionals that can be used to ignore or include certain portions of a Makefile.

Although GNU make is not really intended as a programming language, these features allow it to behave as if it were. It can even similate control flow with certain built-in functions like these:

Loops can be simulated using macros that invoke themselves recursively.

Articles

There are 9 articles: