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/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 vapord to cmd/vapord/vapord"
43 @go build $(BUILD_FLAGS) -o cmd/vapord/vapord cmd/vapord/main.go
46 @echo "Building vaporcli to cmd/vaporcli/vaporcli"
47 @go build $(BUILD_FLAGS) -o cmd/vaporcli/vaporcli cmd/vaporcli/main.go
50 @echo "Installing vapord and vaporcli to $(GOPATH)/bin"
51 @go install ./cmd/vapord
52 @go install ./cmd/vaporcli
57 binary: target/$(VAPORD_BINARY32) target/$(VAPORD_BINARY64) target/$(VAPORCLI_BINARY32) target/$(VAPORCLI_BINARY64)
59 ifeq ($(GOOS),windows)
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
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
82 GOOS=darwin make release
83 GOOS=linux make release
84 GOOS=windows make release
87 @echo "Cleaning binaries built..."
88 @rm -rf cmd/vapord/vapord
89 @rm -rf cmd/vaporcli/vaporcli
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
100 target/$(VAPORD_BINARY32):
101 CGO_ENABLED=0 GOARCH=386 go build $(BUILD_FLAGS) -o $@ cmd/vapord/main.go
103 target/$(VAPORD_BINARY64):
104 CGO_ENABLED=0 GOARCH=amd64 go build $(BUILD_FLAGS) -o $@ cmd/vapord/main.go
106 target/$(VAPORCLI_BINARY32):
107 CGO_ENABLED=0 GOARCH=386 go build $(BUILD_FLAGS) -o $@ cmd/vaporcli/main.go
109 target/$(VAPORCLI_BINARY64):
110 CGO_ENABLED=0 GOARCH=amd64 go build $(BUILD_FLAGS) -o $@ cmd/vaporcli/main.go
114 @echo "====> Running go test"
115 @go test -tags "network" $(PACKAGES)
118 @go test -bench $(PACKAGES)
121 @go test -timeout=5m -tags="functional" ./test
125 .PHONY: all target release-all clean test benchmark