github.com/Bytom/bytom@v1.1.2-0.20210127130405-ae40204c0b09/Makefile (about) 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 PACKAGES += 'github.com/bytom/bytom/mining/tensority/go_algorithm' 14 15 BUILD_FLAGS := -ldflags "-X github.com/bytom/bytom/version.GitCommit=`git rev-parse HEAD`" 16 17 MINER_BINARY32 := miner-$(GOOS)_386 18 MINER_BINARY64 := miner-$(GOOS)_amd64 19 20 BYTOMD_BINARY32 := bytomd-$(GOOS)_386 21 BYTOMD_BINARY64 := bytomd-$(GOOS)_amd64 22 23 BYTOMCLI_BINARY32 := bytomcli-$(GOOS)_386 24 BYTOMCLI_BINARY64 := bytomcli-$(GOOS)_amd64 25 26 VERSION := $(shell awk -F= '/Version =/ {print $$2}' version/version.go | tr -d "\" ") 27 28 MINER_RELEASE32 := miner-$(VERSION)-$(GOOS)_386 29 MINER_RELEASE64 := miner-$(VERSION)-$(GOOS)_amd64 30 31 BYTOMD_RELEASE32 := bytomd-$(VERSION)-$(GOOS)_386 32 BYTOMD_RELEASE64 := bytomd-$(VERSION)-$(GOOS)_amd64 33 34 BYTOMCLI_RELEASE32 := bytomcli-$(VERSION)-$(GOOS)_386 35 BYTOMCLI_RELEASE64 := bytomcli-$(VERSION)-$(GOOS)_amd64 36 37 BYTOM_RELEASE32 := bytom-$(VERSION)-$(GOOS)_386 38 BYTOM_RELEASE64 := bytom-$(VERSION)-$(GOOS)_amd64 39 40 all: test target release-all install 41 42 bytomd: 43 @echo "Building bytomd to cmd/bytomd/bytomd" 44 @go build $(BUILD_FLAGS) -o cmd/bytomd/bytomd cmd/bytomd/main.go 45 46 bytomd-simd: 47 @echo "Building SIMD version bytomd to cmd/bytomd/bytomd" 48 @cd mining/tensority/cgo_algorithm/lib/ && make 49 @go build -tags="simd" $(BUILD_FLAGS) -o cmd/bytomd/bytomd cmd/bytomd/main.go 50 51 bytomcli: 52 @echo "Building bytomcli to cmd/bytomcli/bytomcli" 53 @go build $(BUILD_FLAGS) -o cmd/bytomcli/bytomcli cmd/bytomcli/main.go 54 55 install: 56 @echo "Installing bytomd and bytomcli to $(GOPATH)/bin" 57 @go install ./cmd/bytomd 58 @go install ./cmd/bytomcli 59 60 target: 61 mkdir -p $@ 62 63 binary: target/$(BYTOMD_BINARY32) target/$(BYTOMD_BINARY64) target/$(BYTOMCLI_BINARY32) target/$(BYTOMCLI_BINARY64) target/$(MINER_BINARY32) target/$(MINER_BINARY64) 64 65 ifeq ($(GOOS),windows) 66 release: binary 67 cd target && cp -f $(MINER_BINARY32) $(MINER_BINARY32).exe 68 cd target && cp -f $(BYTOMD_BINARY32) $(BYTOMD_BINARY32).exe 69 cd target && cp -f $(BYTOMCLI_BINARY32) $(BYTOMCLI_BINARY32).exe 70 cd target && md5sum $(MINER_BINARY32).exe $(BYTOMD_BINARY32).exe $(BYTOMCLI_BINARY32).exe >$(BYTOM_RELEASE32).md5 71 cd target && zip $(BYTOM_RELEASE32).zip $(MINER_BINARY32).exe $(BYTOMD_BINARY32).exe $(BYTOMCLI_BINARY32).exe $(BYTOM_RELEASE32).md5 72 cd target && rm -f $(MINER_BINARY32) $(BYTOMD_BINARY32) $(BYTOMCLI_BINARY32) $(MINER_BINARY32).exe $(BYTOMD_BINARY32).exe $(BYTOMCLI_BINARY32).exe $(BYTOM_RELEASE32).md5 73 cd target && cp -f $(MINER_BINARY64) $(MINER_BINARY64).exe 74 cd target && cp -f $(BYTOMD_BINARY64) $(BYTOMD_BINARY64).exe 75 cd target && cp -f $(BYTOMCLI_BINARY64) $(BYTOMCLI_BINARY64).exe 76 cd target && md5sum $(MINER_BINARY64).exe $(BYTOMD_BINARY64).exe $(BYTOMCLI_BINARY64).exe >$(BYTOM_RELEASE64).md5 77 cd target && zip $(BYTOM_RELEASE64).zip $(MINER_BINARY64).exe $(BYTOMD_BINARY64).exe $(BYTOMCLI_BINARY64).exe $(BYTOM_RELEASE64).md5 78 cd target && rm -f $(MINER_BINARY64) $(BYTOMD_BINARY64) $(BYTOMCLI_BINARY64) $(MINER_BINARY64).exe $(BYTOMD_BINARY64).exe $(BYTOMCLI_BINARY64).exe $(BYTOM_RELEASE64).md5 79 else 80 release: binary 81 cd target && md5sum $(MINER_BINARY32) $(BYTOMD_BINARY32) $(BYTOMCLI_BINARY32) >$(BYTOM_RELEASE32).md5 82 cd target && tar -czf $(BYTOM_RELEASE32).tgz $(MINER_BINARY32) $(BYTOMD_BINARY32) $(BYTOMCLI_BINARY32) $(BYTOM_RELEASE32).md5 83 cd target && rm -f $(MINER_BINARY32) $(BYTOMD_BINARY32) $(BYTOMCLI_BINARY32) $(BYTOM_RELEASE32).md5 84 cd target && md5sum $(MINER_BINARY64) $(BYTOMD_BINARY64) $(BYTOMCLI_BINARY64) >$(BYTOM_RELEASE64).md5 85 cd target && tar -czf $(BYTOM_RELEASE64).tgz $(MINER_BINARY64) $(BYTOMD_BINARY64) $(BYTOMCLI_BINARY64) $(BYTOM_RELEASE64).md5 86 cd target && rm -f $(MINER_BINARY64) $(BYTOMD_BINARY64) $(BYTOMCLI_BINARY64) $(BYTOM_RELEASE64).md5 87 endif 88 89 release-all: clean 90 GOOS=darwin make release 91 GOOS=linux make release 92 GOOS=windows make release 93 94 clean: 95 @echo "Cleaning binaries built..." 96 @rm -rf cmd/bytomd/bytomd 97 @rm -rf cmd/bytomcli/bytomcli 98 @rm -rf cmd/miner/miner 99 @rm -rf target 100 @rm -rf $(GOPATH)/bin/bytomd 101 @rm -rf $(GOPATH)/bin/bytomcli 102 @echo "Cleaning temp test data..." 103 @rm -rf test/pseudo_hsm* 104 @rm -rf blockchain/pseudohsm/testdata/pseudo/ 105 @echo "Cleaning sm2 pem files..." 106 @rm -rf crypto/sm2/*.pem 107 @echo "Done." 108 109 target/$(BYTOMD_BINARY32): 110 CGO_ENABLED=0 GOARCH=386 go build $(BUILD_FLAGS) -o $@ cmd/bytomd/main.go 111 112 target/$(BYTOMD_BINARY64): 113 CGO_ENABLED=0 GOARCH=amd64 go build $(BUILD_FLAGS) -o $@ cmd/bytomd/main.go 114 115 target/$(BYTOMCLI_BINARY32): 116 CGO_ENABLED=0 GOARCH=386 go build $(BUILD_FLAGS) -o $@ cmd/bytomcli/main.go 117 118 target/$(BYTOMCLI_BINARY64): 119 CGO_ENABLED=0 GOARCH=amd64 go build $(BUILD_FLAGS) -o $@ cmd/bytomcli/main.go 120 121 target/$(MINER_BINARY32): 122 CGO_ENABLED=0 GOARCH=386 go build $(BUILD_FLAGS) -o $@ cmd/miner/main.go 123 124 target/$(MINER_BINARY64): 125 CGO_ENABLED=0 GOARCH=amd64 go build $(BUILD_FLAGS) -o $@ cmd/miner/main.go 126 127 test: 128 @echo "====> Running go test" 129 @go test -tags "network" $(PACKAGES) 130 131 benchmark: 132 @go test -bench $(PACKAGES) 133 134 functional-tests: 135 @go test -timeout=5m -tags="functional" ./test 136 137 ci: test functional-tests 138 139 .PHONY: all target release-all clean test benchmark