meta data for this page
  •  

functions

8.3 Functions for File Names

  • $(dir /path/to/file.txt) - get path part only
  • $(notdir src/foo.c hacks) - result foo.c hacks.
  • $(suffix …)
  • $(basename src/foo.c src-1.0/bar hacks) - produces the result src/foo src-1.0/bar hacks.
  • $(addsuffix)
  • $(addprefix)
  • $(join)
  • $(wildcard) - execute wildcard expansion (needed to expand wildcards in variables and arguments in functions). More: The Function wildcard
  • $(realpath) - NOTE: file must exist!
  • $(abspath) - NOTE: do not require file to exist

Conditional Functions - can be used also in recipes body:

  • $(if)
    Example 1:
    build:
        $(if $(filter 1,$(WORKSPACE_DETECTED)), \
          @echo
          @echo "!!! Configured workspace detected: '$(WORKSPACE_PATH)'"
        )

    Example 2:

    $(if $(filter foo,bar),@echo match is broken,@echo match works)
    $(if $(filter-out foo,bar),@echo match works,@echo match is broken)