A pure-Python 3 (stdlib only) Makefile linter. Detects common issues including tab/space errors, missing .PHONY declarations, unused/undefined variables, hardcoded paths, shell portability problems, and more.
lint FILE#Lint a Makefile and report issues.
bash
python3 scripts/makefile-linter.py lint Makefile
python3 scripts/makefile-linter.py lint /path/to/Makefile
echo -e "all:\n\techo hello" | python3 scripts/makefile-linter.py lint /dev/stdin
targets FILE#List all targets with line numbers, phony status, prerequisites, and inline comment descriptions.
bash
python3 scripts/makefile-linter.py targets Makefile
python3 scripts/makefile-linter.py targets Makefile --format json
vars FILE#List all variable definitions with line numbers and values.
bash
python3 scripts/makefile-linter.py vars Makefile
python3 scripts/makefile-linter.py vars Makefile --format markdown
audit FILE#Full audit combining lint results, targets list, and variables summary.
bash
python3 scripts/makefile-linter.py audit Makefile
python3 scripts/makefile-linter.py audit Makefile --format json
FlagDescription--format text|json|markdownOutput format (default: text)--strictExit code 1 on any reported issue--ignore RULEIgnore a specific rule (repeatable)--min-severity error|warning|infoMinimum severity to report (default: info)
RuleSeverityDescriptionspaces-not-tabserrorRecipe lines must use tabs, not spacesduplicate-targetserrorSame target defined more than oncemissing-phonywarningCommon phony target not in .PHONY``unused-variableswarningVariable defined but never referencedundefined-variableswarningVariable referenced but never definedhardcoded-pathswarningAbsolute paths in recipestrailing-whitespacewarningLines ending with spaces or tabsshell-portabilitywarningBash-specific syntax without SHELL := /bin/bash``recursive-makeinfo$(MAKE) -C or make -C detectedmissing-default-targetinfoNo all target definedlong-linesinfoLines over 120 charactersmissing-cleaninfoNo clean target defined
bash
# Report only errors and warnings
python3 scripts/makefile-linter.py lint Makefile --min-severity warning
# JSON output for CI integration
python3 scripts/makefile-linter.py lint Makefile --format json
# Fail CI on any issue
python3 scripts/makefile-linter.py lint Makefile --strict
# Ignore specific rules
python3 scripts/makefile-linter.py lint Makefile --ignore recursive-make --ignore missing-clean
# Full audit in Markdown (for PR comments)
python3 scripts/makefile-linter.py audit Makefile --format markdown
# Pipe from stdin
cat Makefile | python3 scripts/makefile-linter.py lint /dev/stdin