dict @ master

 1VERSION?=$(shell cat VERSION)
 2BIN?=dict
 3PREFIX?=/usr/local
 4BINDIR?=$(PREFIX)/bin
 5SHAREDIR ?= $(PREFIX)/share/$(BIN)
 6OUT=./bin/$(BIN)
 7EXT=./ext/libsqlite3ext.so
 8
 9GO_LDFLAGS:= -s -w
10GO_LDFLAGS+= -X main.Version=$(VERSION)
11GO_LDFLAGS+= -X git.gabrielgio.me/dict/db.LibPath=$(SHAREDIR)/libsqlite3ext
12GO_BUILD=go build -v --tags "fts5"
13GO_RUN=go run -v --tags "fts5"
14
15build: ext
16	$(GO_BUILD) -ldflags "$(GO_LDFLAGS)" -o $(OUT) ./cmd/dict/main.go
17
18install:
19	install -Dm755 $(OUT) $(BINDIR)/$(BIN)
20	install -Dm644 $(EXT) $(SHAREDIR)/libsqlite3ext.so
21
22run: ext
23	$(GO_RUN) ./cmd/dict/main.go ui
24
25import: ext
26	$(GO_RUN) ./cmd/dict/main.go import
27
28serve: ext
29	$(GO_RUN) ./cmd/dict/main.go serve
30
31version: ext
32	$(GO_RUN) ./cmd/dict/main.go version
33
34uninstall:
35	rm $(BINDIR)/$(BIN)
36	rm $(SHAREDIR)/libsqlite3ext.so
37
38
39.PHONY: ext
40ext:
41	gcc -shared -o ext/libsqlite3ext.so -fPIC ext/spellfix.c