OSDN Git Service

update log (#259)
[bytom/vapor.git] / Makefile
1 ifndef GOOS
2 UNAME_S := $(shell uname -s)
3 ifeq ($(UNAME_S),Darwin)
4         GOOS := darwin
5 else ifeq ($(UNAME_S),Linux)
6         GOOS := linux
7 else
8 $(error "$$GOOS is not defined. If you are using Windows, try to re-make using 'GOOS=windows make ...' ")
9 endif
10 endif
11
12 PACKAGES    := $(shell go list ./... | grep -v '/vendor/' | grep -v '/crypto/ed25519/chainkd' | grep -v '/mining/tensority')
13
14 BUILD_FLAGS := -ldflags "-X github.com/vapor/version.GitCommit=`git rev-parse HEAD`"
15
16
17 VAPORD_BINARY32 := vapord-$(GOOS)_386
18 VAPORD_BINARY64 := vapord-$(GOOS)_amd64
19
20 VAPORCLI_BINARY32 := vaporcli-$(GOOS)_386
21 VAPORCLI_BINARY64 := vaporcli-$(GOOS)_amd64
22
23 VERSION := $(shell awk -F= '/Version =/ {print $$2}' version/version.go | tr -d "\" ")
24
25
26 VAPORD_RELEASE32 := vapord-$(VERSION)-$(GOOS)_386
27 VAPORD_RELEASE64 := vapord-$(VERSION)-$(GOOS)_amd64
28
29 VAPORCLI_RELEASE32 := vaporcli-$(VERSION)-$(GOOS)_386
30 VAPORCLI_RELEASE64 := vaporcli-$(VERSION)-$(GOOS)_amd64
31
32 VAPOR_RELEASE32 := vapor-$(VERSION)-$(GOOS)_386
33 VAPOR_RELEASE64 := vapor-$(VERSION)-$(GOOS)_amd64
34
35 all: test target release-all install
36
37 fedd:
38         @echo "Building fedd to cmd/fedd/fedd"
39         @go build $(BUILD_FLAGS) -o cmd/fedd/fedd cmd/fedd/main.go
40
41 vapord:
42         @echo "Building vapord to cmd/vapord/vapord"
43         @go build $(BUILD_FLAGS) -o cmd/vapord/vapord cmd/vapord/main.go
44
45 vaporcli:
46         @echo "Building vaporcli to cmd/vaporcli/vaporcli"
47         @go build $(BUILD_FLAGS) -o cmd/vaporcli/vaporcli cmd/vaporcli/main.go
48
49 install:
50         @echo "Installing vapord and vaporcli to $(GOPATH)/bin"
51         @go install ./cmd/vapord
52         @go install ./cmd/vaporcli
53
54 target:
55         mkdir -p $@
56
57 binary: target/$(VAPORD_BINARY32) target/$(VAPORD_BINARY64) target/$(VAPORCLI_BINARY32) target/$(VAPORCLI_BINARY64)
58
59 ifeq ($(GOOS),windows)
60 release: binary
61         cd target && cp -f $(VAPORD_BINARY32) $(VAPORD_BINARY32).exe
62         cd target && cp -f $(VAPORCLI_BINARY32) $(VAPORCLI_BINARY32).exe
63         cd target && md5sum $(VAPORD_BINARY32).exe $(VAPORCLI_BINARY32).exe >$(VAPOR_RELEASE32).md5
64         cd target && zip $(VAPOR_RELEASE32).zip $(VAPORD_BINARY32).exe $(VAPORCLI_BINARY32).exe $(VAPOR_RELEASE32).md5
65         cd target && rm -f $(VAPORD_BINARY32) $(VAPORCLI_BINARY32) $(VAPORD_BINARY32).exe $(VAPORCLI_BINARY32).exe $(VAPOR_RELEASE32).md5
66         cd target && cp -f $(VAPORD_BINARY64) $(VAPORD_BINARY64).exe
67         cd target && cp -f $(VAPORCLI_BINARY64) $(VAPORCLI_BINARY64).exe
68         cd target && md5sum $(VAPORD_BINARY64).exe $(VAPORCLI_BINARY64).exe >$(VAPOR_RELEASE64).md5
69         cd target && zip $(VAPOR_RELEASE64).zip $(VAPORD_BINARY64).exe $(VAPORCLI_BINARY64).exe $(VAPOR_RELEASE64).md5
70         cd target && rm -f $(VAPORD_BINARY64) $(VAPORCLI_BINARY64) $(VAPORD_BINARY64).exe $(VAPORCLI_BINARY64).exe $(VAPOR_RELEASE64).md5
71 else
72 release: binary
73         cd target && md5sum $(VAPORD_BINARY32) $(VAPORCLI_BINARY32) >$(VAPOR_RELEASE32).md5
74         cd target && tar -czf $(VAPOR_RELEASE32).tgz $(VAPORD_BINARY32) $(VAPORCLI_BINARY32) $(VAPOR_RELEASE32).md5
75         cd target && rm -f $(VAPORD_BINARY32) $(VAPORCLI_BINARY32) $(VAPOR_RELEASE32).md5
76         cd target && md5sum $(VAPORD_BINARY64) $(VAPORCLI_BINARY64) >$(VAPOR_RELEASE64).md5
77         cd target && tar -czf $(VAPOR_RELEASE64).tgz $(VAPORD_BINARY64) $(VAPORCLI_BINARY64) $(VAPOR_RELEASE64).md5
78         cd target && rm -f $(VAPORD_BINARY64) $(VAPORCLI_BINARY64) $(VAPOR_RELEASE64).md5
79 endif
80
81 release-all: clean
82         GOOS=darwin  make release
83         GOOS=linux   make release
84         GOOS=windows make release
85
86 clean:
87         @echo "Cleaning binaries built..."
88         @rm -rf cmd/vapord/vapord
89         @rm -rf cmd/vaporcli/vaporcli
90         @rm -rf target
91         @rm -rf $(GOPATH)/bin/vapord
92         @rm -rf $(GOPATH)/bin/vaporcli
93         @echo "Cleaning temp test data..."
94         @rm -rf test/pseudo_hsm*
95         @rm -rf blockchain/pseudohsm/testdata/pseudo/
96         @echo "Cleaning sm2 pem files..."
97         @rm -rf crypto/sm2/*.pem
98         @echo "Done."
99
100 target/$(VAPORD_BINARY32):
101         CGO_ENABLED=0 GOARCH=386 go build $(BUILD_FLAGS) -o $@ cmd/vapord/main.go
102
103 target/$(VAPORD_BINARY64):
104         CGO_ENABLED=0 GOARCH=amd64 go build $(BUILD_FLAGS) -o $@ cmd/vapord/main.go
105
106 target/$(VAPORCLI_BINARY32):
107         CGO_ENABLED=0 GOARCH=386 go build $(BUILD_FLAGS) -o $@ cmd/vaporcli/main.go
108
109 target/$(VAPORCLI_BINARY64):
110         CGO_ENABLED=0 GOARCH=amd64 go build $(BUILD_FLAGS) -o $@ cmd/vaporcli/main.go
111
112
113 test:
114         @echo "====> Running go test"
115         @go test -tags "network" $(PACKAGES)
116
117 benchmark:
118         @go test -bench $(PACKAGES)
119
120 functional-tests:
121         @go test -timeout=5m -tags="functional" ./test 
122
123 ci: test
124
125 .PHONY: all target release-all clean test benchmark