Makefile Functions & Text Processing/dir, notdir, basename, suffix

Split and recombine filenames.

Section: Text and list functions

dir, notdir, basename, suffix

makefile
makefile
DIRS := $(dir $(FILES))
BASE := $(basename $(FILES))
Explanation

Useful for path manipulation without shelling out.

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 Text and list functions
subst replace text
Replace every occurrence of one string with another.
OpenIn sheetmakefilesame section
patsubst pattern replacement
Replace words matching a `%` pattern.
OpenIn sheetmakefilesame section
strip whitespace
Trim extra leading, trailing, and repeated internal whitespace.
OpenIn sheetmakefilesame section
findstring substring search
Return the search string if found.
OpenIn sheetmakefilesame section
word and wordlist
Extract words by position.
OpenIn sheetmakefilesame section
firstword and lastword
Grab the first or last word of a list.
OpenIn sheetmakefilesame section