From a26f850c2372718d2b69d6b258d686c68ddba5ff Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sat, 20 Apr 2024 21:07:51 +0200 Subject: ref: Better doc and makefile It adds README explaining how to compile and install. Makefile allows to install dict system wide. --- Makefile | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'Makefile') 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 -- cgit v1.2.3