github.com/minio/mc@v0.0.0-20240503112107-b471de8d1882/Makefile (about) 1 PWD := $(shell pwd) 2 GOPATH := $(shell go env GOPATH) 3 LDFLAGS := $(shell go run buildscripts/gen-ldflags.go) 4 5 GOARCH := $(shell go env GOARCH) 6 GOOS := $(shell go env GOOS) 7 8 VERSION ?= $(shell git describe --tags) 9 TAG ?= "minio/mc:$(VERSION)" 10 11 all: build 12 13 checks: 14 @echo "Checking dependencies" 15 @(env bash $(PWD)/buildscripts/checkdeps.sh) 16 17 getdeps: 18 @mkdir -p ${GOPATH}/bin 19 @echo "Installing golangci-lint" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin 20 @echo "Installing stringer" && go install -v golang.org/x/tools/cmd/stringer@latest 21 @echo "Installing staticheck" && go install honnef.co/go/tools/cmd/staticcheck@latest 22 23 crosscompile: 24 @(env bash $(PWD)/buildscripts/cross-compile.sh) 25 26 verifiers: getdeps vet lint 27 28 docker: build 29 @docker build -t $(TAG) . -f Dockerfile.dev 30 31 vet: 32 @echo "Running $@" 33 @GO111MODULE=on go vet github.com/minio/mc/... 34 35 lint: getdeps 36 @echo "Running $@ check" 37 @GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=5m --config ./.golangci.yml 38 @GO111MODULE=on ${GOPATH}/bin/staticcheck -tests=false -checks="all,-ST1000,-ST1003,-ST1016,-ST1020,-ST1021,-ST1022,-ST1023,-ST1005" ./... 39 40 # Builds mc, runs the verifiers then runs the tests. 41 check: test 42 test: verifiers build 43 @echo "Running unit tests" 44 @GO111MODULE=on CGO_ENABLED=0 go test -tags kqueue ./... 1>/dev/null 45 @echo "Running functional tests" 46 @GO111MODULE=on MC_TEST_RUN_FULL_SUITE=true go test -race -v --timeout 20m ./... -run Test_FullSuite 47 48 test-race: verifiers build 49 @echo "Running unit tests under -race" 50 @GO111MODULE=on go test -race -v --timeout 20m ./... 1>/dev/null 51 52 # Verify mc binary 53 verify: 54 @echo "Verifying build with race" 55 @GO111MODULE=on CGO_ENABLED=1 go build -race -tags kqueue -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/mc 1>/dev/null 56 @echo "Running functional tests" 57 @GO111MODULE=on MC_TEST_RUN_FULL_SUITE=true go test -race -v --timeout 20m ./... -run Test_FullSuite 58 59 # Builds mc locally. 60 build: checks 61 @echo "Building mc binary to './mc'" 62 @GO111MODULE=on CGO_ENABLED=0 go build -trimpath -tags kqueue --ldflags "$(LDFLAGS)" -o $(PWD)/mc 63 64 hotfix-vars: 65 $(eval LDFLAGS := $(shell MC_RELEASE="RELEASE" MC_HOTFIX="hotfix.$(shell git rev-parse --short HEAD)" go run buildscripts/gen-ldflags.go $(shell git describe --tags --abbrev=0 | \ 66 sed 's#RELEASE\.\([0-9]\+\)-\([0-9]\+\)-\([0-9]\+\)T\([0-9]\+\)-\([0-9]\+\)-\([0-9]\+\)Z#\1-\2-\3T\4:\5:\6Z#'))) 67 $(eval VERSION := $(shell git describe --tags --abbrev=0).hotfix.$(shell git rev-parse --short HEAD)) 68 $(eval TAG := "minio/mc:$(VERSION)") 69 70 hotfix: hotfix-vars install ## builds mc binary with hotfix tags 71 @mv -f ./mc ./mc.$(VERSION) 72 @minisign -qQSm ./mc.$(VERSION) -s "${CRED_DIR}/minisign.key" < "${CRED_DIR}/minisign-passphrase" 73 @sha256sum < ./mc.$(VERSION) | sed 's, -,mc.$(VERSION),g' > mc.$(VERSION).sha256sum 74 75 hotfix-push: hotfix 76 @scp -q -r mc.$(VERSION)* minio@dl-0.min.io:~/releases/client/mc/hotfixes/linux-amd64/archive/ 77 @scp -q -r mc.$(VERSION)* minio@dl-1.min.io:~/releases/client/mc/hotfixes/linux-amd64/archive/ 78 @echo "Published new hotfix binaries at https://dl.min.io/client/mc/hotfixes/linux-amd64/archive/mc.$(VERSION)" 79 80 docker-hotfix-push: docker-hotfix 81 @docker push -q $(TAG) && echo "Published new container $(TAG)" 82 83 docker-hotfix: hotfix-push checks ## builds mc docker container with hotfix tags 84 @echo "Building mc docker image '$(TAG)'" 85 @docker build -q --no-cache -t $(TAG) --build-arg RELEASE=$(VERSION) . -f Dockerfile.hotfix 86 87 # Builds MinIO and installs it to $GOPATH/bin. 88 install: build 89 @echo "Installing mc binary to '$(GOPATH)/bin/mc'" 90 @mkdir -p $(GOPATH)/bin && cp -f $(PWD)/mc $(GOPATH)/bin/mc 91 @echo "Installation successful. To learn more, try \"mc --help\"." 92 93 clean: 94 @echo "Cleaning up all the generated files" 95 @find . -name '*.test' | xargs rm -fv 96 @find . -name '*~' | xargs rm -fv 97 @rm -rvf mc 98 @rm -rvf build 99 @rm -rvf release