GNU Make 4 cheatsheet

GNU Make 4: Running make

8 common GNU Make 4 tasks.

Run a target

Run one specific target from the Makefile.

make test

Preview the commands

Print what would run without running it.

make -n deploy

Build in parallel

Run up to four jobs at once. Use $(nproc) for one per CPU core.

make -j4

Set a variable on the command line

Command-line variables override those in the Makefile.

make CC=clang DEBUG=1

Force a rebuild

Rebuild everything even if files look up to date.

make -B

Use another Makefile

Read a different file, or run in another directory.

make -f build.mk
make -C subdir

Continue after errors

Keep building independent targets after a failure.

make -k

Print why targets are rebuilt

Show make's decisions, useful when a target rebuilds unexpectedly.

make --debug=b

Was this page helpful?