Commit Diff


commit - ffb7bf10fb6c9d5f8cfacec3559a6a721fffc2e4
commit + 7da8ef9eb7516961a7acaedbe448cde8a6e66380
blob - 2447609dbb04bc1136d075e148ea2d181003f9ea
blob + 654aabebb6ab11549294d21636e1cf27bc2cca35
--- .gitignore
+++ .gitignore
@@ -1,2 +1,3 @@
 /build/
 /src/mcol/*.so
+/.ninja_log
blob - 12eb1fd97f8fe1a0dfca57d4d536a28209f7b8f7 (mode 644)
blob + /dev/null
--- Makefile
+++ /dev/null
@@ -1,54 +0,0 @@
-SCHEME ?= scheme
-INPUT ?= $(if $(MCOL_INPUT),$(MCOL_INPUT),.)
-PREFIX ?= /usr/local
-BINDIR ?= $(PREFIX)/bin
-LIBEXECDIR ?= $(PREFIX)/libexec/mcol
-MANDIR ?= $(PREFIX)/share/man
-LIBDIR = src
-RUN = $(SCHEME) --libdirs $(LIBDIR) --program
-SOURCES = src/mcol/core.sls src/mcol/tui.sls bin/mcol.ss
-
-.PHONY: all tui build test install uninstall clean help
-
-all: build
-
-tui:
-	$(RUN) bin/mcol.ss --input "$(INPUT)"
-
-build: build/mcol.so
-
-build/mcol.so: $(SOURCES) tools/build.ss
-	mkdir -p build
-	$(SCHEME) --libdirs $(LIBDIR) --compile-imported-libraries --program tools/build.ss
-
-test:
-	$(RUN) test/test.ss
-
-install: build/mcol.so
-	install -d "$(DESTDIR)$(BINDIR)" "$(DESTDIR)$(LIBEXECDIR)/lib/mcol" \
-		"$(DESTDIR)$(MANDIR)/man1"
-	install -m 755 bin/mcol "$(DESTDIR)$(BINDIR)/mcol"
-	install -m 755 build/mcol.so "$(DESTDIR)$(LIBEXECDIR)/mcol.so"
-	install -m 644 src/mcol/core.so src/mcol/tui.so "$(DESTDIR)$(LIBEXECDIR)/lib/mcol/"
-	install -m 644 doc/mcol.1 "$(DESTDIR)$(MANDIR)/man1/mcol.1"
-
-uninstall:
-	rm -f "$(DESTDIR)$(BINDIR)/mcol" "$(DESTDIR)$(LIBEXECDIR)/mcol.so" \
-		"$(DESTDIR)$(LIBEXECDIR)/lib/mcol/core.so" \
-		"$(DESTDIR)$(LIBEXECDIR)/lib/mcol/tui.so" \
-		"$(DESTDIR)$(MANDIR)/man1/mcol.1"
-
-clean:
-	rm -rf build src/mcol/*.so
-
-help:
-	@printf '%s\n' \
-		'make tui       Run the ANSI terminal browser' \
-		'make build     Compile the Chez Scheme program' \
-		'make test      Run fixture and demo tests' \
-		'make install   Install mcol and its manual' \
-		'make uninstall Remove installed files' \
-		'make clean     Remove generated artifacts' \
-		'' \
-		'Variables: INPUT=. SCHEME=scheme PREFIX=/usr/local DESTDIR=' \
-		'           BINDIR=PREFIX/bin LIBEXECDIR=PREFIX/libexec/mcol MANDIR=PREFIX/share/man'
blob - 3407e92ab9a9dabe8bbb04d33ad97f1aaea6da8f
blob + dd5eb25c031c1b4f1578aa089476ced1fc81d51a
--- README.md
+++ README.md
@@ -18,23 +18,23 @@ dated lists without a date cutoff:
 
 ## Run
 
-Requires Chez Scheme 10.4 or newer. Playback requires `mpc`.
+You need Chez Scheme 10.4 or newer. Playback needs `mpc`.
 
 ```sh
-make tui INPUT=/path/to/releases
+ninja tui INPUT=/path/to/releases
 ```
 
 Input is chosen from `--input`, then `MCOL_INPUT`, then the current directory:
 
 ```sh
 export MCOL_INPUT=/path/to/releases
-make tui
+ninja tui
 ```
 
-A small runnable demo is included in [`demo/`](demo/README.md):
+A small runnable demo is in [`demo/`](demo/README.md):
 
 ```sh
-make tui INPUT=demo
+ninja tui INPUT=demo
 ```
 
 ## Keys
@@ -63,10 +63,12 @@ one. Use `q 4 5 2` to add them to the queue without pl
 ## Build and install
 
 ```sh
-make build
-make test
-make install                 # /usr/local
-make install PREFIX=~/.local
+ninja build
+ninja test
+ninja install                  # /usr/local, escalates to sudo if needed
 ```
 
-See `mcol(1)` after installation. Set `NO_COLOR=1` to disable colour.
+Run `ninja install` to write to a system prefix. mcol asks for `sudo` if the
+target directories are not writable. Set `PREFIX`, `DESTDIR`, `SCHEME` or
+`NO_COLOR` in the environment to override the defaults. See `mcol(1)` after
+installation. Set `NO_COLOR=1` to turn off colour.
blob - /dev/null
blob + 50aeb26d23cdda183baa681d15e681f7b921a7ee (mode 644)
--- /dev/null
+++ build.ninja
@@ -0,0 +1,53 @@
+ninja_required_version = 1.5
+
+libdir = src
+
+rule compile
+  command = mkdir -p build && $${SCHEME:-scheme} --libdirs $libdir --compile-imported-libraries --program tools/build.ss
+  description = compiling mcol
+
+build build/mcol.so: compile bin/mcol.ss src/mcol/core.sls src/mcol/tui.sls tools/build.ss
+
+build build: phony build/mcol.so
+default build
+
+rule tui
+  command = $${SCHEME:-scheme} --libdirs $libdir --program bin/mcol.ss --input "$${INPUT:-$${MCOL_INPUT:-.}}"
+  pool = console
+  description = running mcol TUI
+
+build tui: tui build/mcol.so
+
+rule test
+  command = $${SCHEME:-scheme} --libdirs $libdir --program test/test.ss
+  pool = console
+  description = running tests
+
+build test: test build/mcol.so
+
+rule install
+  command = prefix=$${PREFIX:-/usr/local}; bindir=$${BINDIR:-$$prefix/bin}; libexecdir=$${LIBEXECDIR:-$$prefix/libexec/mcol}; mandir=$${MANDIR:-$$prefix/share/man}; destdir=$${DESTDIR:-}; can_create() { d="$$1"; while [ -n "$$d" ] && [ ! -e "$$d" ]; do d=$$(dirname "$$d"); done; [ -d "$$d" ] && [ -w "$$d" ]; }; s=; if ! can_create "$$destdir$$bindir"; then s=sudo; fi; $$s install -d "$$destdir$$bindir" "$$destdir$$libexecdir/lib/mcol" "$$destdir$$mandir/man1" && $$s install -m 755 bin/mcol "$$destdir$$bindir/mcol" && $$s install -m 755 build/mcol.so "$$destdir$$libexecdir/mcol.so" && $$s install -m 644 src/mcol/core.so src/mcol/tui.so "$$destdir$$libexecdir/lib/mcol/" && $$s install -m 644 doc/mcol.1 "$$destdir$$mandir/man1/mcol.1"
+  pool = console
+  description = installing mcol
+
+build install: install build/mcol.so
+
+rule uninstall
+  command = prefix=$${PREFIX:-/usr/local}; bindir=$${BINDIR:-$$prefix/bin}; libexecdir=$${LIBEXECDIR:-$$prefix/libexec/mcol}; mandir=$${MANDIR:-$$prefix/share/man}; destdir=$${DESTDIR:-}; can_create() { d="$$1"; while [ -n "$$d" ] && [ ! -e "$$d" ]; do d=$$(dirname "$$d"); done; [ -d "$$d" ] && [ -w "$$d" ]; }; s=; if ! can_create "$$destdir$$bindir"; then s=sudo; fi; $$s rm -f "$$destdir$$bindir/mcol" "$$destdir$$libexecdir/mcol.so" "$$destdir$$libexecdir/lib/mcol/core.so" "$$destdir$$libexecdir/lib/mcol/tui.so" "$$destdir$$mandir/man1/mcol.1"
+  pool = console
+  description = uninstalling mcol
+
+build uninstall: uninstall
+
+rule clean
+  command = rm -rf build src/mcol/core.so src/mcol/tui.so
+  description = cleaning
+
+build clean: clean
+
+rule help
+  description = mcol targets
+  command = printf '%s\n' 'ninja tui        Run the ANSI terminal browser' 'ninja build      Compile the Chez Scheme program' 'ninja test       Run fixture and demo tests' 'ninja install    Install mcol and its manual (escalates to sudo if needed)' 'ninja uninstall  Remove installed files' 'ninja clean      Remove generated artifacts' '' 'Variables (set in the environment): SCHEME=scheme PREFIX=/usr/local DESTDIR=' '                BINDIR=PREFIX/bin LIBEXECDIR=PREFIX/libexec/mcol MANDIR=PREFIX/share/man' '                INPUT=. (or MCOL_INPUT) NO_COLOR=1'
+  pool = console
+
+build help: help
blob - 00a8b5821d650fb018b6a35d398931f226d39fc7
blob + e21ac02991d84ed60c768c1510ef680106f23df7
--- demo/README.md
+++ demo/README.md
@@ -3,7 +3,7 @@
 Run this small set of release lists from the repository root:
 
 ```sh
-make tui INPUT=demo
+ninja tui INPUT=demo
 ```
 
 The dated lists demonstrate daily, legacy, session, and weekly sources. mcol