Git, containers and DevOps

Command make

Run Makefile tasks

Linux · Bash examples · commands run on the selected server

When to use make

Use make to execute recipes described by a trusted makefile. Targets can perform arbitrary actions, so inspect the project instructions and recipes before invoking a build on a server with valuable data or credentials.

Syntax

make [PARAMETERS] [TARGET...]

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

-n
Show command plan, with caveats for recursive make.
-j N
Limit the number of parallel tasks.
-C DIRECTORY
Launch in the selected directory.

Usage examples

Run a standard trusted project target

make

The default target is selected, which depends on the project's makefile.

Show build plan

make -n build

Recipes for the requested target are previewed. This is not a security sandbox: processing the makefile itself can execute commands.

Limit parallel build

make -j 2 build

Up to two recipe jobs can run concurrently when the dependency graph permits.

Notes and limitations

  • Makefiles contain executable commands. Only run make in a trusted project.
  • -n is not a sandbox: expansions while reading a Makefile and some recursive make calls can still execute actions.

Common questions and troubleshooting

Does make -n guarantee no code executes?

No. Processing a makefile and invoking recursive builds can still execute commands. Review untrusted makefiles instead of relying on dry-run mode as isolation.

Why does make report nothing to be done?

Targets may already be up to date according to dependencies and timestamps. Check the intended target and makefile before forcing a rebuild.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man make.