2 UNAME_S := $(shell uname -s)
3 ifeq ($(UNAME_S),Darwin)
5 else ifeq ($(UNAME_S),Linux)
8 $(error "$$GOOS is not defined. If you are using Windows, try to re-make using 'GOOS=windows make ...' ")
12 PACKAGES := $(shell go list ./... | grep -v '/vendor/' | grep -v '/crypto/ed25519/chainkd' | grep -v '/mining/tensority')
14 BUILD_FLAGS := -ldflags "-X github.com/bytom/vapor/version.GitCommit=`git rev-parse HEAD`"
17 VAPORD_BINARY32 := vapord-$(GOOS)_386
18 VAPORD_BINARY64 := vapord-$(GOOS)_amd64
20 VAPORCLI_BINARY32 := vaporcli-$(GOOS)_386
21 VAPORCLI_BINARY64 := vaporcli-$(GOOS)_amd64
23 VERSION := $(shell awk -F= '/Version =/ {print $$2}' version/version.go | tr -d "\" ")
26 VAPORD_RELEASE32 := vapord-$(VERSION)-$(GOOS)_386
27 VAPORD_RELEASE64 := vapord-$(VERSION)-$(GOOS)_amd64
29 VAPORCLI_RELEASE32 := vaporcli-$(VERSION)-$(GOOS)_386
30 VAPORCLI_RELEASE64 := vaporcli-$(VERSION)-$(GOOS)_amd64
32 VAPOR_RELEASE32 := vapor-$(VERSION)-$(GOOS)_386
33 VAPOR_RELEASE64 := vapor-$(VERSION)-$(GOOS)_amd64
35 all: test target release-all install
38 @echo "Building fedd to cmd/fedd/fedd"
39 @go build $(BUILD_FLAGS) -o cmd/fedd/fedd cmd/fedd/main.go
42 @echo "Building precognitive to cmd/precognitive/precognitive"
43 @go build $(BUILD_FLAGS) -o cmd/precognitive/precognitive cmd/precognitive/main.go
46 @echo "Building vapord to cmd/vapord/vapord"
47 @go build $(BUILD_FLAGS) -o cmd/vapord/vapord cmd/vapord/main.go
50 @echo "Building vaporcli to cmd/vaporcli/vaporcli"
51 @go build $(BUILD_FLAGS) -o cmd/vaporcli/vaporcli cmd/vaporcli/main.go
54 @echo "Installing vapord and vaporcli to $(GOPATH)/bin"
55 @go install ./cmd/vapord
56 @go install ./cmd/vaporcli
61 binary: target/$(VAPORD_BINARY32) target/$(VAPORD_BINARY64) target/$(VAPORCLI_BINARY32) target/$(VAPORCLI_BINARY64)
63 ifeq ($(GOOS),windows)
65 cd target && cp -f $(VAPORD_BINARY32) $(VAPORD_BINARY32).exe
66 cd target && cp -f $(VAPORCLI_BINARY32) $(VAPORCLI_BINARY32).exe
67 cd target && md5sum $(VAPORD_BINARY32).exe $(VAPORCLI_BINARY32).exe >$(VAPOR_RELEASE32).md5
68 cd target && zip $(VAPOR_RELEASE32).zip $(VAPORD_BINARY32).exe $(VAPORCLI_BINARY32).exe $(VAPOR_RELEASE32).md5
69 cd target && rm -f $(VAPORD_BINARY32) $(VAPORCLI_BINARY32) $(VAPORD_BINARY32).exe $(VAPORCLI_BINARY32).exe $(VAPOR_RELEASE32).md5
70 cd target && cp -f $(VAPORD_BINARY64) $(VAPORD_BINARY64).exe
71 cd target && cp -f $(VAPORCLI_BINARY64) $(VAPORCLI_BINARY64).exe
72 cd target && md5sum $(VAPORD_BINARY64).exe $(VAPORCLI_BINARY64).exe >$(VAPOR_RELEASE64).md5
73 cd target && zip $(VAPOR_RELEASE64).zip $(VAPORD_BINARY64).exe $(VAPORCLI_BINARY64).exe $(VAPOR_RELEASE64).md5
74 cd target && rm -f $(VAPORD_BINARY64) $(VAPORCLI_BINARY64) $(VAPORD_BINARY64).exe $(VAPORCLI_BINARY64).exe $(VAPOR_RELEASE64).md5
77 cd target && md5sum $(VAPORD_BINARY32) $(VAPORCLI_BINARY32) >$(VAPOR_RELEASE32).md5
78 cd target && tar -czf $(VAPOR_RELEASE32).tgz $(VAPORD_BINARY32) $(VAPORCLI_BINARY32) $(VAPOR_RELEASE32).md5
79 cd target && rm -f $(VAPORD_BINARY32) $(VAPORCLI_BINARY32) $(VAPOR_RELEASE32).md5
80 cd target && md5sum $(VAPORD_BINARY64) $(VAPORCLI_BINARY64) >$(VAPOR_RELEASE64).md5
81 cd target && tar -czf $(VAPOR_RELEASE64).tgz $(VAPORD_BINARY64) $(VAPORCLI_BINARY64) $(VAPOR_RELEASE64).md5
82 cd target && rm -f $(VAPORD_BINARY64) $(VAPORCLI_BINARY64) $(VAPOR_RELEASE64).md5
86 GOOS=darwin make release
87 GOOS=linux make release
88 GOOS=windows make release
91 @echo "Cleaning binaries built..."
92 @rm -rf cmd/vapord/vapord
93 @rm -rf cmd/vaporcli/vaporcli
95 @rm -rf $(GOPATH)/bin/vapord
96 @rm -rf $(GOPATH)/bin/vaporcli
97 @echo "Cleaning temp test data..."
98 @rm -rf test/pseudo_hsm*
99 @rm -rf blockchain/pseudohsm/testdata/pseudo/
100 @echo "Cleaning sm2 pem files..."
101 @rm -rf crypto/sm2/*.pem
104 target/$(VAPORD_BINARY32):
105 CGO_ENABLED=0 GOARCH=386 go build $(BUILD_FLAGS) -o $@ cmd/vapord/main.go
107 target/$(VAPORD_BINARY64):
108 CGO_ENABLED=0 GOARCH=amd64 go build $(BUILD_FLAGS) -o $@ cmd/vapord/main.go
110 target/$(VAPORCLI_BINARY32):
111 CGO_ENABLED=0 GOARCH=386 go build $(BUILD_FLAGS) -o $@ cmd/vaporcli/main.go
113 target/$(VAPORCLI_BINARY64):
114 CGO_ENABLED=0 GOARCH=amd64 go build $(BUILD_FLAGS) -o $@ cmd/vaporcli/main.go
118 @echo "====> Running go test"
119 @go test -tags "network" $(PACKAGES)
122 @go test -bench $(PACKAGES)
125 @go test -timeout=5m -tags="functional" ./test
129 .PHONY: all target release-all clean test benchmark