diff options
| author | Felix Hanley <felix@userspace.com.au> | 2020-11-08 23:33:08 +0000 |
|---|---|---|
| committer | Felix Hanley <felix@userspace.com.au> | 2020-11-16 22:07:05 +0000 |
| commit | 9b72d1065ca106c98b01b62caefdd2cf8f08178c (patch) | |
| tree | 2adfef8b2f48c80ba23b3df90831766a32ea2d49 /Makefile | |
| parent | eda2530094e72463f6aef6e7f9bf524002e248fa (diff) | |
| download | dhtsearch-9b72d1065ca106c98b01b62caefdd2cf8f08178c.tar.gz dhtsearch-9b72d1065ca106c98b01b62caefdd2cf8f08178c.tar.bz2 | |
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 43 |
1 files changed, 20 insertions, 23 deletions
@@ -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 |
