PREFIX?=/usr/local BINDIR?=$(PREFIX)/bin LIBDIR?=$(PREFIX)/lib SHAREDIR?=$(PREFIX)/share ASSETS?=/usr/share/sourcehut SERVICE=dolt.sr.ht STATICDIR=$(SHAREDIR)/sourcehut/static/$(SERVICE) MIGRATIONDIR=$(SHAREDIR)/sourcehut/migrations/$(SERVICE) SASSC?=sassc SASSC_INCLUDE=-I$(ASSETS)/scss/ MINIFY?=minify # Pure-Go build (default): no cgo, no ICU/zstd C libraries, statically linkable. # Two things make it work: the `gms_pure_go` tag swaps go-mysql-server's ICU # regex for the stdlib regexp (this service never runs the SQL engine), and a # `replace github.com/dolthub/gozstd => ./third_party/gozstd-purego` directive # backs dolt's only other hard cgo dependency with a pure-Go klauspost shim. # To build the cgo variant instead: `make CGO_ENABLED=1 GO_TAGS=`. GO_TAGS?=gms_pure_go CGO_ENABLED?=0 export CGO_ENABLED GO=go GOBUILD=$(GO) build $(if $(GO_TAGS),-tags "$(GO_TAGS)",) BINARIES=\ doltsrht \ doltsrht-migrate \ dolt-git-hook # Default target builds the Go binaries only. CSS (all-share) is deliberately # kept off the default path because sassc/minify are not always installed on # dev machines; run `make css` explicitly to build stylesheets. all: all-bin all-bin: $(BINARIES) all-share: static/main.min.css css: all-share # Build each binary if its cmd package exists yet. The cmd/ packages land in # Phase 3; until then these targets are no-ops rather than hard failures. doltsrht: @if [ -d ./cmd/doltsrht ]; then \ echo "$(GOBUILD) -o $@ ./cmd/doltsrht"; \ $(GOBUILD) -o $@ ./cmd/doltsrht; \ else \ echo "skip $@: ./cmd/doltsrht not present yet"; \ fi doltsrht-migrate: @if [ -d ./cmd/doltsrht-migrate ]; then \ echo "$(GOBUILD) -o $@ ./cmd/doltsrht-migrate"; \ $(GOBUILD) -o $@ ./cmd/doltsrht-migrate; \ else \ echo "skip $@: ./cmd/doltsrht-migrate not present yet"; \ fi dolt-git-hook: @if [ -d ./cmd/dolt-git-hook ]; then \ echo "$(GOBUILD) -o $@ ./cmd/dolt-git-hook"; \ $(GOBUILD) -o $@ ./cmd/dolt-git-hook; \ else \ echo "skip $@: ./cmd/dolt-git-hook not present yet"; \ fi # Compile every buildable package; used as the CI build gate. build: $(GOBUILD) ./... install: install-bin install-share install-bin: all-bin mkdir -p $(BINDIR) for bin in $(BINARIES); do \ if [ -x $$bin ]; then install -Dm755 $$bin $(BINDIR)/; fi; \ done install-share: mkdir -p $(STATICDIR) mkdir -p $(MIGRATIONDIR) install -Dm644 schema.sql $(SHAREDIR)/sourcehut/$(SERVICE).sql install -Dm644 migrations/*.sql $(MIGRATIONDIR) if [ -d static ]; then install -Dm644 static/*.css static/*.svg $(STATICDIR) 2>/dev/null || true; fi clean: clean-bin clean-share clean-bin: rm -f $(BINARIES) clean-share: rm -f static/main.min.css static/main.css static/main.min.*.css .PHONY: all all-bin all-share css build install install-bin install-share .PHONY: clean clean-bin clean-share $(BINARIES) static/main.css: scss/main.scss mkdir -p $(@D) $(SASSC) $(SASSC_INCLUDE) $< $@ static/main.min.css: static/main.css $(MINIFY) -o $@ $< cp $@ $(@D)/main.min.$$(sha256sum $@ | cut -c1-8).css