Makefile Cheat Sheet/Append to variable

Add text to an existing variable.

Section: Variables and assignment

Append to variable

makefile
makefile
CFLAGS += -Wall -Wextra
Explanation

Works with both recursive and simple variables.

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
Recursive variable
Expand later when used.
OpenIn sheetmakefilesame section
Simple variable
Expand immediately at assignment time.
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
Force override in makefile
Override even a command-line assignment.
OpenIn sheetmakefilesame section
Export variable to recipes
Pass a variable into the shell environment of recipe commands.
OpenIn sheetmakefilesame section