github.com/x-oss-byte/git-lfs@v2.5.2+incompatible/Makefile (about) 1 # GIT_LFS_SHA is the '--short'-form SHA1 of the current revision of Git LFS. 2 GIT_LFS_SHA ?= $(shell git rev-parse --short HEAD) 3 # VERSION is the longer-form describe output of the current revision of Git LFS, 4 # used for identifying intermediate releases. 5 # 6 # If Git LFS is being built for a published release, VERSION and GIT_LFS_SHA 7 # should be identical. 8 VERSION ?= $(shell git describe HEAD) 9 10 # GO is the name of the 'go' binary used to compile Git LFS. 11 GO ?= go 12 13 # GO_TEST_EXTRA_ARGS are extra arguments given to invocations of 'go test'. 14 # 15 # Examples include: 16 # 17 # make test GO_TEST_EXTRA_ARGS=-v 18 # make test GO_TEST_EXTRA_ARGS='-run TestMyExample' 19 GO_TEST_EXTRA_ARGS = 20 21 # BUILTIN_LD_FLAGS are the internal flags used to pass to the linker. By default 22 # the config.GitCommit variable is always set via this variable, and 23 # DWARF-stripping is enabled unless DWARF=YesPlease. 24 BUILTIN_LD_FLAGS = 25 BUILTIN_LD_FLAGS += -X github.com/git-lfs/git-lfs/config.GitCommit=$(GIT_LFS_SHA) 26 ifneq ("$(DWARF)","YesPlease") 27 BUILTIN_LD_FLAGS += -s 28 BUILTIN_LD_FLAGS += -w 29 endif 30 # EXTRA_LD_FLAGS are given by the caller, and are passed to the Go linker after 31 # BUILTIN_LD_FLAGS are processed. 32 EXTRA_LD_FLAGS = 33 # LD_FLAGS is the union of the above two BUILTIN_LD_FLAGS and EXTRA_LD_FLAGS. 34 LD_FLAGS = $(BUILTIN_LD_FLAGS) $(EXTRA_LD_FLAGS) 35 36 # BUILTIN_GC_FLAGS are the internal flags used to pass compiler. 37 BUILTIN_GC_FLAGS = 38 # EXTRA_GC_FLAGS are the caller-provided flags to pass to the compiler. 39 EXTRA_GC_FLAGS = 40 # GC_FLAGS are the union of the above two BUILTIN_GC_FLAGS and EXTRA_GC_FLAGS. 41 GC_FLAGS = $(BUILTIN_GC_FLAGS) $(EXTRA_GC_FLAGS) 42 43 # GLIDE is the name of the 'glide' binary used to manage vendored dependencies. 44 GLIDE ?= glide 45 46 # RONN is the name of the 'ronn' program used to generate man pages. 47 RONN ?= ronn 48 # RONN_EXTRA_ARGS are extra arguments given to the $(RONN) program when invoked. 49 RONN_EXTRA_ARGS ?= 50 51 # GREP is the name of the program used for regular expression matching, or 52 # 'grep' if unset. 53 GREP ?= grep 54 # RM is the name of the program used removing files, or 'rm -f' if unset. 55 RM ?= rm -f 56 # XARGS is the name of the program used to turn stdin into program arguments, or 57 # 'xargs' if unset. 58 XARGS ?= xargs 59 60 # GOIMPORTS is the name of the program formatter used before compiling. 61 GOIMPORTS ?= goimports 62 # GOIMPORTS_EXTRA_OPTS are the default options given to the $(GOIMPORTS) 63 # program. 64 GOIMPORTS_EXTRA_OPTS ?= -w -l 65 66 # SOURCES is a listing of all .go files in this and child directories, excluding 67 # that in vendor. 68 SOURCES = $(shell find . -type f -name '*.go' | grep -v vendor) 69 # PKGS is a listing of packages that are considered to be a part of Git LFS, and 70 # are used in package-specific commands, such as the 'make test' targets. For 71 # example: 72 # 73 # make test # run 'go test' in all packages 74 # make PKGS='config git/githistory' test # run 'go test' in config and 75 # # git/githistory 76 # 77 # By default, it is a listing of all packages in Git LFS. When new packages (or 78 # sub-packages) are created, they should be added here. 79 ifndef PKGS 80 PKGS = 81 PKGS += commands 82 PKGS += config 83 PKGS += errors 84 PKGS += filepathfilter 85 PKGS += fs 86 PKGS += git 87 PKGS += git/gitattr 88 PKGS += git/githistory 89 PKGS += git 90 PKGS += lfs 91 PKGS += lfsapi 92 PKGS += locking 93 PKGS += subprocess 94 PKGS += tasklog 95 PKGS += tools 96 PKGS += tools/humanize 97 PKGS += tools/kv 98 PKGS += tq 99 endif 100 101 # X is the platform-specific extension for Git LFS binaries. It is automatically 102 # set to .exe on Windows, and the empty string on all other platforms. It may be 103 # overridden. 104 # 105 # BUILD_MAIN is the main ".go" file that contains func main() for Git LFS. On 106 # macOS and other non-Windows platforms, it is required that a specific 107 # entrypoint be given, hence the below conditional. On Windows, it is required 108 # that an entrypoint not be given so that goversioninfo can successfully embed 109 # the resource.syso file (for more, see below). 110 ifeq ($(OS),Windows_NT) 111 X ?= .exe 112 BUILD_MAIN ?= 113 else 114 X ?= 115 BUILD_MAIN ?= ./git-lfs.go 116 endif 117 118 # BUILD is a macro used to build a single binary of Git LFS using the above 119 # LD_FLAGS and GC_FLAGS. 120 # 121 # It takes three arguments: 122 # 123 # $(1) - a valid GOOS value, or empty-string 124 # $(2) - a valid GOARCH value, or empty-string 125 # $(3) - an optional program extension. If $(3) is given as '-foo', then the 126 # program will be written to bin/git-lfs-foo. 127 # 128 # It uses BUILD_MAIN as defined above to specify the entrypoint for building Git 129 # LFS. 130 BUILD = GOOS=$(1) GOARCH=$(2) \ 131 $(GO) build \ 132 -ldflags="$(LD_FLAGS)" \ 133 -gcflags="$(GC_FLAGS)" \ 134 -o ./bin/git-lfs$(3) $(BUILD_MAIN) 135 136 # BUILD_TARGETS is the set of all platforms and architectures that Git LFS is 137 # built for. 138 BUILD_TARGETS = bin/git-lfs-darwin-amd64 bin/git-lfs-darwin-386 \ 139 bin/git-lfs-linux-amd64 bin/git-lfs-linux-386 \ 140 bin/git-lfs-freebsd-amd64 bin/git-lfs-freebsd-386 \ 141 bin/git-lfs-windows-amd64.exe bin/git-lfs-windows-386.exe 142 143 # mangen is a shorthand for ensuring that commands/mancontent_gen.go is kept 144 # up-to-date with the contents of docs/man/*.ronn. 145 .PHONY : mangen 146 mangen : commands/mancontent_gen.go 147 148 # commands/mancontent_gen.go is generated by running 'go generate' on package 149 # 'commands' of Git LFS. It depends upon the contents of the 'docs' directory 150 # and converts those manpages into code. 151 commands/mancontent_gen.go : $(wildcard docs/man/*.ronn) 152 $(GO) generate github.com/git-lfs/git-lfs/commands 153 154 # Targets 'all' and 'build' build binaries of Git LFS for the above release 155 # matrix. 156 .PHONY : all build 157 all build : $(BUILD_TARGETS) 158 159 # The following bin/git-lfs-% targets make a single binary compilation of Git 160 # LFS for a specific operating system and architecture pair. 161 # 162 # They function by translating target names into arguments for the above BUILD 163 # builtin, and appending the appropriate suffix to the build target. 164 # 165 # On Windows, they also depend on the resource.syso target, which installs and 166 # embeds the versioninfo into the binary. 167 bin/git-lfs-darwin-amd64 : $(SOURCES) mangen 168 $(call BUILD,darwin,amd64,-darwin-amd64) 169 bin/git-lfs-darwin-386 : $(SOURCES) mangen 170 $(call BUILD,darwin,386,-darwin-386) 171 bin/git-lfs-linux-amd64 : $(SOURCES) mangen 172 $(call BUILD,linux,amd64,-linux-amd64) 173 bin/git-lfs-linux-386 : $(SOURCES) mangen 174 $(call BUILD,linux,386,-linux-386) 175 bin/git-lfs-freebsd-amd64 : $(SOURCES) mangen 176 $(call BUILD,freebsd,amd64,-freebsd-amd64) 177 bin/git-lfs-freebsd-386 : $(SOURCES) mangen 178 $(call BUILD,freebsd,386,-freebsd-386) 179 bin/git-lfs-windows-amd64.exe : resource.syso $(SOURCES) mangen 180 $(call BUILD,windows,amd64,-windows-amd64.exe) 181 bin/git-lfs-windows-386.exe : resource.syso $(SOURCES) mangen 182 $(call BUILD,windows,386,-windows-386.exe) 183 184 # .DEFAULT_GOAL sets the operating system-appropriate Git LFS binary as the 185 # default output of 'make'. 186 .DEFAULT_GOAL := bin/git-lfs$(X) 187 188 # bin/git-lfs targets the default output of Git LFS on non-Windows operating 189 # systems, and respects the build knobs as above. 190 bin/git-lfs : $(SOURCES) fmt mangen 191 $(call BUILD,$(GOOS),$(GOARCH),) 192 193 # bin/git-lfs.exe targets the default output of Git LFS on Windows systems, and 194 # respects the build knobs as above. 195 bin/git-lfs.exe : $(SOURCES) resource.syso mangen 196 $(call BUILD,$(GOOS),$(GOARCH),.exe) 197 198 # resource.syso installs the 'goversioninfo' command and uses it in order to 199 # generate a binary that has information included necessary to create the 200 # Windows installer. 201 # 202 # Generating a new resource.syso is a pure function of the contents in the 203 # prerequisites listed below. 204 resource.syso : \ 205 versioninfo.json script/windows-installer/git-lfs-logo.bmp \ 206 script/windows-installer/git-lfs-logo.ico \ 207 script/windows-installer/git-lfs-wizard-image.bmp 208 @$(GO) get github.com/josephspurrier/goversioninfo/cmd/goversioninfo 209 $(GO) generate 210 211 # RELEASE_TARGETS is the set of all release artifacts that we generate over a 212 # particular release. They each have a corresponding entry in BUILD_TARGETS as 213 # above. 214 # 215 # Unlike BUILD_TARGETS above, each of the below create a compressed directory 216 # containing the matching binary, as well as the contents of RELEASE_INCLUDES 217 # below. 218 # 219 # To build a specific release, execute the following: 220 # 221 # make bin/releases/git-lfs-darwin-amd64-$(git describe HEAD).tar.gz 222 # 223 # To build a specific release with a custom VERSION suffix, run the following: 224 # 225 # make VERSION=my-version bin/releases/git-lfs-darwin-amd64-my-version.tar.gz 226 RELEASE_TARGETS = bin/releases/git-lfs-darwin-amd64-$(VERSION).tar.gz \ 227 bin/releases/git-lfs-darwin-386-$(VERSION).tar.gz \ 228 bin/releases/git-lfs-linux-amd64-$(VERSION).tar.gz \ 229 bin/releases/git-lfs-linux-386-$(VERSION).tar.gz \ 230 bin/releases/git-lfs-freebsd-amd64-$(VERSION).tar.gz \ 231 bin/releases/git-lfs-freebsd-386-$(VERSION).tar.gz \ 232 bin/releases/git-lfs-windows-amd64-$(VERSION).zip \ 233 bin/releases/git-lfs-windows-386-$(VERSION).zip 234 235 # RELEASE_INCLUDES are the names of additional files that are added to each 236 # release artifact. 237 RELEASE_INCLUDES = README.md CHANGELOG.md 238 239 # release is a phony target that builds all of the release artifacts, and then 240 # shows the SHA 256 signature of each. 241 # 242 # To build all of the release binaries for a given Git LFS release: 243 # 244 # make release 245 .PHONY : release 246 release : $(RELEASE_TARGETS) 247 shasum -a 256 $(RELEASE_TARGETS) 248 249 # bin/releases/git-lfs-%-$(VERSION).tar.gz generates a gzip-compressed TAR of 250 # the non-Windows release artifacts. 251 # 252 # It includes all of RELEASE_INCLUDES, as well as script/install.sh. 253 bin/releases/git-lfs-%-$(VERSION).tar.gz : \ 254 $(RELEASE_INCLUDES) bin/git-lfs-% script/install.sh 255 @mkdir -p bin/releases 256 tar -s '!bin/git-lfs-.*!git-lfs!' -s '!script/!!' -czf $@ $^ 257 258 # bin/releases/git-lfs-%-$(VERSION).zip generates a ZIP compression of all of 259 # the Windows release artifacts. 260 # 261 # It includes all of the RELEASE_INCLUDES, and converts LF-style line endings to 262 # CRLF in the non-binary components of the artifact. 263 bin/releases/git-lfs-%-$(VERSION).zip : $(RELEASE_INCLUDES) bin/git-lfs-%.exe 264 @mkdir -p bin/releases 265 zip -j -l $@ $^ 266 267 # TEST_TARGETS is a list of all phony test targets. Each one of them corresponds 268 # to a specific kind or subset of tests to run. 269 TEST_TARGETS := test-bench test-verbose test-race 270 .PHONY : $(TEST_TARGETS) test 271 $(TEST_TARGETS) : test 272 273 # test-bench runs all Go benchmark tests, and nothing more. 274 test-bench : GO_TEST_EXTRA_ARGS=-run=__nothing__ -bench=. 275 # test-verbose runs all Go tests in verbose mode. 276 test-verbose : GO_TEST_EXTRA_ARGS=-v 277 # test-race runs all Go tests in race-detection mode. 278 test-race : GO_TEST_EXTRA_ARGS=-race 279 280 # test runs the Go tests with GO_TEST_EXTRA_ARGS in all specified packages, 281 # given by the PKGS variable. 282 # 283 # For example, a caller can invoke the race-detection tests in just the config 284 # package by running: 285 # 286 # make PKGS=config test-race 287 # 288 # Or in a series of packages, like: 289 # 290 # make PKGS="config lfsapi tools/kv" test-race 291 # 292 # And so on. 293 test : fmt 294 $(GO) test $(GO_TEST_EXTRA_ARGS) $(addprefix ./,$(PKGS)) 295 296 # integration is a shorthand for running 'make' in the 't' directory. 297 .PHONY : integration 298 integration : bin/git-lfs$(X) 299 make -C t test 300 301 # glide.lock is the permanent record of the glide.yaml file, and it is built by 302 # running 'glide update'. 303 glide.lock : glide.yaml 304 $(GLIDE) update 305 306 # vendor updates the glide.lock-file, and installs vendored dependencies into 307 # the vendor/ sub-tree, removing sub-packages (listed below) that are unused by 308 # Git LFS. 309 .PHONY : vendor 310 vendor : glide.lock 311 $(GLIDE) install 312 $(RM) -r vendor/github.com/ThomsonReutersEikon/go-ntlm/utils 313 $(RM) -r vendor/github.com/davecgh/go-spew 314 $(RM) -r vendor/github.com/pmezard/go-difflib 315 316 # fmt runs goimports over all files in Git LFS (as defined by $(SOURCES) above), 317 # and replaces their contents with a formatted one in-place. 318 # 319 # If $(GOIMPORTS) does not exist, or isn't otherwise executable, this recipe 320 # still performs the linting sequence, but gracefully skips over running a 321 # non-existent command. 322 .PHONY : fmt 323 ifeq ($(shell test -x "`which $(GOIMPORTS)`"; echo $$?),0) 324 fmt : $(SOURCES) | lint 325 @$(GOIMPORTS) $(GOIMPORTS_EXTRA_OPTS) $?; 326 else 327 fmt : $(SOURCES) | lint 328 @echo "git-lfs: skipping fmt, no goimports found at \`$(GOIMPORTS)\` ..." 329 endif 330 331 # lint ensures that there are all dependencies outside of the standard library 332 # are vendored in via vendor (see: above). 333 .PHONY : lint 334 lint : $(SOURCES) 335 @$(GO) list -f '{{ join .Deps "\n" }}' . \ 336 | $(XARGS) $(GO) list -f '{{ if not .Standard }}{{ .ImportPath }}{{ end }}' \ 337 | $(GREP) -v "github.com/git-lfs/git-lfs" || exit 0 338 339 # MAN_ROFF_TARGETS is a list of all ROFF-style targets in the man pages. 340 MAN_ROFF_TARGETS = man/git-lfs-checkout.1 \ 341 man/git-lfs-clean.1 \ 342 man/git-lfs-clone.1 \ 343 man/git-lfs-config.5 \ 344 man/git-lfs-env.1 \ 345 man/git-lfs-ext.1 \ 346 man/git-lfs-fetch.1 \ 347 man/git-lfs-filter-process.1 \ 348 man/git-lfs-fsck.1 \ 349 man/git-lfs-install.1 \ 350 man/git-lfs-lock.1 \ 351 man/git-lfs-locks.1 \ 352 man/git-lfs-logs.1 \ 353 man/git-lfs-ls-files.1 \ 354 man/git-lfs-migrate.1 \ 355 man/git-lfs-pointer.1 \ 356 man/git-lfs-post-checkout.1 \ 357 man/git-lfs-post-merge.1 \ 358 man/git-lfs-pre-push.1 \ 359 man/git-lfs-prune.1 \ 360 man/git-lfs-pull.1 \ 361 man/git-lfs-push.1 \ 362 man/git-lfs-smudge.1 \ 363 man/git-lfs-status.1 \ 364 man/git-lfs-track.1 \ 365 man/git-lfs-uninstall.1 \ 366 man/git-lfs-unlock.1 \ 367 man/git-lfs-untrack.1 \ 368 man/git-lfs-update.1 \ 369 man/git-lfs.1 370 371 # MAN_HTML_TARGETS is a list of all HTML-style targets in the man pages. 372 MAN_HTML_TARGETS = man/git-lfs-checkout.1.html \ 373 man/git-lfs-clean.1.html \ 374 man/git-lfs-clone.1.html \ 375 man/git-lfs-config.5.html \ 376 man/git-lfs-env.1.html \ 377 man/git-lfs-ext.1.html \ 378 man/git-lfs-fetch.1.html \ 379 man/git-lfs-filter-process.1.html \ 380 man/git-lfs-fsck.1.html \ 381 man/git-lfs-install.1.html \ 382 man/git-lfs-lock.1.html \ 383 man/git-lfs-locks.1.html \ 384 man/git-lfs-logs.1.html \ 385 man/git-lfs-ls-files.1.html \ 386 man/git-lfs-migrate.1.html \ 387 man/git-lfs-pointer.1.html \ 388 man/git-lfs-post-checkout.1.html \ 389 man/git-lfs-post-merge.1.html \ 390 man/git-lfs-pre-push.1.html \ 391 man/git-lfs-prune.1.html \ 392 man/git-lfs-pull.1.html \ 393 man/git-lfs-push.1.html \ 394 man/git-lfs-smudge.1.html \ 395 man/git-lfs-status.1.html \ 396 man/git-lfs-track.1.html \ 397 man/git-lfs-uninstall.1.html \ 398 man/git-lfs-unlock.1.html \ 399 man/git-lfs-untrack.1.html \ 400 man/git-lfs-update.1.html \ 401 man/git-lfs.1.html 402 403 # man generates all ROFF- and HTML-style manpage targets. 404 .PHONY : man 405 man : $(MAN_ROFF_TARGETS) $(MAN_HTML_TARGETS) 406 407 # man/% generates ROFF-style man pages from the corresponding .ronn file. 408 man/% : docs/man/%.ronn 409 @mkdir -p man 410 $(RONN) $(RONN_EXTRA_ARGS) -r --pipe < $^ > $@ 411 412 # man/%.html generates HTML-style man pages from the corresponding .ronn file. 413 man/%.html : docs/man/%.ronn 414 @mkdir -p man 415 $(RONN) $(RONN_EXTRA_ARGS) -5 --pipe < $^ > $@