Makefile cheatsheetEdit

Automatic variables

  • $@: File being generated (ie. the "target" in Make parlance).
  • $<: First pre-requisite.
  • $^: All prerequisites (separated by spaces).
  • $?: All prerequisites newer than the target (separated by spaces).

Functions

  • wildcard
  • addprefix

Order-only prerequisites

# "target" depends on "dependency" but last-modified date is not considered
target: | dependency

FORCE targets

# "target" always gets built...
target: FORCE

# ...because it depends on this non-existent file
FORCE:

See also:

External resources