-
Notifications
You must be signed in to change notification settings - Fork 32
/
Makefile
40 lines (31 loc) · 986 Bytes
/
Makefile
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
EXE := tgswitch
PKG := github.com/warrensbox/tgswitch
VER := $(shell { git ls-remote --tags . 2>/dev/null || git ls-remote --tags [email protected]:warrensbox/tgswitch.git; } | awk '{if ($$2 ~ "\\^\\{\\}$$") next; print vers[split($$2,vers,"\\/")]}' | sort -n -t. -k1,1 -k2,2 -k3,3 | tail -1)
PATH := build:$(PATH)
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
$(EXE): go.mod *.go lib/*.go
go build -v -ldflags "-X main.version=$(VER)" -o $@ $(PKG)
.PHONY: release
release: $(EXE) darwin linux
.PHONY: darwin linux
darwin linux:
GOOS=$@ go build -ldflags "-X main.version=$(VER)" -o $(EXE)-$(VER)-$@-$(GOARCH) $(PKG)
.PHONY: clean
clean:
rm -f $(EXE) $(EXE)-*-*-*
.PHONY: test
test: $(EXE)
mkdir -p build
mv $(EXE) build
go test -v ./...
.PHONY: install
install: $(EXE)
mkdir -p ~/bin
mv $(EXE) ~/bin
.PHONY: docs
docs:
cd docs; bundle install --path vendor/bundler; bundle exec jekyll build -c _config.yml; cd ..
.PHONY: version
version:
@echo $(VER)