# Thin control Makefile — one target per ctrl/ script, and the subcommand is an # argument rather than a second target: `make cluster down`, not `make cluster-down`. # # The logic lives in the scripts, never here. Each target maps to exactly one # file, and that file holds the variants: # # make cluster up -> ctrl/cluster.sh up # make build amar -> ctrl/build.sh amar # # Bare words pass straight through. Anything starting with a dash would be # swallowed by make itself, so pass those via ARGS instead: # # make component ARGS="publish soleprint-ui /tmp/out --dist" # make deploy ARGS="--build" # # Every script stays runnable on its own (./ctrl/cluster.sh up still works, and each # built room keeps its own gen//ctrl/*.sh) — the standalone rule holds, and # this only saves typing. # # Start with: make build && make start # The room to act on when none is named. Rooms live in cfg/ and build into gen/. ROOM ?= standalone PYTHON ?= python3 export PYTHON # Words after the target become the script's subcommand. Make would otherwise # treat them as goals of their own, so each gets a no-op rule. ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) ifneq ($(ARGS),) # Declares each extra word as a target that does nothing: `:` is an empty rule # body and `@` silences it. Without this, `make build sample` runs the build and # then fails with "No rule to make target 'sample'", because make reads every # word on the line as something it has been asked to build. $(eval $(ARGS):;@:) # ...and as PHONY, because some of those words name real directories. `cfg`, # `ctrl`, `docs`, `gen` and `init` all exist at this level, and make considers a # target that is an existing directory already built — so `make build ctrl` ran # the build and then printed "make: 'ctrl' is up to date". The empty rule above # is not enough on its own; only .PHONY stops make consulting the filesystem. .PHONY: $(ARGS) endif .DEFAULT_GOAL := help .PHONY: help build start stop dist theme docs cluster deploy component help: ## list targets @grep -hE '^[a-z]+:.*?##' $(MAKEFILE_LIST) | sed 's/:.*##/\t/' | expand -t16 # ── rooms ────────────────────────────────────────────────────────────────── build: ## build a room into gen/ [|all|models] bash ctrl/build.sh $(or $(ARGS),$(ROOM)) start: ## run a built room [] [-d] [--build] bash ctrl/start.sh $(or $(ARGS),$(ROOM)) stop: ## stop a running room [] bash ctrl/stop.sh $(or $(ARGS),$(ROOM)) dist: ## compile the plexus UIs to single files [] bash ctrl/dist.sh $(or $(ARGS),$(ROOM)) # ── theme ────────────────────────────────────────────────────────────────── theme: ## ad-hoc pages [new|parts|bake|check|export|run FILE] bash ctrl/theme.sh $(or $(ARGS),bake) # ── docs ─────────────────────────────────────────────────────────────────── docs: ## documentation [serve [port]|graphs [theme]] (default serve) bash ctrl/docs.sh $(or $(ARGS),serve) # ── cluster ──────────────────────────────────────────────────────────────── cluster: ## shared kind cluster [up|down|status] (default status) bash ctrl/cluster.sh $(or $(ARGS),status) # ── distribution ─────────────────────────────────────────────────────────── component: ## publish components [list|sync|watch|publish|diff] $(PYTHON) ctrl/spr.py $(or $(ARGS),list) deploy: ## push standalone to the server [--build|--sync-only] bash ctrl/deploy.sh $(ARGS)