-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
52 lines (37 loc) · 1.2 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
PACKAGE=github.com/moznion/amugine
PKGS := $(shell go list ./...)
GOVERSION=$(shell go version)
GOOS=$(word 1,$(subst /, ,$(lastword $(GOVERSION))))
GOARCH=$(word 2,$(subst /, ,$(lastword $(GOVERSION))))
RELEASE_DIR=bin
REVISION=$(shell git rev-parse --verify HEAD)
build: $(RELEASE_DIR)/amugine_$(GOOS)_$(GOARCH)
all: check clean build-linux-amd64 build-linux-386 build-darwin-amd64 build-darwin-386 build-windows-amd64 build-windows-386
build-linux-amd64:
@$(MAKE) build GOOS=linux GOARCH=amd64
build-linux-386:
@$(MAKE) build GOOS=linux GOARCH=386
build-darwin-amd64:
@$(MAKE) build GOOS=darwin GOARCH=amd64
build-darwin-386:
@$(MAKE) build GOOS=darwin GOARCH=386
build-windows-amd64:
@$(MAKE) build GOOS=windows GOARCH=amd64
build-windows-386:
@$(MAKE) build GOOS=windows GOARCH=386
$(RELEASE_DIR)/amugine_$(GOOS)_$(GOARCH):
ifndef VERSION
@echo '[ERROR] $$VERSION must be specified'
exit 255
endif
go build -ldflags "-X $(PACKAGE).rev=$(REVISION) -X $(PACKAGE).ver=$(VERSION)" \
-o $(RELEASE_DIR)/amugine_$(GOOS)_$(GOARCH)_$(VERSION) cmd/amugine/amugine.go
clean:
rm -rf $(RELEASE_DIR)/amugine_*
check: test lint vet
test:
go test $(PKGS)
lint:
golint -set_exit_status $(PKGS)
vet:
go vet $(PKGS)