Skip to content

Instantly share code, notes, and snippets.

@phatblat
Last active August 1, 2022 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phatblat/d07e2ede6bc1b5d523789ff098d004e3 to your computer and use it in GitHub Desktop.
Save phatblat/d07e2ede6bc1b5d523789ff098d004e3 to your computer and use it in GitHub Desktop.
Make Automatic Variables Cheatsheet

Make Automatic Variables Cheatsheet

I can never remember all of the automatic variables that can be used in a Makefile so here is a table of them.

Variable Description
$@ File name of the target of the rule
$% Target member name, when the target is an archive member
$< Name of the first prerequisite
$? Name of all prerequisites that are newer than the target
$^ Names of all the prerequisites, with spaces between them
$+ Like $^, but prerequisites listed more than once are duplicated in the order they were listed in the makefile
$| Names of all the order-only prerequisites, with spaces between them
$* Stem with which an implicit rule matches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment