VERSION?=$(shell cat VERSION) BIN?=dict PREFIX?=/usr/local BINDIR?=$(PREFIX)/bin SHAREDIR ?= $(PREFIX)/share/$(BIN) OUT=./bin/$(BIN) EXT=./ext/libsqlite3ext.so GO_LDFLAGS:= -s -w GO_LDFLAGS+= -X main.Version=$(VERSION) GO_LDFLAGS+= -X git.gabrielgio.me/dict/db.LibPath=$(SHAREDIR)/libsqlite3ext GO_BUILD=go build -v --tags "fts5" GO_RUN=go run -v --tags "fts5" build: ext $(GO_BUILD) -ldflags "$(GO_LDFLAGS)" -o $(OUT) ./cmd/dict/main.go install: install -Dm755 $(OUT) $(BINDIR)/$(BIN) install -Dm644 $(EXT) $(SHAREDIR)/libsqlite3ext.so run: ext $(GO_RUN) ./cmd/dict/main.go ui import: ext $(GO_RUN) ./cmd/dict/main.go import serve: ext $(GO_RUN) ./cmd/dict/main.go serve version: ext $(GO_RUN) ./cmd/dict/main.go version uninstall: rm $(BINDIR)/$(BIN) rm $(SHAREDIR)/libsqlite3ext.so .PHONY: ext ext: gcc -shared -o ext/libsqlite3ext.so -fPIC ext/spellfix.c