Makefile Cheat Sheet/Inspect variable origin

See where a variable value came from.

Section: Variables and assignment

Inspect variable origin

makefile
makefile
$(info CC came from $(origin CC))
Explanation

Origins include `default`, `environment`, `file`, `command line`, and more.

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 Variables and assignment
Inspect variable flavor
Check whether a variable is recursive or simple.
OpenIn sheetmakefilesame section
Recursive variable
Expand later when used.
OpenIn sheetmakefilesame section
Simple variable
Expand immediately at assignment time.
OpenIn sheetmakefilesame section
Append to variable
Add text to an existing variable.
OpenIn sheetmakefilesame section
Set if undefined
Assign only if variable is not already set.
OpenIn sheetmakefilesame section
Override from command line
Pass variable values when invoking make.
OpenIn sheetbashsame section