github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/Makefile (about) 1 SHELL = bash 2 # Branch we are working on 3 BRANCH := $(or $(BUILD_SOURCEBRANCHNAME),$(lastword $(subst /, ,$(GITHUB_REF))),$(shell git rev-parse --abbrev-ref HEAD)) 4 # Tag of the current commit, if any. If this is not "" then we are building a release 5 RELEASE_TAG := $(shell git tag -l --points-at HEAD) 6 # Version of last release (may not be on this branch) 7 VERSION := $(shell cat VERSION) 8 # Last tag on this branch 9 LAST_TAG := $(shell git describe --tags --abbrev=0) 10 # Next version 11 NEXT_VERSION := $(shell echo $(VERSION) | awk -F. -v OFS=. '{print $$1,$$2+1,0}') 12 NEXT_PATCH_VERSION := $(shell echo $(VERSION) | awk -F. -v OFS=. '{print $$1,$$2,$$3+1}') 13 # If we are working on a release, override branch to master 14 ifdef RELEASE_TAG 15 BRANCH := master 16 LAST_TAG := $(shell git describe --abbrev=0 --tags $(VERSION)^) 17 endif 18 TAG_BRANCH := .$(BRANCH) 19 BRANCH_PATH := branch/$(BRANCH)/ 20 # If building HEAD or master then unset TAG_BRANCH and BRANCH_PATH 21 ifeq ($(subst HEAD,,$(subst master,,$(BRANCH))),) 22 TAG_BRANCH := 23 BRANCH_PATH := 24 endif 25 # Make version suffix -beta.NNNN.CCCCCCCC (N=Commit number, C=Commit) 26 VERSION_SUFFIX := -beta.$(shell git rev-list --count HEAD).$(shell git show --no-patch --no-notes --pretty='%h' HEAD) 27 # TAG is current version + commit number + commit + branch 28 TAG := $(VERSION)$(VERSION_SUFFIX)$(TAG_BRANCH) 29 ifdef RELEASE_TAG 30 TAG := $(RELEASE_TAG) 31 endif 32 GO_VERSION := $(shell go version) 33 GO_OS := $(shell go env GOOS) 34 ifdef BETA_SUBDIR 35 BETA_SUBDIR := /$(BETA_SUBDIR) 36 endif 37 BETA_PATH := $(BRANCH_PATH)$(TAG)$(BETA_SUBDIR) 38 BETA_URL := https://beta.rclone.org/$(BETA_PATH)/ 39 BETA_UPLOAD_ROOT := beta.rclone.org: 40 BETA_UPLOAD := $(BETA_UPLOAD_ROOT)/$(BETA_PATH) 41 # Pass in GOTAGS=xyz on the make command line to set build tags 42 ifdef GOTAGS 43 BUILDTAGS=-tags "$(GOTAGS)" 44 LINTTAGS=--build-tags "$(GOTAGS)" 45 endif 46 LDFLAGS=--ldflags "-s -X github.com/rclone/rclone/fs.Version=$(TAG)" 47 48 .PHONY: rclone test_all vars version 49 50 rclone: 51 ifeq ($(GO_OS),windows) 52 go run bin/resource_windows.go -version $(TAG) -syso resource_windows_`go env GOARCH`.syso 53 endif 54 go build -v $(LDFLAGS) $(BUILDTAGS) $(BUILD_ARGS) 55 ifeq ($(GO_OS),windows) 56 rm resource_windows_`go env GOARCH`.syso 57 endif 58 mkdir -p `go env GOPATH`/bin/ 59 cp -av rclone`go env GOEXE` `go env GOPATH`/bin/rclone`go env GOEXE`.new 60 mv -v `go env GOPATH`/bin/rclone`go env GOEXE`.new `go env GOPATH`/bin/rclone`go env GOEXE` 61 62 test_all: 63 go install $(LDFLAGS) $(BUILDTAGS) $(BUILD_ARGS) github.com/rclone/rclone/fstest/test_all 64 65 vars: 66 @echo SHELL="'$(SHELL)'" 67 @echo BRANCH="'$(BRANCH)'" 68 @echo TAG="'$(TAG)'" 69 @echo VERSION="'$(VERSION)'" 70 @echo GO_VERSION="'$(GO_VERSION)'" 71 @echo BETA_URL="'$(BETA_URL)'" 72 73 btest: 74 @echo "[$(TAG)]($(BETA_URL)) on branch [$(BRANCH)](https://github.com/rclone/rclone/tree/$(BRANCH)) (uploaded in 15-30 mins)" | xclip -r -sel clip 75 @echo "Copied markdown of beta release to clip board" 76 77 btesth: 78 @echo "<a href="$(BETA_URL)">$(TAG)</a> on branch <a href="https://github.com/rclone/rclone/tree/$(BRANCH)">$(BRANCH)</a> (uploaded in 15-30 mins)" | xclip -r -sel clip -t text/html 79 @echo "Copied beta release in HTML to clip board" 80 81 version: 82 @echo '$(TAG)' 83 84 # Full suite of integration tests 85 test: rclone test_all 86 -test_all 2>&1 | tee test_all.log 87 @echo "Written logs in test_all.log" 88 89 # Quick test 90 quicktest: 91 RCLONE_CONFIG="/notfound" go test $(LDFLAGS) $(BUILDTAGS) ./... 92 93 racequicktest: 94 RCLONE_CONFIG="/notfound" go test $(LDFLAGS) $(BUILDTAGS) -cpu=2 -race ./... 95 96 compiletest: 97 RCLONE_CONFIG="/notfound" go test $(LDFLAGS) $(BUILDTAGS) -run XXX ./... 98 99 # Do source code quality checks 100 check: rclone 101 @echo "-- START CODE QUALITY REPORT -------------------------------" 102 @golangci-lint run $(LINTTAGS) ./... 103 @echo "-- END CODE QUALITY REPORT ---------------------------------" 104 105 # Get the build dependencies 106 build_dep: 107 go run bin/get-github-release.go -use-api -extract golangci-lint golangci/golangci-lint 'golangci-lint-.*\.tar\.gz' 108 109 # Get the release dependencies we only install on linux 110 release_dep_linux: 111 go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest 112 113 # Update dependencies 114 showupdates: 115 @echo "*** Direct dependencies that could be updated ***" 116 @GO111MODULE=on go list -u -f '{{if (and (not (or .Main .Indirect)) .Update)}}{{.Path}}: {{.Version}} -> {{.Update.Version}}{{end}}' -m all 2> /dev/null 117 118 # Update direct dependencies only 119 updatedirect: 120 GO111MODULE=on go get -d $$(go list -m -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' all) 121 GO111MODULE=on go mod tidy 122 123 # Update direct and indirect dependencies and test dependencies 124 update: 125 GO111MODULE=on go get -d -u -t ./... 126 GO111MODULE=on go mod tidy 127 128 # Tidy the module dependencies 129 tidy: 130 GO111MODULE=on go mod tidy 131 132 doc: rclone.1 MANUAL.html MANUAL.txt rcdocs commanddocs 133 134 rclone.1: MANUAL.md 135 pandoc -s --from markdown-smart --to man MANUAL.md -o rclone.1 136 137 MANUAL.md: bin/make_manual.py docs/content/*.md commanddocs backenddocs rcdocs 138 ./bin/make_manual.py 139 140 MANUAL.html: MANUAL.md 141 pandoc -s --from markdown-smart --to html MANUAL.md -o MANUAL.html 142 143 MANUAL.txt: MANUAL.md 144 pandoc -s --from markdown-smart --to plain MANUAL.md -o MANUAL.txt 145 146 commanddocs: rclone 147 XDG_CACHE_HOME="" XDG_CONFIG_HOME="" HOME="\$$HOME" USER="\$$USER" rclone gendocs docs/content/ 148 149 backenddocs: rclone bin/make_backend_docs.py 150 XDG_CACHE_HOME="" XDG_CONFIG_HOME="" HOME="\$$HOME" USER="\$$USER" ./bin/make_backend_docs.py 151 152 rcdocs: rclone 153 bin/make_rc_docs.sh 154 155 install: rclone 156 install -d ${DESTDIR}/usr/bin 157 install ${GOPATH}/bin/rclone ${DESTDIR}/usr/bin 158 159 clean: 160 go clean ./... 161 find . -name \*~ | xargs -r rm -f 162 rm -rf build docs/public 163 rm -f rclone fs/operations/operations.test fs/sync/sync.test fs/test_all.log test.log 164 165 website: 166 rm -rf docs/public 167 cd docs && hugo 168 @if grep -R "raw HTML omitted" docs/public ; then echo "ERROR: found unescaped HTML - fix the markdown source" ; fi 169 170 upload_website: website 171 rclone -v sync docs/public www.rclone.org: 172 173 upload_test_website: website 174 rclone -P sync docs/public test-rclone-org: 175 176 validate_website: website 177 find docs/public -type f -name "*.html" | xargs tidy --mute-id yes -errors --gnu-emacs yes --drop-empty-elements no --warn-proprietary-attributes no --mute MISMATCHED_ATTRIBUTE_WARN 178 179 tarball: 180 git archive -9 --format=tar.gz --prefix=rclone-$(TAG)/ -o build/rclone-$(TAG).tar.gz $(TAG) 181 182 vendorball: 183 go mod vendor 184 tar -zcf build/rclone-$(TAG)-vendor.tar.gz vendor 185 rm -rf vendor 186 187 sign_upload: 188 cd build && md5sum rclone-v* | gpg --clearsign > MD5SUMS 189 cd build && sha1sum rclone-v* | gpg --clearsign > SHA1SUMS 190 cd build && sha256sum rclone-v* | gpg --clearsign > SHA256SUMS 191 192 check_sign: 193 cd build && gpg --verify MD5SUMS && gpg --decrypt MD5SUMS | md5sum -c 194 cd build && gpg --verify SHA1SUMS && gpg --decrypt SHA1SUMS | sha1sum -c 195 cd build && gpg --verify SHA256SUMS && gpg --decrypt SHA256SUMS | sha256sum -c 196 197 upload: 198 rclone -P copy build/ downloads.rclone.org:/$(TAG) 199 rclone lsf build --files-only --include '*.{zip,deb,rpm}' --include version.txt | xargs -i bash -c 'i={}; j="$$i"; [[ $$i =~ (.*)(-v[0-9\.]+-)(.*) ]] && j=$${BASH_REMATCH[1]}-current-$${BASH_REMATCH[3]}; rclone copyto -v "downloads.rclone.org:/$(TAG)/$$i" "downloads.rclone.org:/$$j"' 200 201 upload_github: 202 ./bin/upload-github $(TAG) 203 204 cross: doc 205 go run bin/cross-compile.go -release current $(BUILD_FLAGS) $(BUILDTAGS) $(BUILD_ARGS) $(TAG) 206 207 beta: 208 go run bin/cross-compile.go $(BUILD_FLAGS) $(BUILDTAGS) $(BUILD_ARGS) $(TAG) 209 rclone -v copy build/ pub.rclone.org:/$(TAG) 210 @echo Beta release ready at https://pub.rclone.org/$(TAG)/ 211 212 log_since_last_release: 213 git log $(LAST_TAG).. 214 215 compile_all: 216 go run bin/cross-compile.go -compile-only $(BUILD_FLAGS) $(BUILDTAGS) $(BUILD_ARGS) $(TAG) 217 218 ci_upload: 219 sudo chown -R $$USER build 220 find build -type l -delete 221 gzip -r9v build 222 ./rclone --no-check-dest --config bin/ci.rclone.conf -v copy build/ $(BETA_UPLOAD)/testbuilds 223 ifeq ($(or $(BRANCH_PATH),$(RELEASE_TAG)),) 224 ./rclone --no-check-dest --config bin/ci.rclone.conf -v copy build/ $(BETA_UPLOAD_ROOT)/test/testbuilds-latest 225 endif 226 @echo Beta release ready at $(BETA_URL)/testbuilds 227 228 ci_beta: 229 git log $(LAST_TAG).. > /tmp/git-log.txt 230 go run bin/cross-compile.go -release beta-latest -git-log /tmp/git-log.txt $(BUILD_FLAGS) $(BUILDTAGS) $(BUILD_ARGS) $(TAG) 231 rclone --no-check-dest --config bin/ci.rclone.conf -v copy --exclude '*beta-latest*' build/ $(BETA_UPLOAD) 232 ifeq ($(or $(BRANCH_PATH),$(RELEASE_TAG)),) 233 rclone --no-check-dest --config bin/ci.rclone.conf -v copy --include '*beta-latest*' --include version.txt build/ $(BETA_UPLOAD_ROOT)$(BETA_SUBDIR) 234 endif 235 @echo Beta release ready at $(BETA_URL) 236 237 # Fetch the binary builds from GitHub actions 238 fetch_binaries: 239 rclone -P sync --exclude "/testbuilds/**" --delete-excluded $(BETA_UPLOAD) build/ 240 241 serve: website 242 cd docs && hugo server -v -w --disableFastRender 243 244 tag: retag doc 245 bin/make_changelog.py $(LAST_TAG) $(VERSION) > docs/content/changelog.md.new 246 mv docs/content/changelog.md.new docs/content/changelog.md 247 @echo "Edit the new changelog in docs/content/changelog.md" 248 @echo "Then commit all the changes" 249 @echo git commit -m \"Version $(VERSION)\" -a -v 250 @echo "And finally run make retag before make cross, etc." 251 252 retag: 253 @echo "Version is $(VERSION)" 254 git tag -f -s -m "Version $(VERSION)" $(VERSION) 255 256 startdev: 257 @echo "Version is $(VERSION)" 258 @echo "Next version is $(NEXT_VERSION)" 259 echo -e "package fs\n\n// VersionTag of rclone\nvar VersionTag = \"$(NEXT_VERSION)\"\n" | gofmt > fs/versiontag.go 260 echo -n "$(NEXT_VERSION)" > docs/layouts/partials/version.html 261 echo "$(NEXT_VERSION)" > VERSION 262 git commit -m "Start $(NEXT_VERSION)-DEV development" fs/versiontag.go VERSION docs/layouts/partials/version.html 263 264 startstable: 265 @echo "Version is $(VERSION)" 266 @echo "Next stable version is $(NEXT_PATCH_VERSION)" 267 echo -e "package fs\n\n// VersionTag of rclone\nvar VersionTag = \"$(NEXT_PATCH_VERSION)\"\n" | gofmt > fs/versiontag.go 268 echo -n "$(NEXT_PATCH_VERSION)" > docs/layouts/partials/version.html 269 echo "$(NEXT_PATCH_VERSION)" > VERSION 270 git commit -m "Start $(NEXT_PATCH_VERSION)-DEV development" fs/versiontag.go VERSION docs/layouts/partials/version.html 271 272 winzip: 273 zip -9 rclone-$(TAG).zip rclone.exe 274 275 # docker volume plugin 276 PLUGIN_USER ?= rclone 277 PLUGIN_TAG ?= latest 278 PLUGIN_BASE_TAG ?= latest 279 PLUGIN_ARCH ?= amd64 280 PLUGIN_IMAGE := $(PLUGIN_USER)/docker-volume-rclone:$(PLUGIN_TAG) 281 PLUGIN_BASE := $(PLUGIN_USER)/rclone:$(PLUGIN_BASE_TAG) 282 PLUGIN_BUILD_DIR := ./build/docker-plugin 283 PLUGIN_CONTRIB_DIR := ./contrib/docker-plugin/managed 284 285 docker-plugin-create: 286 docker buildx inspect |grep -q /${PLUGIN_ARCH} || \ 287 docker run --rm --privileged tonistiigi/binfmt --install all 288 rm -rf ${PLUGIN_BUILD_DIR} 289 docker buildx build \ 290 --no-cache --pull \ 291 --build-arg BASE_IMAGE=${PLUGIN_BASE} \ 292 --platform linux/${PLUGIN_ARCH} \ 293 --output ${PLUGIN_BUILD_DIR}/rootfs \ 294 ${PLUGIN_CONTRIB_DIR} 295 cp ${PLUGIN_CONTRIB_DIR}/config.json ${PLUGIN_BUILD_DIR} 296 docker plugin rm --force ${PLUGIN_IMAGE} 2>/dev/null || true 297 docker plugin create ${PLUGIN_IMAGE} ${PLUGIN_BUILD_DIR} 298 299 docker-plugin-push: 300 docker plugin push ${PLUGIN_IMAGE} 301 docker plugin rm ${PLUGIN_IMAGE} 302 303 docker-plugin: docker-plugin-create docker-plugin-push