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