# spec.sr.ht — build scaffolding (compare.sr.ht / sourcehut-dolt style). # # One Go binary plus a brant migration wrapper, both under cmd/. The CSS is # built from the shared sourcehut scss partials with sassc; there is no # frontend bundle — the prose differ renders server-side. SERVICE=spec.sr.ht BIN=specsrht MIGRATE_BIN=specsrht-migrate PREFIX?=/usr/local BINDIR?=$(PREFIX)/bin SHAREDIR?=$(PREFIX)/share ASSETS?=/usr/share/sourcehut STATICDIR?=$(ASSETS)/$(SERVICE)/static MIGRATIONDIR?=$(SHAREDIR)/sourcehut/migrations/$(SERVICE) SASSC?=sassc SASSC_INCLUDE=-I$(ASSETS)/scss all: build # Compile the binaries. cmd/ lands in Phase 1's Wave B, so until then each # target skips rather than failing — a red default target during the build-out # trains everyone to ignore it. build: $(BIN) $(MIGRATE_BIN) $(BIN): @if [ -d ./cmd/$(BIN) ]; then \ echo "go build -o $@ ./cmd/$(BIN)"; \ go build -o $@ ./cmd/$(BIN); \ else \ echo "skip $@: ./cmd/$(BIN) not present yet"; \ fi $(MIGRATE_BIN): @if [ -d ./cmd/$(MIGRATE_BIN) ]; then \ echo "go build -o $@ ./cmd/$(MIGRATE_BIN)"; \ go build -o $@ ./cmd/$(MIGRATE_BIN); \ else \ echo "skip $@: ./cmd/$(MIGRATE_BIN) not present yet"; \ fi test: go test ./... # CSS pipeline: sassc -> minify -> content-hashed filename. The running service # globs web/static/main.min.*.css at startup, so the hash in the name is the # cache-busting version. Requires the shared scss partials installed at # $(ASSETS)/scss (core.sr.ht `make install`) and scss/main.scss to exist. # Produces exactly ONE web/static/main.min..css; old ones and the # intermediate main.css are removed. css: mkdir -p web/static rm -f web/static/main.css web/static/main.min.*.css $(SASSC) $(SASSC_INCLUDE) scss/main.scss web/static/main.css minify -o web/static/main.min.css web/static/main.css mv web/static/main.min.css \ web/static/main.min.$$(sha256sum web/static/main.min.css | cut -c1-8).css rm -f web/static/main.css # Local development run. Requires a ./config.ini in the working directory (or # ../config.ini, /etc/sr.ht/config.ini) carrying the instance's shared # [sr.ht]/[webhooks] keys plus a [spec.sr.ht] section. run-dev: build ./$(BIN) -b localhost:5091 install: build install -Dm755 $(BIN) $(DESTDIR)$(BINDIR)/$(BIN) install -Dm755 $(MIGRATE_BIN) $(DESTDIR)$(BINDIR)/$(MIGRATE_BIN) mkdir -p $(DESTDIR)$(STATICDIR) $(DESTDIR)$(MIGRATIONDIR) install -Dm644 -t $(DESTDIR)$(STATICDIR) web/static/* install -Dm644 -t $(DESTDIR)$(MIGRATIONDIR) migrations/*.sql clean: rm -f $(BIN) $(MIGRATE_BIN) rm -f web/static/main.css web/static/main.min.*.css .PHONY: all build test css run-dev install clean $(BIN) $(MIGRATE_BIN)