summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-17 16:11:25 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-17 16:11:25 +0200
commit7055723f8b79240ab2df1353eaaf3761f65414a9 (patch)
tree0308d9a2649e44838b6beba85c9fb01c822c4751 /Makefile
parentf03567a04b68ab19b5f16f0b6d56d9c08b14c818 (diff)
downloadcolitur-7055723f8b79240ab2df1353eaaf3761f65414a9.tar.gz
colitur-7055723f8b79240ab2df1353eaaf3761f65414a9.zip
feat(cli): a Makefile, a man page, and --help
Three things the project had no answer for: how to install it without knowing dune, where to read about it, and what it does when asked. Makefile, same shape as lectio's -- PREFIX ?= $(HOME)/.local, BINDIR, MANDIR, and the '## '-comment help target -- so the two siblings are driven the same way. Every recipe wraps dune in `opam exec --`, which is the actual point of having one here: `make build` works from a plain shell with no `eval $(opam env)` first. install goes through `dune install` rather than a hand-rolled copy, because the binary finds its calendar data relative to its own path; the man page is installed separately to share/man/man1, matching lectio. install and uninstall were both run against a scratch prefix and checked: uninstall leaves zero files behind. PREFIX defaults to ~/.local because that is where lectio installs and where it actually lives on this machine, so colitur lands on an existing PATH with no shell change. An earlier install this session went to ~/opt/colitur, which was me over-applying a rule meant for third-party tools to one of the author's own projects; it has been removed rather than left as a second, staler binary competing on PATH. man/colitur.1 documents the four commands, both output formats and why they differ, COLITUR_DATA_DIR and its refusal to fall back, the data resolution order, exit statuses, and -- deliberately -- the limitations: EF only, Epistle and Gospel only with the chants unbuilt and rejected rather than guessed, and the BVM Saturday Mass-selection gap. A man page that only lists what works is half a man page. Renders clean under `groff -ww -z`, no warnings. --help prints to stdout and exits 0; a usage error prints one line to stderr and exits 2. That is the Unix convention rather than a preference: asking for help succeeded and should be pipeable, being invoked wrongly did not and must not pollute stdout. Both directions are asserted in cli.t, along with a loop confirming every command the help text advertises is one the dispatch actually accepts -- the check that catches help drifting away from the code.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile55
1 files changed, 55 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..75372ac
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,55 @@
+COLITUR := colitur
+PREFIX ?= $(HOME)/.local
+BINDIR := $(PREFIX)/bin
+MANDIR := $(PREFIX)/share/man/man1
+
+# The binary locates its calendar data relative to its own path
+# (<prefix>/share/colitur/ef), so `dune install` -- not a hand-rolled copy --
+# is what places the four .sexp files where a running colitur will look for
+# them. See bin/main.ml's own [data_dir] for the full resolution order.
+#
+# dune needs the project-local opam switch on PATH. Every recipe that invokes
+# dune goes through this, so `make` works from a plain shell with no
+# `eval $(opam env)` first -- which is the whole point of having a Makefile
+# over documenting the dune commands.
+DUNE := opam exec --
+
+.PHONY: help build test check install uninstall reinstall clean fmt man doc
+help: ## show this help
+ @grep -hE '^[a-z-]+:.*##' $(MAKEFILE_LIST) | sed -E 's/:.*## /\t/' | sort
+
+build: ## build the binary
+ $(DUNE) dune build
+
+test: ## fast suite (~5s): properties sample 200 years
+ $(DUNE) dune test
+
+check: ## full gate (~2min): every year 1583-9999, not a sample
+ COLITUR_EXHAUSTIVE_SWEEP=1 $(DUNE) dune test --force
+
+install: build ## install binary, calendar data and man page into PREFIX (default ~/.local)
+ $(DUNE) dune install --prefix $(PREFIX)
+ @mkdir -p $(MANDIR)
+ install -m 644 man/colitur.1 $(MANDIR)/colitur.1
+ @echo "installed $(BINDIR)/$(COLITUR), data in $(PREFIX)/share/colitur/ef, man page in $(MANDIR)"
+ @command -v $(COLITUR) >/dev/null 2>&1 || \
+ echo "note: $(BINDIR) is not on PATH -- add it, or run $(BINDIR)/$(COLITUR) directly"
+
+uninstall: ## remove everything install put into PREFIX
+ -$(DUNE) dune uninstall --prefix $(PREFIX)
+ rm -f $(MANDIR)/colitur.1
+ @echo "removed $(COLITUR) from $(PREFIX)"
+
+reinstall: uninstall install ## uninstall then install (the installed copy is a snapshot, not a link)
+
+man: ## preview the man page
+ man -l man/colitur.1
+
+doc: ## lint the man page (groff warnings; silence means clean)
+ groff -man -Tutf8 -ww -z man/colitur.1
+
+fmt: ## format the OCaml sources
+ $(DUNE) dune build @fmt --auto-promote
+
+clean: ## remove build artifacts
+ $(DUNE) dune clean