Tools
Makefile
Build automation — targets, variables, and pattern rules.
Basic structure
target: dep1 dep2
command
# Phony targets don't produce output files
.PHONY: clean test build
clean:
rm -rf dist/
test:
npm testVariables
foo = barLazy (recursive) assignmentfoo := barImmediate assignmentfoo ?= barSet only if unsetfoo += barAppend to variablefoo != echo hiShell command result$(foo)Expand variableMagic variables
$@Current target name$<First prerequisite$^All prerequisites$*Stem of pattern rule match$(@D)Directory part of targetCommand prefixes
-commandIgnore errors (continue on failure)@commandSuppress command echo+commandRun even in dry-run mode (make -n)Functions
$(wildcard *.c)Expand glob$(patsubst %.c,%.o,$(src))Pattern substitution$(shell find . -name "*.js")Shell command$(filter %.js,$(files))Filter by pattern$(strip $(var))Remove whitespaceOptions
make -eEnv vars override file varsmake -BRebuild all unconditionallymake -sSilent modemake -j4Parallel jobsmake -nDry run (print, no execute)