make commands cheatsheet.
Run targets, build in parallel, override variables and control rebuilds — the GNU Make commands you reach for. Tap to copy.
makeRun the default (first) target in the Makefilemake <target>Run a specific named targetmake -C <dir> <target>Change to a directory before running makemake allBuild the conventional "all" targetmake cleanRemove build artifacts (conventional target)make installInstall the built program (conventional target)make -jRun recipes in parallel with unlimited jobsmake -j4Run up to 4 recipes in parallelmake -f <file>Use an alternate Makefilemake -nDry run — print commands without running themmake -BUnconditionally rebuild every targetmake -kKeep going after a target failsmake -sSilent — don't echo recipe commandsmake -iIgnore all errors in recipesmake --debugPrint debugging information while buildingmake -dPrint full (verbose) debug informationmake -pPrint the rules and variables databasemake -qQuestion mode — set exit status, run nothingmake VAR=value <target>Override a variable from the command linemake -eLet environment variables override the Makefilemake --versionPrint the GNU Make versionmake --helpList available command-line optionsmake --warn-undefined-variablesWarn when an undefined variable is referencedWhat make actually does
Make is a build tool that decides what needs rebuilding and runs the commands to do it. You describe your project in a file called a Makefile: a set of targets (files or task names), the prerequisites each one depends on, and the recipe of shell commands that produces it. Run make and it walks that graph, comparing timestamps, and only rebuilds targets whose prerequisites are newer. That timestamp check is the whole point — on a big project make skips work that is already up to date instead of rebuilding everything.
Running targets
With no argument, make builds the first target in the Makefile — by convention that's usually all. To run a specific one, name it: make test, make clean, make install. These last few are conventions, not built-ins, but almost every project defines them. If your Makefile lives in a subdirectory, make -C <dir> <target> changes into that directory first, which is how recursive builds drive sub-projects.
Flags worth knowing
A handful of flags change make's behaviour dramatically. make -j (or -j4 to cap it) runs independent recipes in parallel and is the single easiest way to speed up a slow build. make -n is a dry run that prints the commands without executing them — invaluable for checking what a target would do. make -B forces a full rebuild when timestamps lie to you, and make -k keeps going after a failure so you see every error in one pass instead of one at a time.
Variables and debugging
You can override any Makefile variable from the command line by passing VAR=value before or after the target, which is how flags like make CFLAGS=-O2 get injected without editing the file. When a build misbehaves, make -p dumps the full rules-and-variables database so you can see exactly what make thinks is defined, and make -d traces every decision it makes. These pair naturally with the Git commands for version control and the Linux commands for everything around the build.