Debian Codegraph @

Makefile

raw symbols SCIP
1 # GIT_LFS_SHA is the '--short'-form SHA1 of the current revision of Git LFS.
2 GIT_LFS_SHA ?= $(shell env -u GIT_TRACE 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 env -u GIT_TRACE git describe HEAD)
9
10 # PREFIX is VERSION without the leading v, for use in archive prefixes.
11 PREFIX ?= $(patsubst v%,git-lfs-%,$(VERSION))
12
13 # GO is the name of the 'go' binary used to compile Git LFS.
14 GO ?= go
15
16 # GOTOOLCHAIN is an environment variable which, when set to 'local',
17 # prevents Go from downloading and running non-local versions of itself.
18 export GOTOOLCHAIN = local
19
20 # GO_TEST_EXTRA_ARGS are extra arguments given to invocations of 'go test'.
21 #
22 # Examples include:
23 #
24 # make test GO_TEST_EXTRA_ARGS=-v
25 # make test GO_TEST_EXTRA_ARGS='-run TestMyExample'
26 GO_TEST_EXTRA_ARGS =
27
28 # BUILTIN_LD_FLAGS are the internal flags used to pass to the linker. By default
29 # the config.GitCommit variable is always set via this variable, and
30 # DWARF-stripping is enabled unless DWARF=YesPlease.
31 BUILTIN_LD_FLAGS =
32 ifneq ("$(VENDOR)","")
33 BUILTIN_LD_FLAGS += -X 'github.com/git-lfs/git-lfs/v3/config.Vendor=$(VENDOR)'
34 endif
35 BUILTIN_LD_FLAGS += -X github.com/git-lfs/git-lfs/v3/config.GitCommit=$(GIT_LFS_SHA)
36 ifneq ("$(DWARF)","YesPlease")
37 BUILTIN_LD_FLAGS += -s
38 BUILTIN_LD_FLAGS += -w
39 endif
40 # EXTRA_LD_FLAGS are given by the caller, and are passed to the Go linker after
41 # BUILTIN_LD_FLAGS are processed. By default the system LDFLAGS are passed.
42 # Note that these must be passed as a single argument to -extldflags, and
43 # since our LD_FLAGS variable must in turn be passed as a single argument
44 # to the "go build" command's -ldflags option, we enclose any system LDFLAGS
45 # in escaped quotes.
46 ifdef LDFLAGS
47 EXTRA_LD_FLAGS ?= -extldflags \"$(LDFLAGS)\"
48 endif
49 # LD_FLAGS is the union of the above two BUILTIN_LD_FLAGS and EXTRA_LD_FLAGS.
50 LD_FLAGS = $(BUILTIN_LD_FLAGS) $(EXTRA_LD_FLAGS)
51
52 # BUILTIN_GC_FLAGS are the internal flags used to pass compiler.
53 BUILTIN_GC_FLAGS =
54 # EXTRA_GC_FLAGS are the caller-provided flags to pass to the compiler.
55 EXTRA_GC_FLAGS =
56 # GC_FLAGS are the union of the above two BUILTIN_GC_FLAGS and EXTRA_GC_FLAGS.
57 GC_FLAGS = $(BUILTIN_GC_FLAGS) $(EXTRA_GC_FLAGS)
58
59 # ASCIIDOCTOR is the name of the 'asciidoctor' program used to generate man pages.
60 ASCIIDOCTOR ?= asciidoctor
61 # ASCIIDOCTOR_EXTRA_ARGS are extra arguments given to the $(ASCIIDOCTOR) program when invoked.
62 ASCIIDOCTOR_EXTRA_ARGS ?= -a reproducible
63
64 # GREP is the name of the program used for regular expression matching, or
65 # 'grep' if unset.
66 GREP ?= grep
67 # XARGS is the name of the program used to turn stdin into program arguments, or
68 # 'xargs' if unset.
69 XARGS ?= xargs
70
71 # GOIMPORTS is the name of the program formatter used before compiling.
72 GOIMPORTS ?= goimports
73 # GOIMPORTS_EXTRA_OPTS are the default options given to the $(GOIMPORTS)
74 # program.
75 GOIMPORTS_EXTRA_OPTS ?= -w -l
76
77 # TAR is the tar command, either GNU or BSD (libarchive) tar.
78 TAR ?= tar
79
80 TAR_XFORM_ARG ?= $(shell $(TAR) --version | grep -q 'GNU tar' && echo '--xform' || echo '-s')
81 TAR_XFORM_CMD ?= $(shell $(TAR) --version | grep -q 'GNU tar' && echo 's')
82
83 # GZIP is the "gzip" command.
84 GZIP ?= gzip
85
86 # CERT_SHA1 is the SHA-1 hash of the Windows code-signing cert to use. The
87 # actual signature is made with SHA-256.
88 CERT_SHA1 ?= 30a531ed3a246d3d07a4273adaef31552bf6473a
89
90 # CERT_FILE is the PKCS#12 file holding the certificate.
91 CERT_FILE ?=
92
93 # CERT_PASS is the password for the certificate. It must not contain
94 # double-quotes.
95 CERT_PASS ?=
96
97 # CERT_ARGS are additional arguments to pass when signing Windows binaries.
98 ifneq ("$(CERT_FILE)$(CERT_PASS)","")
99 CERT_ARGS ?= -f "$(CERT_FILE)" -p "$(CERT_PASS)"
100 else
101 CERT_ARGS ?= -sha1 $(CERT_SHA1)
102 endif
103
104 # DARWIN_KEYCHAIN_ID is the name of the keychain (with suffix) where the
105 # certificate is located.
106 DARWIN_KEYCHAIN_ID ?= lfs.keychain
107
108 export DARWIN_DEV_USER DARWIN_DEV_PASS DARWIN_DEV_TEAM
109
110 # SOURCES is a listing of all .go files in this and child directories, excluding
111 # that in vendor.
112 SOURCES = $(shell find . -type f -name '*.go' | grep -v vendor)
113
114 # MSGFMT is the GNU gettext msgfmt binary.
115 MSGFMT ?= msgfmt
116
117 # PO is a list of all the po (gettext source) files.
118 PO = $(wildcard po/*.po)
119
120 # MO is a list of all the mo (gettext compiled) files to be built.
121 MO = $(patsubst po/%.po,po/build/%.mo,$(PO))
122
123 # XGOTEXT is the string extractor for gotext.
124 XGOTEXT ?= xgotext
125
126 # CODESIGN is the macOS signing tool.
127 CODESIGN ?= codesign
128
129 # SIGNTOOL is the Windows signing tool.
130 SIGNTOOL ?= signtool.exe
131
132 # FORCE_LOCALIZE forces localization to be run if set to non-empty.
133 FORCE_LOCALIZE ?=
134
135 # PKGS is a listing of packages that are considered to be a part of Git LFS, and
136 # are used in package-specific commands, such as the 'make test' targets. For
137 # example:
138 #
139 # make test # run 'go test' in all packages
140 # make PKGS='config git/githistory' test # run 'go test' in config and
141 # # git/githistory
142 #
143 # By default, it is a listing of all packages in Git LFS. When new packages (or
144 # sub-packages) are created, they should be added here.
145 ifndef PKGS
146 PKGS =
147 PKGS += commands
148 PKGS += config
149 PKGS += creds
150 PKGS += errors
151 PKGS += filepathfilter
152 PKGS += fs
153 PKGS += git
154 PKGS += git/gitattr
155 PKGS += git/githistory
156 PKGS += git
157 PKGS += internal/testutil
158 PKGS += lfs
159 PKGS += lfsapi
160 PKGS += lfshttp
161 PKGS += locking
162 PKGS += ssh
163 PKGS += subprocess
164 PKGS += tasklog
165 PKGS += tools
166 PKGS += tools/humanize
167 PKGS += tools/kv
168 PKGS += tr
169 PKGS += tq
170 endif
171
172 # X is the platform-specific extension for Git LFS binaries. It is automatically
173 # set to .exe on Windows, and the empty string on all other platforms. It may be
174 # overridden.
175 #
176 # BUILD_MAIN is the main ".go" file that contains func main() for Git LFS. On
177 # macOS and other non-Windows platforms, it is required that a specific
178 # entrypoint be given, hence the below conditional. On Windows, it is required
179 # that an entrypoint not be given so that goversioninfo can successfully embed
180 # the resource.syso file (for more, see below).
181 #
182 # BSDTAR is BSD (libarchive) tar.
183 ifeq ($(OS),Windows_NT)
184 X ?= .exe
185 BUILD_MAIN ?=
186 BSDTAR ?= C:/Windows/system32/tar.exe
187 else
188 X ?=
189 BUILD_MAIN ?= ./git-lfs.go
190 BSDTAR ?= $(shell $(TAR) --version | grep -q 'GNU tar' && echo bsdtar || echo $(TAR))
191 endif
192
193 # BUILD is a macro used to build a single binary of Git LFS using the above
194 # LD_FLAGS and GC_FLAGS.
195 #
196 # It takes three arguments:
197 #
198 # $(1) - a valid GOOS value, or empty-string
199 # $(2) - a valid GOARCH value, or empty-string
200 # $(3) - an optional program extension. If $(3) is given as '-foo', then the
201 # program will be written to bin/git-lfs-foo.
202 #
203 # It uses BUILD_MAIN as defined above to specify the entrypoint for building Git
204 # LFS.
205 BUILD = GOOS=$(1) GOARCH=$(2) \
206 $(GO) build \
207 -ldflags="$(LD_FLAGS)" \
208 -gcflags="$(GC_FLAGS)" \
209 -trimpath \
210 -o ./bin/git-lfs$(3) $(BUILD_MAIN)
211
212 # BUILD_TARGETS is the set of all platforms and architectures that Git LFS is
213 # built for.
214 BUILD_TARGETS = \
215 bin/git-lfs-darwin-amd64 \
216 bin/git-lfs-darwin-arm64 \
217 bin/git-lfs-linux-arm \
218 bin/git-lfs-linux-arm64 \
219 bin/git-lfs-linux-amd64 \
220 bin/git-lfs-linux-ppc64le \
221 bin/git-lfs-linux-riscv64 \
222 bin/git-lfs-linux-s390x \
223 bin/git-lfs-linux-loong64 \
224 bin/git-lfs-linux-386 \
225 bin/git-lfs-freebsd-amd64 \
226 bin/git-lfs-freebsd-386 \
227 bin/git-lfs-windows-amd64.exe \
228 bin/git-lfs-windows-386.exe \
229 bin/git-lfs-windows-arm64.exe
230
231 # mangen is a shorthand for ensuring that commands/mancontent_gen.go is kept
232 # up-to-date with the contents of docs/man/*.ronn.
233 .PHONY : mangen
234 mangen : commands/mancontent_gen.go
235
236 # commands/mancontent_gen.go is generated by running 'go generate' on package
237 # 'commands' of Git LFS. It depends upon the contents of the 'docs' directory
238 # and converts those manpages into code.
239 commands/mancontent_gen.go : $(wildcard docs/man/*.adoc)
240 GOOS= GOARCH= $(GO) generate github.com/git-lfs/git-lfs/v3/commands
241
242 # trgen is a shorthand for ensuring that tr/tr_gen.go is kept up-to-date with
243 # the contents of po/build/*.mo.
244 .PHONY : trgen
245 trgen : tr/tr_gen.go
246
247 # tr/tr_gen.go is generated by running 'go generate' on package
248 # 'tr' of Git LFS. It depends upon the contents of the 'po' directory
249 # and converts the .mo files.
250 tr/tr_gen.go : $(MO)
251 GOOS= GOARCH= $(GO) generate github.com/git-lfs/git-lfs/v3/tr
252
253 po/build:
254 mkdir -p po/build
255
256 # These targets build the MO files.
257 po/build/%.mo: po/%.po po/build
258 ifeq ($(FORCE_LOCALIZE),)
259 if command -v $(MSGFMT) >/dev/null 2>&1; \
260 then \
261 $(MSGFMT) -o $@ $<; \
262 fi
263 else
264 $(MSGFMT) -o $@ $<
265 endif
266
267 po/i-reverse.po: po/default.pot
268 script/gen-i-reverse $< $@
269
270 po/default.pot:
271 if command -v $(XGOTEXT) >/dev/null 2>&1; \
272 then \
273 $(XGOTEXT) -in . -exclude .git,.github,vendor -out po -v; \
274 fi
275
276 # Targets 'all' and 'build' build binaries of Git LFS for the above release
277 # matrix.
278 .PHONY : all build
279 all build : $(BUILD_TARGETS)
280
281 # The following bin/git-lfs-% targets make a single binary compilation of Git
282 # LFS for a specific operating system and architecture pair.
283 #
284 # They function by translating target names into arguments for the above BUILD
285 # builtin, and appending the appropriate suffix to the build target.
286 #
287 # On Windows, they also depend on the resource.syso target, which installs and
288 # embeds the versioninfo into the binary.
289 bin/git-lfs-darwin-amd64 : $(SOURCES) mangen trgen
290 $(call BUILD,darwin,amd64,-darwin-amd64)
291 bin/git-lfs-darwin-arm64 : $(SOURCES) mangen trgen
292 $(call BUILD,darwin,arm64,-darwin-arm64)
293 bin/git-lfs-linux-arm : $(SOURCES) mangen trgen
294 GOARM=5 $(call BUILD,linux,arm,-linux-arm)
295 bin/git-lfs-linux-arm64 : $(SOURCES) mangen trgen
296 $(call BUILD,linux,arm64,-linux-arm64)
297 bin/git-lfs-linux-amd64 : $(SOURCES) mangen trgen
298 $(call BUILD,linux,amd64,-linux-amd64)
299 bin/git-lfs-linux-ppc64le : $(SOURCES) mangen trgen
300 $(call BUILD,linux,ppc64le,-linux-ppc64le)
301 bin/git-lfs-linux-riscv64 : $(SOURCES) mangen trgen
302 $(call BUILD,linux,riscv64,-linux-riscv64)
303 bin/git-lfs-linux-loong64 : $(SOURCES) mangen trgen
304 $(call BUILD,linux,loong64,-linux-loong64)
305 bin/git-lfs-linux-s390x : $(SOURCES) mangen trgen
306 $(call BUILD,linux,s390x,-linux-s390x)
307 bin/git-lfs-linux-386 : $(SOURCES) mangen trgen
308 $(call BUILD,linux,386,-linux-386)
309 bin/git-lfs-freebsd-amd64 : $(SOURCES) mangen trgen
310 $(call BUILD,freebsd,amd64,-freebsd-amd64)
311 bin/git-lfs-freebsd-386 : $(SOURCES) mangen trgen
312 $(call BUILD,freebsd,386,-freebsd-386)
313 bin/git-lfs-windows-amd64.exe : resource.syso $(SOURCES) mangen trgen
314 $(call BUILD,windows,amd64,-windows-amd64.exe)
315 bin/git-lfs-windows-386.exe : resource.syso $(SOURCES) mangen trgen
316 $(call BUILD,windows,386,-windows-386.exe)
317 bin/git-lfs-windows-arm64.exe : resource.syso $(SOURCES) mangen trgen
318 $(call BUILD,windows,arm64,-windows-arm64.exe)
319
320 # .DEFAULT_GOAL sets the operating system-appropriate Git LFS binary as the
321 # default output of 'make'.
322 .DEFAULT_GOAL := bin/git-lfs$(X)
323
324 # bin/git-lfs targets the default output of Git LFS on non-Windows operating
325 # systems, and respects the build knobs as above.
326 bin/git-lfs : $(SOURCES) fmt mangen trgen
327 $(call BUILD,$(GOOS),$(GOARCH),)
328
329 # bin/git-lfs.exe targets the default output of Git LFS on Windows systems, and
330 # respects the build knobs as above.
331 bin/git-lfs.exe : $(SOURCES) resource.syso mangen trgen
332 $(call BUILD,$(GOOS),$(GOARCH),.exe)
333
334 # resource.syso installs the 'goversioninfo' command and uses it in order to
335 # generate a binary that has information included necessary to create the
336 # Windows installer.
337 #
338 # Generating a new resource.syso is a pure function of the contents in the
339 # prerequisites listed below.
340 resource.syso : \
341 versioninfo.json script/windows-installer/git-lfs-logo.bmp \
342 script/windows-installer/git-lfs-logo.ico \
343 script/windows-installer/git-lfs-wizard-image.bmp
344 $(GO) generate
345
346 # RELEASE_TARGETS is the set of all release artifacts that we generate over a
347 # particular release. They each have a corresponding entry in BUILD_TARGETS as
348 # above.
349 #
350 # Unlike BUILD_TARGETS above, each of the below create a compressed directory
351 # containing the matching binary, as well as the contents of RELEASE_INCLUDES
352 # below.
353 #
354 # To build a specific release, execute the following:
355 #
356 # make bin/releases/git-lfs-darwin-amd64-$(git describe HEAD).tar.gz
357 #
358 # To build a specific release with a custom VERSION suffix, run the following:
359 #
360 # make VERSION=my-version bin/releases/git-lfs-darwin-amd64-my-version.tar.gz
361 RELEASE_TARGETS = \
362 bin/releases/git-lfs-darwin-amd64-$(VERSION).zip \
363 bin/releases/git-lfs-darwin-arm64-$(VERSION).zip \
364 bin/releases/git-lfs-linux-arm-$(VERSION).tar.gz \
365 bin/releases/git-lfs-linux-arm64-$(VERSION).tar.gz \
366 bin/releases/git-lfs-linux-amd64-$(VERSION).tar.gz \
367 bin/releases/git-lfs-linux-ppc64le-$(VERSION).tar.gz \
368 bin/releases/git-lfs-linux-riscv64-$(VERSION).tar.gz \
369 bin/releases/git-lfs-linux-s390x-$(VERSION).tar.gz \
370 bin/releases/git-lfs-linux-loong64-$(VERSION).tar.gz \
371 bin/releases/git-lfs-linux-386-$(VERSION).tar.gz \
372 bin/releases/git-lfs-freebsd-amd64-$(VERSION).tar.gz \
373 bin/releases/git-lfs-freebsd-386-$(VERSION).tar.gz \
374 bin/releases/git-lfs-windows-amd64-$(VERSION).zip \
375 bin/releases/git-lfs-windows-386-$(VERSION).zip \
376 bin/releases/git-lfs-windows-arm64-$(VERSION).zip \
377 bin/releases/git-lfs-vendor-$(VERSION).tar.gz \
378 bin/releases/git-lfs-$(VERSION).tar.gz
379
380 # RELEASE_INCLUDES are the names of additional files that are added to each
381 # release artifact.
382 RELEASE_INCLUDES = README.md CHANGELOG.md man
383
384 # release is a phony target that builds all of the release artifacts, and then
385 # shows the SHA 256 signature of each.
386 #
387 # To build all of the release binaries for a given Git LFS release:
388 #
389 # make release
390 .PHONY : release
391 release : $(RELEASE_TARGETS)
392 shasum -a 256 $(RELEASE_TARGETS)
393
394 # bin/releases/git-lfs-%-$(VERSION).tar.gz generates a gzip-compressed TAR of
395 # the non-Windows and non-macOS release artifacts.
396 #
397 # It includes all of RELEASE_INCLUDES, as well as script/install.sh.
398 bin/releases/git-lfs-%-$(VERSION).tar.gz : \
399 $(RELEASE_INCLUDES) bin/git-lfs-% script/install.sh
400 @mkdir -p bin/releases
401 $(TAR) $(TAR_XFORM_ARG) '$(TAR_XFORM_CMD)!bin/git-lfs-.*!$(PREFIX)/git-lfs!' \
402 $(TAR_XFORM_ARG) '$(TAR_XFORM_CMD)!script/!$(PREFIX)/!' \
403 $(TAR_XFORM_ARG) '$(TAR_XFORM_CMD)!\(.*\)\.md!$(PREFIX)/\1.md!' \
404 $(TAR_XFORM_ARG) '$(TAR_XFORM_CMD)!man!$(PREFIX)/man!' \
405 --posix -czf $@ $^
406
407 # bin/releases/git-lfs-darwin-$(VERSION).zip generates a ZIP compression of all
408 # of the macOS release artifacts.
409 #
410 # It includes all of the RELEASE_INCLUDES, as well as script/install.sh.
411 bin/releases/git-lfs-darwin-%-$(VERSION).zip : \
412 $(RELEASE_INCLUDES) bin/git-lfs-darwin-% script/install.sh
413 @mkdir -p bin/releases
414 $(BSDTAR) --format zip \
415 -s '!bin/git-lfs-.*!$(PREFIX)/git-lfs!' \
416 -s '!script/!$(PREFIX)/!' \
417 -s '!\(.*\)\.md!$(PREFIX)/\1.md!' \
418 -s '!man!$(PREFIX)/man!' \
419 -cf $@ $^
420
421 # bin/releases/git-lfs-windows-$(VERSION).zip generates a ZIP compression of all
422 # of the Windows release artifacts.
423 #
424 # It includes all of the RELEASE_INCLUDES, and converts LF-style line endings to
425 # CRLF in the non-binary components of the artifact.
426 bin/releases/git-lfs-windows-%-$(VERSION).zip : $(RELEASE_INCLUDES) bin/git-lfs-windows-%.exe
427 @mkdir -p bin/releases
428 # Windows's bsdtar doesn't support -s, so do the same thing as for Darwin, but
429 # by hand.
430 temp=$$(mktemp -d); \
431 file="$$PWD/$@" && \
432 mkdir -p "$$temp/$(PREFIX)/man" && \
433 cp -r $^ "$$temp/$(PREFIX)" && \
434 (cd "$$temp" && $(BSDTAR) --format zip -cf "$$file" $(PREFIX)) && \
435 $(RM) -r "$$temp"
436
437 # bin/releases/git-lfs-vender-$(VERSION).tar.gz generates a tarball of the
438 # source code with an included "vendor" directory.
439 #
440 # This is useful for third parties who wish to have a source archive from
441 # which they can build directly without fetching any Go dependencies.
442 bin/releases/git-lfs-vendor-$(VERSION).tar.gz : vendor
443 @mkdir -p bin/releases && \
444 git archive -o tmp.tar --prefix=$(PREFIX)/ $(VERSION) && \
445 chmod -R g+w vendor && \
446 $(TAR) $(TAR_XFORM_ARG) '$(TAR_XFORM_CMD)!vendor!$(PREFIX)/vendor!' \
447 -rf tmp.tar vendor && \
448 $(GZIP) <tmp.tar >$@ && \
449 $(RM) tmp.tar
450
451 # bin/releases/git-lfs-$(VERSION).tar.gz generates a tarball of the source code.
452 #
453 # This is useful for third parties who wish to have a bit-for-bit identical
454 # source archive to download and verify cryptographically.
455 bin/releases/git-lfs-$(VERSION).tar.gz :
456 git archive -o $@ --prefix=$(PREFIX)/ --format tar.gz $(VERSION)
457
458 # release-linux is a target that builds Linux packages. It must be run on a
459 # system with Docker that can run Linux containers.
460 .PHONY : release-linux
461 release-linux:
462 ./docker/run_dockers.bsh
463
464 # release-windows-stage-1 is a target that builds the Windows Git LFS binaries
465 # and prepares them for signing. It must be run on a Windows machine under Git
466 # Bash.
467 .PHONY : release-windows-stage-1
468 release-windows-stage-1: tmp/stage1
469
470 # After this stage completes, the binaries in this directory will be signed.
471 tmp/stage1:
472 $(RM) -r tmp/stage1
473 @mkdir -p tmp/stage1
474 @# Using these particular filenames is required for the Inno Setup script to
475 @# work properly.
476 $(MAKE) -B GOOS=windows X=.exe GOARCH=amd64 && cp ./bin/git-lfs.exe ./git-lfs-x64.exe
477 $(MAKE) -B GOOS=windows X=.exe GOARCH=386 && cp ./bin/git-lfs.exe ./git-lfs-x86.exe
478 $(MAKE) -B GOOS=windows X=.exe GOARCH=arm64 && cp ./bin/git-lfs.exe ./git-lfs-arm64.exe
479 mv git-lfs-x64.exe git-lfs-x86.exe git-lfs-arm64.exe tmp/stage1
480
481 # release-windows-stage-2 is a target that builds the InnoSetup installer and
482 # prepares it for signing. It must be run on a Windows machine under Git Bash.
483 .PHONY : release-windows-stage-2
484 release-windows-stage-2: tmp/stage2
485
486 # After this stage completes, the binaries in tmp/stage2 will be signed.
487 tmp/stage2: tmp/stage1
488 cp tmp/stage1/*.exe .
489 @# The git-lfs-windows-*.exe file will be named according to the version
490 @# number in the versioninfo.json, not according to $(VERSION).
491 iscc.exe script/windows-installer/inno-setup-git-lfs-installer.iss
492 mv git-lfs-windows-*.exe git-lfs-windows.exe
493 $(RM) -r tmp/stage2
494 @mkdir -p tmp/stage2
495 cp git-lfs-windows.exe tmp/stage2
496
497 # release-windows-stage-3 is a target that produces an archive from signed
498 # Windows binaries from the previous stages. It must be run on a Windows
499 # machine under Git Bash.
500 .PHONY : release-windows-stage-3
501 release-windows-stage-3: bin/releases/git-lfs-windows-assets-$(VERSION).tar.gz
502
503 bin/releases/git-lfs-windows-assets-$(VERSION).tar.gz : tmp/stage1 tmp/stage2
504 mv tmp/stage1/git-lfs-x64.exe git-lfs-windows-amd64.exe
505 mv tmp/stage1/git-lfs-x86.exe git-lfs-windows-386.exe
506 mv tmp/stage1/git-lfs-arm64.exe git-lfs-windows-arm64.exe
507 mv tmp/stage2/git-lfs-windows.exe git-lfs-windows.exe
508 @# We use tar because Git Bash doesn't include zip.
509 $(TAR) -czf $@ git-lfs-windows-amd64.exe git-lfs-windows-386.exe git-lfs-windows-arm64.exe git-lfs-windows.exe
510 $(RM) git-lfs-windows-amd64.exe git-lfs-windows-386.exe git-lfs-windows-arm64.exe git-lfs-windows.exe
511
512 # release-windows-rebuild takes the archive produced by release-windows and
513 # incorporates the signed binaries into the existing zip archives.
514 .PHONY : release-windows-rebuild
515 release-windows-rebuild: bin/releases/git-lfs-windows-assets-$(VERSION).tar.gz
516 temp=$$(mktemp -d); \
517 file="$$PWD/$^"; \
518 root="$$PWD" && \
519 ( \
520 tar -C "$$temp" -xzf "$$file" && \
521 for i in 386 amd64 arm64; do \
522 temp2="$$(mktemp -d)" && \
523 $(BSDTAR) -C "$$temp2" -xf "$$root/bin/releases/git-lfs-windows-$$i-$(VERSION).zip" && \
524 rm -f "$$temp2/$(PREFIX)/"git-lfs*.exe && \
525 cp "$$temp/git-lfs-windows-$$i.exe" "$$temp2/$(PREFIX)/git-lfs.exe" && \
526 (cd "$$temp2" && $(BSDTAR) --format=zip -cf "$$root/bin/releases/git-lfs-windows-$$i-$(VERSION).zip" $(PREFIX)) && \
527 rm -fr "$$temp2"; \
528 done && \
529 cp "$$temp/git-lfs-windows.exe" bin/releases/git-lfs-windows-$(VERSION).exe \
530 ); \
531 status="$$?"; [ -n "$$temp" ] && $(RM) -r "$$temp"; exit "$$status"
532
533 # release-darwin is a target that builds and signs Darwin (macOS) binaries. It must
534 # be run on a macOS machine with a suitable version of XCode.
535 .PHONY : release-darwin
536 release-darwin: bin/releases/git-lfs-darwin-amd64-$(VERSION).zip bin/releases/git-lfs-darwin-arm64-$(VERSION).zip
537 @cert_id=$$(security find-identity -vp codesigning $(DARWIN_KEYCHAIN_ID) | grep '^ *1)' | awk '{print $$2}') && \
538 for i in $^; do \
539 temp=$$(mktemp -d) && \
540 root=$$(pwd -P) && \
541 ( \
542 $(BSDTAR) -C "$$temp" -xf "$$i" && \
543 echo "Signing git-lfs binary for $$i ..." && \
544 $(CODESIGN) --keychain $(DARWIN_KEYCHAIN_ID) -s "$$cert_id" --force --timestamp -v --options runtime "$$temp/$(PREFIX)/git-lfs" && \
545 (cd "$$temp" && $(BSDTAR) --format zip -cf "$$root/$$i" "$(PREFIX)") && \
546 echo "Signing $$i ..." && \
547 $(CODESIGN) --keychain $(DARWIN_KEYCHAIN_ID) -s "$$cert_id" --force --timestamp -v --options runtime "$$i" && \
548 echo "Notarizing $$i ..." && \
549 jq -e ".notarize.path = \"$$i\" | .apple_id.username = \"$(DARWIN_DEV_USER)\"" script/macos/manifest.json > "$$temp/manifest.json"; \
550 for j in 1 2 3; \
551 do \
552 script/notarize "$$i" && break; \
553 done; \
554 ); \
555 status="$$?"; [ -n "$$temp" ] && $(RM) -r "$$temp"; [ "$$status" -eq 0 ] || exit "$$status"; \
556 done
557
558 .PHONY : release-write-certificate
559 release-write-certificate:
560 @echo "Writing certificate to $(CERT_FILE)"
561 @echo "$$CERT_CONTENTS" | base64 --decode >"$$CERT_FILE"
562 @printf 'Wrote %d bytes (SHA256 %s) to certificate file\n' $$(wc -c <"$$CERT_FILE") $$(shasum -ba 256 "$$CERT_FILE" | cut -d' ' -f1)
563
564 # release-import-certificate imports the given certificate into the macOS
565 # keychain "lfs". It is not generally recommended to run this on a user system,
566 # since it creates a new keychain and modifies the keychain search path.
567 .PHONY : release-import-certificate
568 release-import-certificate:
569 @[ -n "$(CI)" ] || { echo "Don't run this target by hand." >&2; false; }
570 @echo "Creating keychain"
571 security create-keychain -p default $(DARWIN_KEYCHAIN_ID)
572 security set-keychain-settings $(DARWIN_KEYCHAIN_ID)
573 security unlock-keychain -p default $(DARWIN_KEYCHAIN_ID)
574 @echo "Importing certificate from $(CERT_FILE)"
575 @security import "$$CERT_FILE" -f pkcs12 -k $(DARWIN_KEYCHAIN_ID) -P "$$CERT_PASS" -A
576 @echo "Verifying import and setting permissions"
577 security default-keychain -s $(DARWIN_KEYCHAIN_ID)
578 security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k default $(DARWIN_KEYCHAIN_ID) >/dev/null
579
580 # TEST_TARGETS is a list of all phony test targets. Each one of them corresponds
581 # to a specific kind or subset of tests to run.
582 TEST_TARGETS := test-bench test-verbose test-race
583 .PHONY : $(TEST_TARGETS) test
584 $(TEST_TARGETS) : test
585
586 # test-bench runs all Go benchmark tests, and nothing more.
587 test-bench : GO_TEST_EXTRA_ARGS=-run=__nothing__ -bench=.
588 # test-verbose runs all Go tests in verbose mode.
589 test-verbose : GO_TEST_EXTRA_ARGS=-v
590 # test-race runs all Go tests in race-detection mode.
591 test-race : GO_TEST_EXTRA_ARGS=-race
592
593 # test runs the Go tests with GO_TEST_EXTRA_ARGS in all specified packages,
594 # given by the PKGS variable.
595 #
596 # For example, a caller can invoke the race-detection tests in just the config
597 # package by running:
598 #
599 # make PKGS=config test-race
600 #
601 # Or in a series of packages, like:
602 #
603 # make PKGS="config lfsapi tools/kv" test-race
604 #
605 # And so on.
606 test : fmt $(.DEFAULT_GOAL)
607 ( \
608 unset GIT_DIR; unset GIT_WORK_TREE; unset XDG_CONFIG_HOME; unset XDG_RUNTIME_DIR; \
609 tempdir="$$(mktemp -d)"; \
610 export HOME="$$tempdir"; \
611 export GIT_CONFIG_NOSYSTEM=1; \
612 $(GO) test -count=1 $(GO_TEST_EXTRA_ARGS) $(addprefix ./,$(PKGS)); \
613 RET=$$?; \
614 chmod -R u+w "$$tempdir"; \
615 rm -fr "$$tempdir"; \
616 exit $$RET; \
617 )
618
619 # integration is a shorthand for running 'make' in the 't' directory.
620 .PHONY : integration
621 integration : bin/git-lfs$(X)
622 make -C t test
623
624 # go.sum is a lockfile based on the contents of go.mod.
625 go.sum : go.mod
626 $(GO) mod verify >/dev/null
627
628 # vendor updates the go.sum-file, and installs vendored dependencies into
629 # the vendor/ sub-tree, removing sub-packages (listed below) that are unused by
630 # Git LFS as well as test code.
631 .PHONY : vendor
632 vendor : go.mod
633 $(GO) mod vendor -v
634
635 # fmt runs goimports over all files in Git LFS (as defined by $(SOURCES) above),
636 # and replaces their contents with a formatted one in-place.
637 #
638 # If $(GOIMPORTS) does not exist, or isn't otherwise executable, this recipe
639 # still performs the linting sequence, but gracefully skips over running a
640 # non-existent command.
641 .PHONY : fmt
642 ifeq ($(shell test -x "`command -v $(GOIMPORTS)`"; echo $$?),0)
643 fmt : $(SOURCES) | lint
644 @$(GOIMPORTS) $(GOIMPORTS_EXTRA_OPTS) $?;
645 else
646 fmt : $(SOURCES) | lint
647 @echo "git-lfs: skipping fmt, no goimports found at \`$(GOIMPORTS)\` ..."
648 endif
649
650 # lint ensures that there are all dependencies outside of the standard library
651 # are vendored in via vendor (see: above).
652 .PHONY : lint
653 lint : $(SOURCES)
654 @! $(GO) list -f '{{ join .Deps "\n" }}' . \
655 | $(XARGS) $(GO) list -f \
656 '{{ if and (not .Standard) (not .Module) }} \
657 {{ .ImportPath }} \
658 {{ end }}' \
659 | $(GREP) -v "github.com/git-lfs/git-lfs" \
660 | $(GREP) "."
661
662 # MAN_ROFF_TARGETS is a list of all ROFF-style targets in the man pages.
663 MAN_ROFF_TARGETS = man/man1/git-lfs-checkout.1 \
664 man/man1/git-lfs-clean.1 \
665 man/man1/git-lfs-clone.1 \
666 man/man1/git-lfs-completion.1 \
667 man/man5/git-lfs-config.5 \
668 man/man1/git-lfs-dedup.1 \
669 man/man1/git-lfs-env.1 \
670 man/man1/git-lfs-ext.1 \
671 man/man7/git-lfs-faq.7 \
672 man/man1/git-lfs-fetch.1 \
673 man/man1/git-lfs-filter-process.1 \
674 man/man1/git-lfs-fsck.1 \
675 man/man1/git-lfs-install.1 \
676 man/man1/git-lfs-lock.1 \
677 man/man1/git-lfs-locks.1 \
678 man/man1/git-lfs-logs.1 \
679 man/man1/git-lfs-ls-files.1 \
680 man/man1/git-lfs-merge-driver.1 \
681 man/man1/git-lfs-migrate.1 \
682 man/man1/git-lfs-pointer.1 \
683 man/man1/git-lfs-post-checkout.1 \
684 man/man1/git-lfs-post-commit.1 \
685 man/man1/git-lfs-post-merge.1 \
686 man/man1/git-lfs-pre-push.1 \
687 man/man1/git-lfs-prune.1 \
688 man/man1/git-lfs-pull.1 \
689 man/man1/git-lfs-push.1 \
690 man/man1/git-lfs-smudge.1 \
691 man/man1/git-lfs-standalone-file.1 \
692 man/man1/git-lfs-status.1 \
693 man/man1/git-lfs-track.1 \
694 man/man1/git-lfs-uninstall.1 \
695 man/man1/git-lfs-unlock.1 \
696 man/man1/git-lfs-untrack.1 \
697 man/man1/git-lfs-update.1 \
698 man/man1/git-lfs.1
699
700 # MAN_HTML_TARGETS is a list of all HTML-style targets in the man pages.
701 MAN_HTML_TARGETS = man/html/git-lfs-checkout.1.html \
702 man/html/git-lfs-clean.1.html \
703 man/html/git-lfs-clone.1.html \
704 man/html/git-lfs-completion.1.html \
705 man/html/git-lfs-config.5.html \
706 man/html/git-lfs-dedup.1.html \
707 man/html/git-lfs-env.1.html \
708 man/html/git-lfs-ext.1.html \
709 man/html/git-lfs-faq.7.html \
710 man/html/git-lfs-fetch.1.html \
711 man/html/git-lfs-filter-process.1.html \
712 man/html/git-lfs-fsck.1.html \
713 man/html/git-lfs-install.1.html \
714 man/html/git-lfs-lock.1.html \
715 man/html/git-lfs-locks.1.html \
716 man/html/git-lfs-logs.1.html \
717 man/html/git-lfs-ls-files.1.html \
718 man/html/git-lfs-merge-driver.1.html \
719 man/html/git-lfs-migrate.1.html \
720 man/html/git-lfs-pointer.1.html \
721 man/html/git-lfs-post-checkout.1.html \
722 man/html/git-lfs-post-commit.1.html \
723 man/html/git-lfs-post-merge.1.html \
724 man/html/git-lfs-pre-push.1.html \
725 man/html/git-lfs-prune.1.html \
726 man/html/git-lfs-pull.1.html \
727 man/html/git-lfs-push.1.html \
728 man/html/git-lfs-smudge.1.html \
729 man/html/git-lfs-standalone-file.1.html \
730 man/html/git-lfs-status.1.html \
731 man/html/git-lfs-track.1.html \
732 man/html/git-lfs-uninstall.1.html \
733 man/html/git-lfs-unlock.1.html \
734 man/html/git-lfs-untrack.1.html \
735 man/html/git-lfs-update.1.html \
736 man/html/git-lfs.1.html
737
738 # man generates all ROFF- and HTML-style man page targets.
739 .PHONY : man
740 man : $(MAN_ROFF_TARGETS) $(MAN_HTML_TARGETS)
741
742 # Generate ROFF-style man pages from the corresponding .adoc files.
743 man/man1/%.1 : docs/man/%.adoc
744 @mkdir -p man/man1
745 $(ASCIIDOCTOR) $(ASCIIDOCTOR_EXTRA_ARGS) -b manpage -I docs/man/asciidoctor-extensions -r manpage-extension -o $@ $<
746 man/man5/%.5 : docs/man/%.adoc
747 @mkdir -p man/man5
748 $(ASCIIDOCTOR) $(ASCIIDOCTOR_EXTRA_ARGS) -b manpage -I docs/man/asciidoctor-extensions -r manpage-extension -o $@ $<
749 man/man7/%.7 : docs/man/%.adoc
750 @mkdir -p man/man7
751 $(ASCIIDOCTOR) $(ASCIIDOCTOR_EXTRA_ARGS) -b manpage -I docs/man/asciidoctor-extensions -r manpage-extension -o $@ $<
752
753 # Generate HTML-style man pages from the corresponding .adoc files.
754 man/html/%.1.html : docs/man/%.adoc
755 @mkdir -p man/html
756 $(ASCIIDOCTOR) $(ASCIIDOCTOR_EXTRA_ARGS) -b html5 -o $@ $<
757 man/html/%.5.html : docs/man/%.adoc
758 @mkdir -p man/html
759 $(ASCIIDOCTOR) $(ASCIIDOCTOR_EXTRA_ARGS) -b html5 -o $@ $<
760 man/html/%.7.html : docs/man/%.adoc
761 @mkdir -p man/html
762 $(ASCIIDOCTOR) $(ASCIIDOCTOR_EXTRA_ARGS) -b html5 -o $@ $<