aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: de3668f59e569efacb48a6a89cb0b04318b0309a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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