Makefile Cheat Sheet/Rule with multiple prerequisites

Rebuild target when any listed prerequisite changes.

Section: Targets, prerequisites, and recipes

Rule with multiple prerequisites

makefile
makefile
bundle.js: app.js ui.js api.js
	cat $^ > $@
Explanation

`$^` expands to all prerequisites and `$@` to the target name within the recipe.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Targets, prerequisites, and recipes
Basic rule
Define a target, prerequisites, and recipe.
OpenIn sheetmakefilesame section
Multiple targets one recipe
Attach the same recipe to multiple targets.
OpenIn sheetmakefilesame section
Order-only prerequisite
Require creation order without forcing rebuilds when the prerequisite timestamp changes.
OpenIn sheetmakefilesame section
Phony target
Create a target that does not represent a file.
OpenIn sheetmakefilesame section
Stamp file target
Track completion of a step using a timestamp file.
OpenIn sheetmakefilesame section
Clean target
Remove build artifacts.
OpenIn sheetmakefilesame section