aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-04-20 21:07:51 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-04-20 21:15:45 +0200
commita26f850c2372718d2b69d6b258d686c68ddba5ff (patch)
treeca45aa4a57ded8381d404804c4b07255fc01b563 /Makefile
parent07f7f50fd5ff577896314984d1f365631be093bc (diff)
downloaddict-a26f850c2372718d2b69d6b258d686c68ddba5ff.tar.gz
dict-a26f850c2372718d2b69d6b258d686c68ddba5ff.tar.bz2
dict-a26f850c2372718d2b69d6b258d686c68ddba5ff.zip
ref: Better doc and makefile
It adds README explaining how to compile and install. Makefile allows to install dict system wide.
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