Skip to main content

Makefiles

  • use (ref)bash:unofficial-strict-mode
  • The most important variables are:
    • $@ - the name of the target
    • @< - the name of the first prerequisite
    • $^ - the name of all prerequisites, separated by spaces
    • $* - the stem that was matched when using % patterns
    • $(@D) - the directory part of the target

Preamble

SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules

ifeq ($(origin .RECIPEPREFIX), undefined)
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
endif
.RECIPEPREFIX = >

References