## Makefile (repo-owned) -- generated by `uvx rhiza-task shim > Makefile`
#
# This replaces `.rhiza/rhiza.mk` and the ten fragments in `.rhiza/make.d/`: 1023 synced
# lines, at a template tag, for a dozen lines pinned to a package version.
#
# `make` stays the front door. It is what a stranger types in an unfamiliar repository,
# what a decade of muscle memory reaches for, and what keeps a consumer pinned to an older
# reusable workflow working unchanged. It just no longer *contains* anything.
#
# RHIZA_TASK is the entire version contract. Bumping it is the migration that used to be
# `/rhiza:update` re-syncing eleven .mk files and reconciling whatever had been shadowed.
RHIZA_TASK ?= rhiza-task@0.2.0

# The one thing the shim cannot delegate to the CLI: uv itself, because uv is what runs
# the CLI. `bootstrap.mk` had an `install-uv` target for exactly this, and the make layer's
# contract was that `make <anything>` works on a bare runner -- rhiza's own `pre-commit` job
# runs `make fmt` with no `astral-sh/setup-uv` step, and `ubuntu-latest` ships no uv. A shim
# that only ran `uvx` would turn a required status check red on the day a repo migrated.
#
# So the bootstrap survives, minus the parts the CLI took over: no `bin/uv`, no PATH export,
# no clean-up, just the one binary needed to reach the pin above.
INSTALL_DIR ?= $(abspath ./bin)
UVX ?= $(shell command -v uvx 2>/dev/null || echo $(INSTALL_DIR)/uvx)

.DEFAULT_GOAL := help

help: $(UVX)
	@$(UVX) $(RHIZA_TASK) list

# `%:` matches any target make cannot otherwise resolve. Two caveats, both survivable: a
# typo is routed here too (the CLI's "unknown task" error is the backstop), and a task
# needing flags wants `uvx rhiza-task <task> --flag` directly. `.PHONY` cannot name unknown
# targets, so a *file* sharing a task's name would shadow it -- none do.
%: $(UVX)
	@$(UVX) $(RHIZA_TASK) $@

# Named as a file rather than a phony `install-uv`, so make's own up-to-date check is the
# idempotence: when uvx is on PATH this is an existing file with no prerequisites and
# nothing runs, and when it is not, this rule is the only way the file can come into being.
# There is no probe to get wrong and no second invocation that re-downloads.
#
# The target is `$(UVX)` and not `$(INSTALL_DIR)/uvx` because it has to exist as an
# explicit rule in *both* cases: with no rule of its own, an on-PATH uvx is matched by the
# catch-all below, whose prerequisite is that same file, and every invocation opens with
# `make: Circular /usr/local/bin/uvx <- /usr/local/bin/uvx dependency dropped.`
#
# `$(@D)` rather than `$(INSTALL_DIR)`: the installer writes where the binary was expected,
# so an overridden `UVX=/somewhere/uvx` provisions /somewhere rather than silently
# downloading to ./bin and then running nothing.
$(UVX):
	@echo "[INFO] uv not found; installing into $(@D)"
	@curl -LsSf https://astral.sh/uv/install.sh | UV_INSTALL_DIR="$(@D)" sh >/dev/null

# Repo-specific one-offs live here, where they always belonged, and win over the catch-all
# because an explicit rule beats a pattern rule. This is what `local.mk` was for -- and a
# repository that carried its *own* fragment under `.rhiza/make.d/` has to move it here
# before deleting `rhiza.mk`, which is the file whose `-include` was reaching it.
-include local.mk

# An included makefile is also a target make tries to *remake* before running anything, and
# with a match-anything rule in scope that attempt is routed to the CLI -- so every single
# invocation used to begin with "unknown task: local.mk". An explicit rule with an empty
# recipe satisfies the remake attempt silently.
local.mk: ;

# The Makefile needs the same treatment now, and did not before. A match-anything rule with
# no prerequisites cannot make an existing Makefile out of date, so the remake attempt was a
# no-op; `$(UVX)` is a prerequisite that a cold checkout *creates*, which makes it newer than
# the Makefile, which makes the Makefile out of date -- so make remade it by running
# `uvx rhiza-task Makefile`, and the first `make <anything>` on a machine without uv died
# with "unknown task: Makefile" right after installing uv. An empty recipe ends that too.
Makefile: ;
