aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorFelix Hanley <felix@userspace.com.au>2020-11-08 23:33:08 +0000
committerFelix Hanley <felix@userspace.com.au>2020-11-16 22:07:05 +0000
commit9b72d1065ca106c98b01b62caefdd2cf8f08178c (patch)
tree2adfef8b2f48c80ba23b3df90831766a32ea2d49 /Makefile
parenteda2530094e72463f6aef6e7f9bf524002e248fa (diff)
downloaddhtsearch-9b72d1065ca106c98b01b62caefdd2cf8f08178c.tar.gz
dhtsearch-9b72d1065ca106c98b01b62caefdd2cf8f08178c.tar.bz2
Clean up build and docsHEADv1.1.0master
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile43
1 files changed, 20 insertions, 23 deletions
diff --git a/Makefile b/Makefile
index 5457646..eb5ee50 100644
--- a/Makefile
+++ b/Makefile
@@ -1,39 +1,36 @@
-TARGETS = freebsd-amd64 linux-386 linux-amd64 linux-arm linux-arm64 darwin-amd64 windows-386 windows-amd64
-CMD = dhtsearch
VERSION ?= $(shell git describe --tags --always)
-SRC = $(shell find . -type f -name '*.go')
-FLAGS = --tags fts5
-BINARIES = $(patsubst %,$(CMD)-%-v$(VERSION), $(TARGETS))
-
-.PHONY: help
-help:
- @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
- |sort \
- |awk 'BEGIN{FS=":.*?## "};{printf "\033[36m%-30s\033[0m %s\n",$$1,$$2}'
+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 $(BINARIES) ## Build all binaries
+build: sqlite $(BINARY)
+
+.PHONY: release
+release: $(RELEASE)
-$(BINARIES): $(SRC)
- cd cmd && env GOOS=`echo $@ |cut -d'-' -f2` \
- GOARCH=`echo $@ |cut -d'-' -f3 |cut -d'.' -f1` \
- go build -o ../$@ $(FLAGS) -ldflags="-w -s -X=main.version=$(VERSION)"
+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:
- go get -u $(FLAGS) github.com/mattn/go-sqlite3 \
+ CGO_ENABLED=1 go get -u $(FLAGS) github.com/mattn/go-sqlite3 \
&& go install $(FLAGS) github.com/mattn/go-sqlite3
.PHONY: test
-test: ## Run tests and create coverage report
+test:
go test -short -coverprofile=coverage.out ./... \
&& go tool cover -func=coverage.out
.PHONY: lint
-lint:
- revive ./...
+lint: ; go vet ./...
.PHONY: clean
-clean: ## Clean up temp files and binaries
- rm -f $(CMD)-*-v*
- rm -rf coverage*
+clean:
+ rm -f coverage*
+ rm -rf dist