Make Module Registries
Make modules register their targets and requirements into shared lists, and aggregate targets are composed from whatever registered.
- Kind
- Orchestration
- Domain
- Environment & Tooling
- Applies at
scripts/build/- Status
- Stable
01 Defines
How independent make modules contribute to repository-wide commands without editing them: each module appends to a registry variable, and the aggregate targets expand those registries after every module has loaded.
02 Applies when
- A repository command such as
build,validate,clean, ordoctormust cover several unrelated toolchains. - Make modules are added to or removed from a repository over time.
- Shared modules come from a global library as well as from the repository.
03 Boundaries
- Registries carry target names and requirements, not the work itself; the work lives in each module’s own targets.
- Which components exist — Hugo sites, Terraform roots — is declared in
repository.mk, not discovered.
Expected behaviour
- 01Each module appends to registries such as
BUILD_TARGETS,VALIDATE_TARGETS,CLEAN_TARGETS, andDOCTOR_TOOLSwith+=. - 02
00-config.mkinitialises every registry;90-aggregates.mksorts last and turns registries into targets. - 03Removing a module file removes its registrations, and nothing else needs to change.
- 04Modules load in the fixed
MAKE_MODULE_ORDER, resolved from library directories first and the repository second.
Behaviour#
The root Makefile is identical in every repository. It includes the
repository’s configuration and then a fixed sequence of numbered modules. Each
module is self-contained: it defines its own targets and registers them by
appending to shared lists. No module edits another.
- 01
Configure
repository.mkdeclares components;00-config.mkinitialises empty registries - 02
Register
Each module appends:
BUILD_TARGETS += check.hugo,DOCTOR_TOOLS += terraform - 03
Aggregate
90-aggregates.mkis read last, sobuild: $(BUILD_TARGETS)sees every registration - 04
Run
make build,make validate, andmake cleancover whatever modules are present
The registries#
| Registry | Consumed by | Example registration |
|---|---|---|
BUILD_TARGETS | make build | BUILD_TARGETS += check.hugo |
VALIDATE_TARGETS | make validate | VALIDATE_TARGETS += check.links |
FORMAT_CHECK_TARGETS | format-check | FORMAT_CHECK_TARGETS += check.terraform.fmt |
TEST_TARGETS | make test | — |
CLEAN_TARGETS | make clean | CLEAN_TARGETS += clean.hugo |
DOCTOR_TOOLS | make doctor | DOCTOR_TOOLS += hugo |
DOCTOR_FILES | make doctor | DOCTOR_FILES += .linter/ignore |
DOCTOR_SNIPPETS | make doctor | a named shell check |
Module resolution#
Modules load in a fixed order. Each name resolves to the first match across the
global library directories and then the repository’s own scripts/build/, so a
repository can rely on a shared module or carry its own.
- scripts/build/
- 00-config.mk Shared defaults; initialises every registry
- 10-help.mk make help, generated from ## comments Self-Documenting Help
- 20-doctor.mk Environment diagnostics Environment Doctor
- 30-repo.mk Repository hygiene and formatting
- 40-docs.mk Markdown and link checks
- 52-hugo.mk Hugo sites Static Websites
- 53-terraform.mk Terraform format, validate, lint
- 70-security.mk Secret, vulnerability, and IaC scanning
- 81-deploy.mk Deployment Static Site Delivery
- 90-aggregates.mk Aggregate targets; must sort last
- repository.mk Component lists for this repository
Examples#
A module registers itself and guards its own work. The Hugo module adds hugo
to the doctor’s tool list only when the repository declares a site:
ifneq ($(strip $(HUGO_DIRS)),)
DOCTOR_TOOLS += hugo
endif
BUILD_TARGETS += check.hugo
CLEAN_TARGETS += clean.hugo
Connections
How Make Module Registries relates to the library
Composes
- Environment Doctor make doctor reports which required tools and repository files are present or missing — a …
- Self-Documenting Help make help is generated from ## comments on the targets themselves, so the list of commands …
- Explicit Skips When a capability is intentionally unavailable, a command says so with a skip: line and …