aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: eb5ee50a19faa029f62b67fbd3a4026c5f046165 (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
VERSION ?= $(shell git describe --tags --always)
SRC	:= $(shell find . -type f -name '*.go')
FLAGS	:= --tags fts5
PLAT	:= windows darwin linux freebsd openbsd
BINARY	:= $(patsubst %,dist/%,$(shell find cmd/* -maxdepth 0 -type d -exec basename {} \;))
RELEASE	:= $(foreach os, $(PLAT), $(patsubst %,%-$(os), $(BINARY)))

.PHONY: build
build: sqlite $(BINARY)

.PHONY: release
release: $(RELEASE)

dist/%: export GOOS=$(word 2,$(subst -, ,$*))
dist/%: bin=$(word 1,$(subst -, ,$*))
dist/%: $(SRC) $(shell find cmd/$(bin) -type f -name '*.go')
	go build -ldflags "-X main.version=$(VERSION)" $(FLAGS) \
	     -o $@ ./cmd/$(bin)

sqlite:
	CGO_ENABLED=1 go get -u $(FLAGS) github.com/mattn/go-sqlite3 \
		&& go install $(FLAGS) github.com/mattn/go-sqlite3

.PHONY: test
test:
	go test -short -coverprofile=coverage.out ./... \
		&& go tool cover -func=coverage.out

.PHONY: lint
lint: ; go vet ./...

.PHONY: clean
clean:
	rm -f coverage*
	rm -rf dist