make Command Reference
Build targets from a Makefile by resolving their dependencies.
make reads a Makefile and builds targets whose prerequisites are newer than their outputs. It is the default task runner in countless CI pipelines.
What it does
make evaluates the dependency graph in a Makefile and runs each recipe whose target is out of date relative to its prerequisites. Run bare it builds the first (default) target; given a target name it builds just that one.
Common flags and usage
- (none): build the first target in the Makefile
- TARGET: build a specific target by name
- -f FILE: use a Makefile other than ./Makefile
- VAR=value: override a Makefile variable on the command line
- -k: keep going after an error to surface all failures
Example
shell
- name: Build
run: make build
- name: Test
run: make test VERBOSE=1In CI
Pin the toolchain (compiler, make version) so out-of-date detection behaves identically across runners. Override variables on the command line (VAR=value) to parameterize a build without editing the Makefile.
Key takeaways
- Bare make builds the first target; pass a name to build a specific target.
- make only rebuilds targets older than their prerequisites.
- Override Makefile variables with VAR=value on the command line.
Related guides
make -j (Parallel Builds) Command ReferenceReference for make -j in CI/CD: run recipes in parallel, size jobs to runner cores and memory, and avoid the…
make Targets Command ReferenceReference for make targets in CI/CD: what a target is, how to run several in one invocation, and how to disco…
Makefile .PHONY Command ReferenceReference for Makefile .PHONY in CI/CD: declare task targets that are not files so make always runs them, eve…