make Command: Run Builds in CI
make builds targets from rules in a Makefile, rebuilding only what changed.
make is the classic build automation tool, driving C/C++ builds and serving as a generic task runner across CI pipelines. It reads a Makefile, computes which targets are out of date, and runs their recipes.
Common flags
-j N- run up to N recipes in parallel (-jalone = unlimited)-C DIR- change to DIR before reading the Makefile-f FILE- use a non-default Makefile-B/--always-make- rebuild all targets unconditionally-k- keep going after a failed target (collect more errors)VAR=value- override a Makefile variable on the command line-n/--dry-run- print the recipes without running them
Example in CI
Run a parallel release build with a variable override in CI:
shell
make -j$(nproc) BUILD_TYPE=releaseCommon errors in CI
- Makefile:NN: *** missing separator. Stop. - recipe indented with spaces, not a tab
- make: *** No rule to make target 'X'. Stop. - target/prereq does not exist
- make: *** [target] Error 1 - a recipe command exited non-zero
- make: Nothing to be done for 'all' - targets already up to date (or wrong target)
Key takeaways
- Use
-j$(nproc)to parallelize builds across all runner cores. - The infamous "missing separator" error means a space instead of a tab.
- Override variables inline (
VAR=value) without editing the Makefile.
Related guides
cmake Command: Configure C++ Builds in CIcmake configures and builds C/C++ projects. Reference for -S, -B, -G, -D, --build, --target, --preset, and th…
ninja Command: Fast Builds in CIninja is a small, fast build system. Reference for -j, -C, -f, -t, -k, -v, and the ninja CI errors you will s…
gcc Command: Compile C in CIgcc is the GNU C compiler driver. Reference for -c, -o, -I, -L, -l, -Wall, -O2, -std, and the header/library…