Generate text for each item in a list.

Section: Wildcards and file discovery

foreach list expansion

makefile
makefile
PKG_TARGETS := $(foreach p,$(PACKAGES),test-$(p))
Explanation

A powerful building block for metaprogramming.

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 Wildcards and file discovery
sort for deduplication
Sort and deduplicate a list of words.
OpenIn sheetmakefilesame section
filter files by pattern
Keep only values that match a pattern.
OpenIn sheetmakefilesame section
filter-out values
Exclude matches from a list.
OpenIn sheetmakefilesame section
wildcard function
Expand glob patterns during parsing.
OpenIn sheetmakefilesame section
dir and notdir with automatic vars
Extract target directory or file name.
OpenIn sheetmakefile1 tag match
Basic pattern rule
Compile any `.c` file into a matching `.o` file.
OpenIn sheetmakefile