make: Usage, Options & Common CI Errors
make runs the recipe for a target, rebuilding only what its dependencies require.
make orchestrates builds and task running across countless projects. The two errors that define it in CI: the infamous tab-vs-spaces "missing separator", and "No rule to make target".
What it does
make reads a Makefile of target: prerequisites rules with TAB-indented recipes, and builds the requested target by running recipes for any prerequisite that is out of date. It is also widely used as a generic task runner.
Common usage
make # build the first/default target
make test
make -j4 # build with 4 parallel jobs
make -C subdir build # run in another directory
make -f Custom.mk deploy
make --always-make # force rebuild (ignore timestamps)Options
| Flag | What it does |
|---|---|
| -j [N] | Run N recipes in parallel |
| -C <dir> | Change to dir before reading the Makefile |
| -f <file> | Use a non-default makefile |
| -B / --always-make | Rebuild all targets unconditionally |
| -n / --dry-run | Print recipes without running them |
| -k | Keep going after a failed target |
Common errors in CI
Makefile:N: * missing separator. Stop. - a recipe line is indented with spaces instead of a real TAB; editors and copy-paste silently convert them. "make: * No rule to make target "X". Stop." means the target or a prerequisite file does not exist (typo, or it was not generated). "make: *** [target] Error 2" just means a recipe command exited non-zero - scroll up for the real error. With -j, interleaved output makes failures harder to read; rerun with -j1 to isolate.