aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile31
1 files changed, 26 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 8190661..de3668f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,23 @@
-BIN?=bin/dict
+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"
-buid: ext
- $(GO_BUILD) -o $(BIN) ./cmd/dict/main.go
+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
@@ -14,7 +28,14 @@ import: ext
serve: ext
$(GO_RUN) ./cmd/dict/main.go serve
-ext:
- gcc -shared -o ext/libsqlite3ext.so -fPIC ext/spellfix.c
+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