跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

Makefile

882 行 · 37.2 KB历史下载
1# SPDX-FileCopyrightText: Copyright The Lima Authors
2# SPDX-License-Identifier: Apache-2.0
3# Files are installed under $(DESTDIR)/$(PREFIX)
4PREFIX ?= /usr/local
5DEST := $(shell echo "$(DESTDIR)/$(PREFIX)" | sed 's:///*:/:g; s://*$$::')
6
7GITHUB_ACTIONS ?= false
8
9GO ?= go
10CP ?= cp
11TAR ?= tar
12ZIP ?= zip
13PLANTUML ?= plantuml # may also be "java -jar plantuml.jar" if installed elsewhere
14
15GOARCH ?= $(shell $(GO) env GOARCH)
16GOHOSTARCH := $(shell $(GO) env GOHOSTARCH)
17GOHOSTOS := $(shell $(GO) env GOHOSTOS)
18GOOS ?= $(shell $(GO) env GOOS)
19ifeq ($(GOOS),windows)
20bat = .bat
21exe = .exe
22endif
23
24ifeq ($(GOOS),darwin)
25MACOS_SDK_VERSION = $(shell xcrun --show-sdk-version | cut -d . -f 1)
26# xcrun command seems to fail even when the SDK is available:
27# > xcrun: error: unable to lookup item 'SDKVersion' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
28ifeq ($(MACOS_SDK_VERSION),)
29MACOS_SDK_VERSION = $(shell readlink /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk | sed -E -e "s/^MacOSX//" -e "s/\.[0-9]+\.sdk//")
30endif
31endif
32
33DEFAULT_ADDITIONAL_DRIVERS :=
34ifeq ($(GOOS),darwin)
35ifeq ($(GOARCH),arm64)
36ifeq ($(shell test $(MACOS_SDK_VERSION) -ge 14; echo $$?),0)
37# krunkit needs macOS 14 or later: https://github.com/containers/libkrun/blob/main/README.md#macos-efi-variant
38DEFAULT_ADDITIONAL_DRIVERS += krunkit
39endif
40endif
41endif
42ADDITIONAL_DRIVERS ?= $(DEFAULT_ADDITIONAL_DRIVERS)
43
44GO_BUILDTAGS ?=
45ifeq ($(GOOS),darwin)
46ifeq ($(shell test $(MACOS_SDK_VERSION) -lt 13; echo $$?),0)
47# The "vz" mode needs macOS 13 SDK or later
48GO_BUILDTAGS += no_vz
49endif
50endif
51
52ifeq ($(GOHOSTOS),windows)
53WINVER_MAJOR=$(shell powershell.exe "[System.Environment]::OSVersion.Version.Major")
54ifeq ($(WINVER_MAJOR),10)
55WINVER_BUILD=$(shell powershell.exe "[System.Environment]::OSVersion.Version.Build")
56WINVER_BUILD_HIGH_ENOUGH=$(shell powershell.exe $(WINVER_BUILD) -ge 19041)
57ifeq ($(WINVER_BUILD_HIGH_ENOUGH),False)
58GO_BUILDTAGS += no_wsl
59endif
60endif
61endif
62
63PACKAGE := github.com/lima-vm/lima/v2
64
65VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.m' --always --tags 2>/dev/null)
66VERSION_TRIMMED := $(VERSION:v%=%)
67
68ifeq ($(VERSION),)
69$(error VERSION could not be determined. Build from a git repo or run: make VERSION=vX.Y.Z)
70endif
71
72# `DEBUG` flag to build binaries with debug information for use by `dlv exec`.
73# This implies KEEP_DWARF=1 and KEEP_SYMBOLS=1.
74DEBUG ?=
75GO_BUILD_GCFLAGS ?=
76KEEP_DWARF ?=
77KEEP_SYMBOLS ?=
78ifeq ($(DEBUG),1)
79 # Disable optimizations and inlining to make debugging easier.
80 GO_BUILD_GCFLAGS = -gcflags="all=-N -l"
81 # Keep the symbol table
82 KEEP_DWARF = 1
83 # Enable DWARF generation
84 KEEP_SYMBOLS = 1
85endif
86
87GO_BUILD_LDFLAGS_W := true
88ifeq ($(KEEP_DWARF),1)
89 GO_BUILD_LDFLAGS_W = false
90endif
91
92GO_BUILD_LDFLAGS_S := true
93ifeq ($(KEEP_SYMBOLS),1)
94 GO_BUILD_LDFLAGS_S = false
95endif
96# `-s`: Strip the symbol table according to the KEEP_SYMBOLS config
97# `-w`: Disable DWARF generation according to the KEEP_DWARF config
98# `-X`: Embed version information.
99GO_BUILD_LDFLAGS := -ldflags="-s=$(GO_BUILD_LDFLAGS_S) -w=$(GO_BUILD_LDFLAGS_W) -X $(PACKAGE)/pkg/version.Version=$(VERSION)"
100# `go -version -m` returns -tags with comma-separated list, because space-separated list is deprecated in go1.13.
101# converting to comma-separated list is useful for comparing with the output of `go version -m`.
102GO_BUILD_FLAG_TAGS := $(addprefix -tags=,$(shell echo "$(GO_BUILDTAGS)"|tr " " "\n"|paste -sd "," -))
103GO_BUILD := $(strip $(GO) build $(GO_BUILD_GCFLAGS) $(GO_BUILD_LDFLAGS) $(GO_BUILD_FLAG_TAGS))
104
105################################################################################
106# Features
107.NOTPARALLEL:
108.SECONDEXPANSION:
109
110################################################################################
111.PHONY: all
112all: binaries manpages
113
114################################################################################
115# Help
116.PHONY: help
117help:
118 @echo ' binaries - Build all binaries'
119 @echo ' manpages - Build manual pages'
120 @echo
121 @echo ' help-variables - Show Makefile variables'
122 @echo ' help-targets - Show additional Makefile targets'
123
124.PHONY: help-variables
125help-variables:
126 @echo '# Variables that can be overridden.'
127 @echo
128 @echo '- PREFIX (directory) : Installation prefix (default: /usr/local)'
129 @echo '- KEEP_DWARF (1 or 0) : Whether to keep DWARF information (default: 0)'
130 @echo '- KEEP_SYMBOLS (1 or 0) : Whether to keep symbols (default: 0)'
131 @echo '- DEBUG (1 or 0) : Whether to build with debug information (default: 0)'
132
133.PHONY: help-targets
134help-targets:
135 @echo '# Targets can be categorized by their location.'
136 @echo
137 @echo 'Targets for files in _output/bin/:'
138 @echo '- limactl : Build limactl, and lima'
139 @echo '- lima : Copy lima, and lima.bat'
140 @echo '- helpers : Copy nerdctl.lima, apptainer.lima, docker.lima, podman.lima, and kubectl.lima'
141 @echo
142 @echo 'Targets for files in _output/libexec/lima/:'
143 @echo '- limactl-plugins : Build limactl-* CLI plugins'
144 @echo '- lima-privileged-net : Build the privileged network helper (Linux only)'
145 @echo
146 @echo 'Targets for files in _output/share/lima/:'
147 @echo '- guestagents : Build guestagents'
148 @echo '- native-guestagent : Build guestagent for native arch'
149 @echo '- additional-guestagents : Build guestagents for archs other than native arch'
150 @echo '- <arch>-guestagent : Build guestagent for <arch>: $(sort $(LINUX_GUESTAGENT_ARCHS))'
151 @echo
152 @echo 'Targets for files in _output/share/lima/templates/:'
153 @echo '- templates : Copy templates'
154 @echo '- template_experimentals : Copy experimental templates to experimental/'
155 @echo '- default_template : Copy default.yaml template'
156 @echo '- update-templates : Update templates'
157 @echo
158 @echo 'Targets for files in _output/share/doc/lima:'
159 @echo '- documentation : Copy documentation to _output/share/doc/lima'
160 @echo '- create-links-in-doc-dir : Create some symlinks pointing ../../lima/templates'
161 @echo
162 @echo '# e.g. to install limactl, helpers, native guestagent, and templates:'
163 @echo '# make native install'
164
165.PHONY: help-artifact
166help-artifact:
167 @echo '# Targets for building artifacts to _artifacts/'
168 @echo
169 @echo 'Targets to building multiple archs artifacts for GOOS:'
170 @echo '- artifacts : Build artifacts for current OS and supported archs'
171 @echo '- artifacts-<GOOS> : Build artifacts for supported archs and <GOOS>: darwin, linux, or windows'
172 @echo
173 @echo 'Targets to building GOOS and ARCH (GOARCH, or uname -m) specific artifacts:'
174 @echo '- artifact : Build artifacts for current GOOS and GOARCH'
175 @echo '- artifact-<GOOS> : Build artifacts for current GOARCH and <GOOS>: darwin, linux, or windows'
176 @echo '- artifact-<ARCH> : Build artifacts for current GOOS with <ARCH>: amd64, arm64, x86_64, or aarch64'
177 @echo '- artifact-<GOOS>-<ARCH> : Build artifacts for <GOOS> and <ARCH>'
178 @echo
179 @echo '# GOOS and GOARCH can be specified with make parameters or environment variables.'
180 @echo '# e.g. to build artifact for linux and arm64:'
181 @echo '# make GOOS=linux GOARCH=arm64 artifact'
182 @echo
183 @echo 'Targets for miscellaneous artifacts:'
184 @echo '- artifacts-jsonschema : Build artifacts for schema-limayaml.json'
185 @echo '- artifacts-misc : Build artifacts for go.mod, go.sum, and vendor'
186
187################################################################################
188# convenience targets
189exe: _output/bin/limactl$(exe)
190
191.PHONY: minimal native
192minimal: clean limactl native-guestagent default_template
193native: clean limactl limactl-plugins lima-privileged-net helpers native-guestagent templates template_experimentals additional-drivers
194
195################################################################################
196# These configs were once customizable but should no longer be changed.
197CONFIG_GUESTAGENT_OS_LINUX=y
198CONFIG_GUESTAGENT_OS_DARWIN=
199ifeq ($(GOOS),darwin)
200ifeq ($(GOARCH),arm64)
201CONFIG_GUESTAGENT_OS_DARWIN=y
202endif
203endif
204CONFIG_GUESTAGENT_ARCH_X8664=y
205CONFIG_GUESTAGENT_ARCH_AARCH64=y
206CONFIG_GUESTAGENT_ARCH_ARMV7L=y
207CONFIG_GUESTAGENT_ARCH_PPC64LE=y
208CONFIG_GUESTAGENT_ARCH_RISCV64=y
209CONFIG_GUESTAGENT_ARCH_S390X=y
210CONFIG_GUESTAGENT_COMPRESS=y
211
212################################################################################
213.PHONY: binaries
214binaries: limactl helpers limactl-plugins lima-privileged-net guestagents \
215 templates template_experimentals \
216 documentation create-links-in-doc-dir
217
218################################################################################
219# _output/bin
220.PHONY: limactl lima helpers
221limactl: _output/bin/limactl$(exe) lima
222
223### Listing Dependencies
224
225# returns a list of files expanded from $(1) excluding directories and files ending with '_test.go'.
226find_files_excluding_dir_and_test = $(shell find $(1) ! -type d ! -name '*_test.go')
227FILES_IN_PKG = $(call find_files_excluding_dir_and_test, ./pkg)
228
229# returns a list of files which are dependencies for the command $(1).
230dependencies_for_cmd = go.mod $(call find_files_excluding_dir_and_test, ./cmd/$(1)) $(FILES_IN_PKG)
231
232### Force Building Targets
233
234# returns GOVERSION, CGO*, GO*, -ldflags, and -tags build variables from the output of `go version -m $(1)`.
235# When CGO_* variables are not set, they are not included in the output.
236# Because the CGO_* variables are not set means that those values are default values,
237# it can be assumed that those values are same if the GOVERSION is same.
238# $(1): target binary
239extract_build_vars = $(shell \
240 ($(GO) version -m $(1) 2>&- || echo $(1):) | \
241 awk 'FNR==1{print "GOVERSION="$$2}$$2~/^(CGO|GO|-gcflags|-ldflags|-tags).*=.+$$/{sub("^.*"$$2,$$2); print $$0}' \
242)
243
244# a list of keys from the GO build variables to be used for calling `go env`.
245# keys starting with '-' are excluded because `go env` does not support those keys.
246# $(1): extracted build variables from the binary
247keys_in_build_vars = $(filter-out -%,$(shell for i in $(1); do echo $${i%%=*}; done))
248
249# a list of GO build variables to build the target binary.
250# $(1): target binary. expecting ENVS_$(2) is set to use the environment variables for the target binary.
251# $(2): key of the GO build variable to be used for calling `go env`.
252go_build_vars = $(shell \
253 $(ENVS_$(1)) $(GO) env $(2) | \
254 awk '/ /{print "\""$$0"\""; next}{print}' | \
255 for k in $(2); do read -r v && echo "$$k=$${v}"; done \
256) $(GO_BUILD_GCFLAGS) $(GO_BUILD_LDFLAGS) $(GO_BUILD_FLAG_TAGS)
257
258# returns the difference between $(1) and $(2).
259diff = $(filter-out $(2),$(1))$(filter-out $(1),$(2))
260
261# returns diff between the GO build variables in the binary $(1) and the building variables.
262# $(1): target binary
263# $(2): extracted GO build variables from the binary
264compare_build_vars = $(call diff,$(call go_build_vars,$(1),$(call keys_in_build_vars,$(2))),$(2))
265
266# returns "force" if the GO build variables in the binary $(1) is different from the building variables.
267# $(1): target binary. expecting ENVS_$(1) is set to use the environment variables for the target binary.
268force_build = $(if $(call compare_build_vars,$(1),$(call extract_build_vars,$(1))),force,)
269
270# returns the file name without .gz extension. It also gunzips the file with .gz extension if exists.
271# $(1): target file
272gunzip_if_exists = $(shell f=$(1); f=$${f%.gz}; test -f "$${f}.gz" && (set -x; gunzip -f "$${f}.gz") ; echo "$${f}")
273
274# call force_build with passing output of gunzip_if_exists as an argument.
275# $(1): target file
276force_build_with_gunzip = $(call force_build,$(call gunzip_if_exists,$(1)))
277
278force: # placeholder for force build
279
280################################################################################
281# _output/bin/limactl$(exe)
282
283# dependencies for limactl
284LIMACTL_DEPS = $(call dependencies_for_cmd,limactl)
285ifeq ($(GOOS),darwin)
286LIMACTL_DEPS += vz.entitlements
287endif
288
289# environment variables for limactl. this variable is used for checking force build.
290#
291# The hostagent must be compiled with CGO_ENABLED=1 so that net.LookupIP() in the DNS server
292# calls the native resolver library and not the simplistic version in the Go library.
293ENVS__output/bin/limactl$(exe) = CGO_ENABLED=1 GOOS="$(GOOS)" GOARCH="$(GOARCH)" CC="$(CC)"
294
295LIMACTL_DRIVER_TAGS :=
296ifneq (,$(findstring vz,$(ADDITIONAL_DRIVERS)))
297LIMACTL_DRIVER_TAGS += external_vz
298endif
299ifneq (,$(findstring qemu,$(ADDITIONAL_DRIVERS)))
300LIMACTL_DRIVER_TAGS += external_qemu
301endif
302ifneq (,$(findstring wsl2,$(ADDITIONAL_DRIVERS)))
303LIMACTL_DRIVER_TAGS += external_wsl2
304endif
305
306GO_BUILDTAGS ?=
307GO_BUILDTAGS_LIMACTL := $(strip $(GO_BUILDTAGS) $(LIMACTL_DRIVER_TAGS))
308
309_output/bin/limactl$(exe): $(LIMACTL_DEPS) $$(call force_build,$$@)
310ifneq ($(GOOS),windows) #
311 @rm -rf _output/bin/limactl.exe
312else
313 @rm -rf _output/bin/limactl
314endif
315 $(ENVS_$@) $(GO_BUILD) -tags '$(GO_BUILDTAGS_LIMACTL)' -o $@ ./cmd/limactl
316ifeq ($(GOOS),darwin)
317 codesign -f -v --entitlements vz.entitlements -s - $@
318endif
319
320LIBEXEC_LIMA := _output/libexec/lima
321# Privileged helpers are kept in their own directory so that they are easy to
322# audit and to tell apart from the unprivileged helpers next to them.
323LIBEXEC_LIMA_PRIVILEGED := $(LIBEXEC_LIMA)/privileged
324
325limactl-plugins: $(LIBEXEC_LIMA)/limactl-mcp$(exe) $(LIBEXEC_LIMA)/limactl-url-fedora-rawhide
326
327$(LIBEXEC_LIMA)/limactl-mcp$(exe): $(call dependencies_for_cmd,limactl-mcp) $$(call force_build,$$@)
328 @mkdir -p $(LIBEXEC_LIMA)
329 $(ENVS_$@) $(GO_BUILD) -o $@ ./cmd/limactl-mcp
330
331# lima-privileged-net is the privileged helper that manages the bridges and tap
332# devices of the shared/host/bridged networks. It is only used on Linux hosts.
333.PHONY: lima-privileged-net
334ifeq ($(GOOS),linux)
335lima-privileged-net: $(LIBEXEC_LIMA_PRIVILEGED)/lima-privileged-net
336else
337lima-privileged-net:
338endif
339
340$(LIBEXEC_LIMA_PRIVILEGED)/lima-privileged-net: $(call dependencies_for_cmd,lima-privileged-net) $$(call force_build,$$@)
341 @mkdir -p $(LIBEXEC_LIMA_PRIVILEGED)
342 $(ENVS_$@) $(GO_BUILD) -o $@ ./cmd/lima-privileged-net
343
344$(LIBEXEC_LIMA)/limactl-url-fedora-rawhide: cmd/limactl-url-fedora-rawhide
345 cp -aL $< $@
346
347.PHONY: additional-drivers
348additional-drivers:
349 @mkdir -p $(LIBEXEC_LIMA)
350 @for drv in $(ADDITIONAL_DRIVERS); do \
351 echo "Building $$drv as external"; \
352 if [ "$(GOOS)" = "windows" ]; then \
353 $(GO_BUILD) -o $(LIBEXEC_LIMA)/lima-driver-$$drv.exe ./cmd/lima-driver-$$drv || exit 1; \
354 else \
355 $(GO_BUILD) -o $(LIBEXEC_LIMA)/lima-driver-$$drv ./cmd/lima-driver-$$drv || exit 1; \
356 fi; \
357 if [ "$$drv" = "vz" ] && [ "$(GOOS)" = "darwin" ]; then \
358 codesign -f -v --entitlements vz.entitlements -s - $(LIBEXEC_LIMA)/lima-driver-vz; \
359 fi; \
360 done
361
362LIMA_CMDS = $(sort lima lima$(bat)) # $(sort ...) deduplicates the list
363LIMA_DEPS = $(addprefix _output/bin/,$(LIMA_CMDS))
364lima: $(LIMA_DEPS)
365
366HELPER_CMDS = nerdctl.lima apptainer.lima docker.lima podman.lima kubectl.lima
367HELPERS_DEPS = $(addprefix _output/bin/,$(HELPER_CMDS))
368helpers: $(HELPERS_DEPS)
369
370_output/bin/%: ./cmd/% | _output/bin
371 cp -a $< $@
372
373MKDIR_TARGETS += _output/bin
374
375################################################################################
376# _output/share/lima/lima-guestagent
377LINUX_GUESTAGENT_PATH_COMMON = _output/share/lima/lima-guestagent.Linux-
378DARWIN_GUESTAGENT_PATH_COMMON = _output/share/lima/lima-guestagent.Darwin-
379
380# How to add architecture specific guestagent:
381# 1. Add the architecture to GUESTAGENT_ARCHS
382# 2. Add ENVS_$(*_GUESTAGENT_PATH_COMMON)<arch> to set GOOS, GOARCH, and other necessary environment variables
383LINUX_GUESTAGENT_ARCHS = aarch64 armv7l ppc64le riscv64 s390x x86_64
384DARWIN_GUESTAGENT_ARCHS = aarch64
385
386ifeq ($(CONFIG_GUESTAGENT_OS_LINUX),y)
387ALL_GUESTAGENTS_NOT_COMPRESSED += $(addprefix $(LINUX_GUESTAGENT_PATH_COMMON),$(LINUX_GUESTAGENT_ARCHS))
388endif
389ifeq ($(CONFIG_GUESTAGENT_OS_DARWIN),y)
390ALL_GUESTAGENTS_NOT_COMPRESSED += $(addprefix $(DARWIN_GUESTAGENT_PATH_COMMON),$(DARWIN_GUESTAGENT_ARCHS))
391endif
392ifeq ($(CONFIG_GUESTAGENT_COMPRESS),y)
393gz=.gz
394endif
395
396ALL_GUESTAGENTS = $(addsuffix $(gz),$(ALL_GUESTAGENTS_NOT_COMPRESSED))
397
398# guestagent path for the given platform. it may has .gz extension if CONFIG_GUESTAGENT_COMPRESS is enabled.
399# $(1): operating system (os)
400# $(2): list of architectures
401guestagent_path = $(foreach arch,$(2),$($(1)_GUESTAGENT_PATH_COMMON)$(arch)$(gz))
402
403ifeq ($(CONFIG_GUESTAGENT_OS_LINUX),y)
404NATIVE_GUESTAGENT_ARCH = $(shell echo $(GOARCH) | sed -e s/arm64/aarch64/ -e s/arm/armv7l/ -e s/amd64/x86_64/)
405NATIVE_GUESTAGENT = $(call guestagent_path,LINUX,$(NATIVE_GUESTAGENT_ARCH))
406ADDITIONAL_GUESTAGENT_ARCHS = $(filter-out $(NATIVE_GUESTAGENT_ARCH),$(LINUX_GUESTAGENT_ARCHS))
407ADDITIONAL_GUESTAGENTS = $(call guestagent_path,LINUX,$(ADDITIONAL_GUESTAGENT_ARCHS))
408endif
409ifeq ($(CONFIG_GUESTAGENT_OS_DARWIN),y)
410ifeq ($(GOARCH),arm64)
411NATIVE_GUESTAGENT_ARCH = aarch64
412NATIVE_GUESTAGENT += $(call guestagent_path,DARWIN,$(NATIVE_GUESTAGENT_ARCH))
413endif
414endif
415# No ADDITIONAL_GUESTAGENTS for Darwin, as only one architecture is supported.
416
417# config_guestagent_arch returns expanded value of CONFIG_GUESTAGENT_ARCH_<arch>
418# $(1): architecture
419# CONFIG_GUESTAGENT_ARCH_<arch> naming convention: uppercase, remove '_'
420config_guestagent_arch = $(filter y,$(CONFIG_GUESTAGENT_ARCH_$(shell echo $(1)|tr -d _|tr a-z A-Z)))
421
422# guestagent_path_enabled_by_config returns the path to the guestagent binary for the given architecture,
423# or an empty string if the CONFIG_GUESTAGENT_ARCH_<arch> is not set.
424guestagent_path_enabled_by_config = $(if $(call config_guestagent_arch,$(2)),$(call guestagent_path,$(1),$(2)))
425
426ifeq ($(CONFIG_GUESTAGENT_OS_LINUX),y)
427# apply CONFIG_GUESTAGENT_ARCH_*
428GUESTAGENTS += $(foreach arch,$(LINUX_GUESTAGENT_ARCHS),$(call guestagent_path_enabled_by_config,LINUX,$(arch)))
429endif
430ifeq ($(CONFIG_GUESTAGENT_OS_DARWIN),y)
431GUESTAGENTS += $(call guestagent_path,DARWIN,aarch64)
432endif
433
434.PHONY: guestagents native-guestagent additional-guestagents
435guestagents: $(GUESTAGENTS)
436native-guestagent: $(NATIVE_GUESTAGENT)
437additional-guestagents: $(ADDITIONAL_GUESTAGENTS)
438%-guestagent:
439 @[ "$(findstring $(*),$(LINUX_GUESTAGENT_ARCHS))" == "$(*)" ] && make $(call guestagent_path,LINUX,$*)
440 @[ "$(findstring $(*),$(DARWIN_GUESTAGENT_ARCHS))" == "$(*)" ] && make $(call guestagent_path,DARWIN,$*)
441
442# environment variables for linux-guestagent. these variable are used for checking force build.
443ENVS_$(LINUX_GUESTAGENT_PATH_COMMON)aarch64 = CGO_ENABLED=0 GOOS=linux GOARCH=arm64
444ENVS_$(LINUX_GUESTAGENT_PATH_COMMON)armv7l = CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7
445ENVS_$(LINUX_GUESTAGENT_PATH_COMMON)ppc64le = CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le
446ENVS_$(LINUX_GUESTAGENT_PATH_COMMON)riscv64 = CGO_ENABLED=0 GOOS=linux GOARCH=riscv64
447ENVS_$(LINUX_GUESTAGENT_PATH_COMMON)s390x = CGO_ENABLED=0 GOOS=linux GOARCH=s390x
448ENVS_$(LINUX_GUESTAGENT_PATH_COMMON)x86_64 = CGO_ENABLED=0 GOOS=linux GOARCH=amd64
449ENVS_$(DARWIN_GUESTAGENT_PATH_COMMON)aarch64 = CGO_ENABLED=0 GOOS=darwin GOARCH=arm64
450$(ALL_GUESTAGENTS_NOT_COMPRESSED): $(call dependencies_for_cmd,lima-guestagent) $$(call force_build_with_gunzip,$$@) | _output/share/lima
451 $(ENVS_$@) $(GO_BUILD) -o $@ ./cmd/lima-guestagent
452 chmod 644 $@
453$(LINUX_GUESTAGENT_PATH_COMMON)%.gz: $(LINUX_GUESTAGENT_PATH_COMMON)% $$(call force_build_with_gunzip,$$@)
454 @set -x; gzip -n $<
455$(DARWIN_GUESTAGENT_PATH_COMMON)%.gz: $(DARWIN_GUESTAGENT_PATH_COMMON)% $$(call force_build_with_gunzip,$$@)
456 @set -x; gzip -n $<
457
458MKDIR_TARGETS += _output/share/lima
459
460################################################################################
461# _output/share/lima/templates
462TEMPLATES = $(addprefix _output/share/lima/templates/,$(filter-out experimental,$(notdir $(wildcard templates/*))))
463TEMPLATE_DEFAULTS = ${addprefix _output/share/lima/templates/_default/,$(notdir $(wildcard templates/_default/*))}
464TEMPLATE_IMAGES = $(addprefix _output/share/lima/templates/_images/,$(notdir $(wildcard templates/_images/*)))
465TEMPLATE_EXPERIMENTALS = $(addprefix _output/share/lima/templates/experimental/,$(notdir $(wildcard templates/experimental/*)))
466
467.PHONY: default_template templates template_experimentals
468default_template: _output/share/lima/templates/default.yaml
469templates: $(TEMPLATES) $(TEMPLATE_DEFAULTS) $(TEMPLATE_IMAGES)
470template_experimentals: $(TEMPLATE_EXPERIMENTALS)
471
472$(TEMPLATES): | _output/share/lima/templates
473$(TEMPLATE_DEFAULTS): | _output/share/lima/templates/_default
474$(TEMPLATE_IMAGES): | _output/share/lima/templates/_images
475$(TEMPLATE_EXPERIMENTALS): | _output/share/lima/templates/experimental
476MKDIR_TARGETS += _output/share/lima/templates _output/share/lima/templates/_default _output/share/lima/templates/_images _output/share/lima/templates/experimental
477
478_output/share/lima/templates/%: templates/%
479 cp -aL $< $@
480
481# returns "force" if GOOS==windows, or GOOS!=windows and the file $(1) is not a symlink.
482# $(1): target file
483# On Windows, always copy to ensure the target has the same file as the source.
484force_link = $(if $(filter windows,$(GOOS)),force,$(shell test ! -L $(1) && echo force))
485
486################################################################################
487# templates/_images
488
489# fedora-N.yaml should not be updated to refer to Fedora N+1 images
490TEMPLATES_TO_BE_UPDATED = $(filter-out $(wildcard templates/_images/fedora*.yaml),$(wildcard templates/_images/*.yaml))
491
492.PHONY: update-templates
493update-templates: $(TEMPLATES_TO_BE_UPDATED)
494 ./hack/update-template.sh $^
495
496################################################################################
497# _output/share/doc/lima
498DOCUMENTATION = $(addprefix _output/share/doc/lima/,$(wildcard *.md) LICENSE SECURITY.md VERSION)
499
500.PHONY: documentation
501documentation: $(DOCUMENTATION)
502
503_output/share/doc/lima/SECURITY.md: | _output/share/doc/lima
504 echo "Moved to https://github.com/lima-vm/.github/blob/main/SECURITY.md" > $@
505
506_output/share/doc/lima/VERSION: | _output/share/doc/lima
507 echo $(VERSION) > $@
508
509_output/share/doc/lima/%: % | _output/share/doc/lima
510 cp -aL $< $@
511
512MKDIR_TARGETS += _output/share/doc/lima
513
514.PHONY: create-links-in-doc-dir
515create-links-in-doc-dir: _output/share/doc/lima/templates
516_output/share/doc/lima/templates: _output/share/lima/templates $$(call force_link,$$@)
517# remove the existing directory or symlink
518 rm -rf $@
519ifneq ($(GOOS),windows)
520 ln -sf ../../lima/templates $@
521else
522# copy from templates built in build process
523 cp -aL $< $@
524endif
525
526################################################################################
527# returns difference between GOOS GOARCH and GOHOSTOS GOHOSTARCH.
528cross_compiling = $(call diff,$(GOOS) $(GOARCH),$(GOHOSTOS) $(GOHOSTARCH))
529# returns true if cross_compiling is empty.
530native_compiling = $(if $(cross_compiling),,true)
531
532################################################################################
533# _output/share/man/man1
534.PHONY: manpages
535# Set limactl.1 as explicit dependency.
536# It's uncertain how many manpages will be generated by `make`,
537# because `limactl` generates them without corresponding source code for the manpages.
538manpages: _output/share/man/man1/limactl.1
539_output/share/man/man1/limactl.1: _output/bin/limactl$(exe)
540 @mkdir -p _output/share/man/man1
541ifeq ($(native_compiling),true)
542# The manpages are generated by limactl, so the limactl binary must be native.
543 $< generate-doc _output/share/man/man1 \
544 --output _output --prefix $(PREFIX)
545endif
546
547################################################################################
548.PHONY: docsy
549# Set limactl.md as explicit dependency.
550# It's uncertain how many docsy pages will be generated by `make`,
551# because `limactl` generates them without corresponding source code for the docsy pages.
552docsy: website/_output/docsy/limactl.md website/_output/docsy-mcp/mcp.md
553website/_output/docsy/limactl.md: _output/bin/limactl$(exe)
554 @mkdir -p website/_output/docsy
555ifeq ($(native_compiling),true)
556# The docs are generated by limactl, so the limactl binary must be native.
557 $< generate-doc --type docsy website/_output/docsy \
558 --output _output --prefix $(PREFIX)
559endif
560website/_output/docsy-mcp/mcp.md: _output/libexec/lima/limactl-mcp$(exe)
561 @mkdir -p website/_output/docsy-mcp
562ifeq ($(native_compiling),true)
563 $< generate-doc website/_output/docsy-mcp
564endif
565
566################################################################################
567default-template.yaml: _output/bin/limactl$(exe) templates/default.yaml \
568 _output/share/lima/templates/_images/ubuntu.yaml \
569 _output/share/lima/templates/_default/mounts.yaml
570ifeq ($(native_compiling),true)
571 $< tmpl copy --embed-all templates/default.yaml $@
572endif
573
574schema-limayaml.json: _output/bin/limactl$(exe) templates/default.yaml default-template.yaml
575ifeq ($(native_compiling),true)
576 # validate both the original template (with the "base" etc), and the embedded template
577 $< generate-jsonschema --schemafile $@ templates/default.yaml default-template.yaml
578endif
579
580.PHONY: check-jsonschema
581check-jsonschema: schema-limayaml.json templates/default.yaml default-template.yaml
582 check-jsonschema --schemafile schema-limayaml.json templates/default.yaml default-template.yaml
583
584################################################################################
585.PHONY: diagrams
586diagrams: docs/lima-sequence-diagram.png
587docs/lima-sequence-diagram.png: docs/images/lima-sequence-diagram.puml
588 $(PLANTUML) ./docs/images/lima-sequence-diagram.puml
589
590################################################################################
591.PHONY: install
592install: uninstall
593 mkdir -p "$(DEST)"
594 # Use tar rather than cp, for better symlink handling
595 ( cd _output && $(TAR) c * | $(TAR) -xv --no-same-owner -C "$(DEST)" )
596 if [ "$(shell uname -s )" != "Linux" -a ! -e "$(DEST)/bin/nerdctl" ]; then ln -sf nerdctl.lima "$(DEST)/bin/nerdctl"; fi
597 if [ "$(shell uname -s )" != "Linux" -a ! -e "$(DEST)/bin/apptainer" ]; then ln -sf apptainer.lima "$(DEST)/bin/apptainer"; fi
598
599.PHONY: uninstall
600uninstall:
601 @test -f "$(DEST)/bin/lima" || echo "lima not found in $(DEST) prefix"
602 rm -rf \
603 "$(DEST)/bin/lima" \
604 "$(DEST)/bin/lima$(bat)" \
605 "$(DEST)/bin/limactl$(exe)" \
606 "$(DEST)/bin/nerdctl.lima" \
607 "$(DEST)/bin/apptainer.lima" \
608 "$(DEST)/bin/docker.lima" \
609 "$(DEST)/bin/podman.lima" \
610 "$(DEST)/bin/kubectl.lima" \
611 "$(DEST)/share/man/man1/lima.1" \
612 "$(DEST)/share/man/man1/limactl"*".1" \
613 "$(DEST)/share/lima" \
614 "$(DEST)/share/doc/lima" \
615 "$(DEST)/libexec/lima/limactl-mcp$(exe)" \
616 "$(DEST)/libexec/lima/limactl-url-fedora-rawhide" \
617 "$(DEST)/libexec/lima/lima-driver-qemu$(exe)" \
618 "$(DEST)/libexec/lima/lima-driver-vz$(exe)" \
619 "$(DEST)/libexec/lima/lima-driver-wsl2$(exe)" \
620 "$(DEST)/libexec/lima/lima-driver-krunkit$(exe)" \
621 "$(DEST)/libexec/lima/privileged/lima-privileged-net"
622 if [ "$$(readlink "$(DEST)/bin/nerdctl")" = "nerdctl.lima" ]; then rm "$(DEST)/bin/nerdctl"; fi
623 if [ "$$(readlink "$(DEST)/bin/apptainer")" = "apptainer.lima" ]; then rm "$(DEST)/bin/apptainer"; fi
624
625.PHONY: check-generated
626check-generated:
627 git diff --exit-code || \
628 (echo "Please run 'make generate' when making changes to proto files and check-in the generated file changes" && false)
629
630.PHONY: bats
631bats: native limactl-plugins
632 PATH=$$PWD/_output/bin:$$PATH ./hack/bats/lib/bats-core/bin/bats --timing ./hack/bats/tests
633
634# Linting targets - individual stages
635.PHONY: nobin
636nobin:
637 $(GO) run -modfile=./hack/tools/go.mod github.com/jandubois/nobin --allow-emoji --allow-escape --gitignore --skip-ext pb.desc --skip 'website/static/images/**/*.{gif,png}' --skip 'docs/reports/**/*.pdf'
638
639.PHONY: editorconfig-checker
640editorconfig-checker:
641 $(GO) run -modfile=./hack/tools/go.mod github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker
642
643.PHONY: golangci-lint
644golangci-lint:
645 $(GO) run -modfile=./hack/tools/go.mod github.com/golangci/golangci-lint/v2/cmd/golangci-lint run ./...
646
647.PHONY: yamllint
648yamllint:
649 yamllint .
650
651.PHONY: ls-lint
652ls-lint:
653 ls-lint
654
655.PHONY: shellcheck
656shellcheck:
657 find . -name '*.sh' ! -path "./.git/*" | xargs shellcheck
658
659.PHONY: shfmt
660shfmt:
661 find . -name '*.sh' ! -path "./.git/*" | xargs $(GO) run -modfile=./hack/tools/go.mod mvdan.cc/sh/v3/cmd/shfmt -s -d
662
663CYCLONEDX_GOMOD = $(GO) run -modfile=./hack/tools/go.mod github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod
664CYCLONEDX_GOMOD_FLAGS = -licenses -short-purls
665
666.PHONY: sbom
667sbom: sbom-mod sbom-app
668
669.PHONY: sbom-mod
670sbom-mod:
671 rm -rf vendor
672 GOOS="$(GOHOSTOS)" GOARCH="$(GOHOSTARCH)" GOFLAGS="" \
673 $(CYCLONEDX_GOMOD) mod $(CYCLONEDX_GOMOD_FLAGS) -json -output bom.json -type library
674
675SBOM_OS = $(call capitalize,$(GOOS))
676SBOM_ARCH = $(call to_uname_m,$(GOARCH))
677
678.PHONY: sbom-app
679sbom-app:
680ifeq ($(native_compiling),true)
681 rm -rf vendor
682 $(CYCLONEDX_GOMOD) app $(CYCLONEDX_GOMOD_FLAGS) -json -output limactl.$(SBOM_OS)-$(SBOM_ARCH).bom.json -main cmd/limactl
683 $(CYCLONEDX_GOMOD) app $(CYCLONEDX_GOMOD_FLAGS) -json -output limactl-mcp.$(SBOM_OS)-$(SBOM_ARCH).bom.json -main cmd/limactl-mcp
684 $(CYCLONEDX_GOMOD) app $(CYCLONEDX_GOMOD_FLAGS) -json -output lima-guestagent.$(SBOM_OS)-$(SBOM_ARCH).bom.json -main cmd/lima-guestagent
685endif
686
687.PHONY: go-licenses
688go-licenses:
689 # the allow list corresponds to https://github.com/cncf/foundation/blob/87e70a07d5a0cf06cd6f8208b8d52c16f035724a/policies-guidance/allowed-third-party-license-policy.md
690 # hashicorp/hcl/v2 is MPL-2.0; covered by the CNCF license exception for hashicorp/hcl
691 # see also https://github.com/cncf/foundation/issues/1242
692 # segmentio/asm is MIT-0; approved by CNCF, but go-licenses has not support it yet.
693 # see also https://github.com/google/licenseclassifier/issues/75
694 go-licenses check --include_tests --ignore github.com/hashicorp/hcl/v2 --ignore github.com/segmentio/asm ./... --allowed_licenses=$$(cat ./hack/allowed-licenses.txt)
695
696# gomodjail statically verifies that the Go modules annotated `gomodjail:confined` in go.mod
697# cannot reach a denied capability (filesystem, network, process execution, raw syscalls,
698# OS state modification, or cgo).
699# https://github.com/AkihiroSuda/gomodjail
700#
701# The verdicts are platform-dependent, so the gate is pinned to linux/amd64 and linux/arm64.
702# These are the only platforms that can be analyzed from any host: analyzing darwin needs a
703# macOS host, as the "vz" driver requires cgo. The linux verdicts are a superset of the
704# darwin ones anyway.
705#
706# When a dependency bump makes a confined module reach a denied capability, run
707# `make gomodjail-fix` to downgrade its annotation to `gomodjail:unconfined`,
708# so that the decision stays visible and reviewable in go.mod.
709GOMODJAIL = $(GO) run -modfile=./hack/tools/go.mod github.com/AkihiroSuda/gomodjail/v2/cmd/gomodjail
710
711# gomodjail itself does not build on Windows hosts, as its legacy dynamic mode is compiled in
712# unconditionally.
713.PHONY: gomodjail
714gomodjail:
715ifeq ($(GOHOSTOS),windows)
716 @echo "Skipped: gomodjail does not support Windows hosts"
717else
718 $(GOMODJAIL) analyze --goos=linux --goarch=amd64 ./...
719 $(GOMODJAIL) analyze --goos=linux --goarch=arm64 ./...
720endif
721
722# Downgrades the `gomodjail:confined` annotation of the modules that fail `make gomodjail`
723# to `gomodjail:unconfined`. Unconfining is the only safe automated fix: a violation means
724# that the module's own dependency cone reaches the capability.
725.PHONY: gomodjail-fix
726gomodjail-fix:
727ifeq ($(GOHOSTOS),windows)
728 @echo "Skipped: gomodjail does not support Windows hosts"
729else
730 $(GOMODJAIL) fix --goos=linux --goarch=amd64 ./...
731 $(GOMODJAIL) fix --goos=linux --goarch=arm64 ./...
732endif
733
734.PHONY: gosocialcheck
735gosocialcheck:
736 -$(GO) run -modfile=./hack/tools/go.mod github.com/AkihiroSuda/gosocialcheck/cmd/gosocialcheck run --gha=$(GITHUB_ACTIONS) ./...
737 # TODO: run gosocialcheck for ./hack/tools/... too (not supported yet by gosocialcheck)
738
739.PHONY: ltag
740ltag:
741 $(GO) run -modfile=./hack/tools/go.mod github.com/containerd/ltag -t ./hack/ltag --check --excludes "vendor _output" -v
742
743.PHONY: protolint
744protolint:
745 $(GO) run -modfile=./hack/tools/go.mod github.com/yoheimuta/protolint/cmd/protolint .
746
747# Main lint target - runs all linting stages
748.PHONY: lint
749lint: check-generated nobin editorconfig-checker golangci-lint yamllint ls-lint shellcheck shfmt go-licenses gomodjail gosocialcheck ltag protolint
750
751.PHONY: clean
752clean:
753 rm -rf _output vendor
754
755.PHONY: install-protoc-tools
756install-protoc-tools:
757 go install -modfile=./hack/tools/go.mod google.golang.org/protobuf/cmd/protoc-gen-go
758 go install -modfile=./hack/tools/go.mod google.golang.org/grpc/cmd/protoc-gen-go-grpc
759
760.PHONY: generate
761generate:
762 go generate ./...
763
764################################################################################
765# _artifacts/lima-$(VERSION_TRIMMED)-$(ARTIFACT_OS)-$(ARTIFACT_UNAME_M)
766# _artifacts/lima-additional-guestagents-$(VERSION_TRIMMED)-$(ARTIFACT_OS)-$(ARTIFACT_UNAME_M)
767.PHONY: artifact
768
769# returns the capitalized string of $(1).
770capitalize = $(shell echo "$(1)"|awk '{print toupper(substr($$0,1,1)) tolower(substr($$0,2))}')
771
772# returns the architecture name converted from GOARCH to GNU coreutils uname -m.
773to_uname_m = $(foreach arch,$(1),$(shell echo $(arch) | sed 's/amd64/x86_64/' | sed 's/arm64/aarch64/'))
774
775ARTIFACT_FILE_EXTENSIONS := .tar.gz
776
777ifeq ($(GOOS),darwin)
778# returns the architecture name converted from GOARCH to macOS's uname -m.
779to_uname_m = $(foreach arch,$(1),$(shell echo $(arch) | sed 's/amd64/x86_64/'))
780else ifeq ($(GOOS),windows)
781# Conforms to %PROCESSOR_ARCHITECTURE%
782to_uname_m = $(foreach arch,$(1),$(shell echo $(arch) | sed 's/amd64/AMD64/' | sed 's/arm64/ARM64/'))
783# Windows artifacts use zip instead of tar.gz.
784ARTIFACT_FILE_EXTENSIONS := .zip
785else ifeq ($(GOOS),linux)
786# CC is required for cross-compiling on Linux.
787# On Debian, Ubuntu, and related distributions, compilers are named like x86_64-linux-gnu-gcc
788# On Fedora, RHEL, and related distributions, the equivalent is x86_64-redhat-linux-gcc
789# On openSUSE and as a generic fallback, gcc is used
790CC := $(shell \
791 if command -v $(call to_uname_m,$(GOARCH))-redhat-linux-gcc >/dev/null 2>&1; then \
792 echo $(call to_uname_m,$(GOARCH))-redhat-linux-gcc; \
793 elif command -v $(call to_uname_m,$(GOARCH))-linux-gnu-gcc >/dev/null 2>&1; then \
794 echo $(call to_uname_m,$(GOARCH))-linux-gnu-gcc; \
795 else \
796 echo gcc; \
797 fi)
798endif
799
800# artifacts: artifacts-$(GOOS)
801ARTIFACT_OS = $(call capitalize,$(GOOS))
802ARTIFACT_UNAME_M = $(call to_uname_m,$(GOARCH))
803ARTIFACT_PATH_COMMON = _artifacts/lima-$(VERSION_TRIMMED)-$(ARTIFACT_OS)-$(ARTIFACT_UNAME_M)
804ARTIFACT_ADDITIONAL_GUESTAGENTS_PATH_COMMON = _artifacts/lima-additional-guestagents-$(VERSION_TRIMMED)-$(ARTIFACT_OS)-$(ARTIFACT_UNAME_M)
805
806artifact: $(addprefix $(ARTIFACT_PATH_COMMON),$(ARTIFACT_FILE_EXTENSIONS)) \
807 $(addprefix $(ARTIFACT_ADDITIONAL_GUESTAGENTS_PATH_COMMON),$(ARTIFACT_FILE_EXTENSIONS))
808
809ARTIFACT_DES = _output/bin/limactl$(exe) limactl-plugins $(LIMA_DEPS) $(HELPERS_DEPS) \
810 $(NATIVE_GUESTAGENT) \
811 $(TEMPLATES) $(TEMPLATE_IMAGES) $(TEMPLATE_DEFAULTS) $(TEMPLATE_EXPERIMENTALS) \
812 additional-drivers \
813 $(DOCUMENTATION) _output/share/doc/lima/templates \
814 _output/share/man/man1/limactl.1
815
816# file targets
817$(ARTIFACT_PATH_COMMON).tar.gz: $(ARTIFACT_DES) | _artifacts
818 $(TAR) -C _output/ --no-xattrs -czvf $@ ./
819
820$(ARTIFACT_ADDITIONAL_GUESTAGENTS_PATH_COMMON).tar.gz:
821 # FIXME: do not exec make from make
822 make clean additional-guestagents
823 $(TAR) -C _output/ --no-xattrs -czvf $@ ./
824
825$(ARTIFACT_PATH_COMMON).zip: $(ARTIFACT_DES) | _artifacts
826 cd _output && $(ZIP) -r ../$@ *
827
828$(ARTIFACT_ADDITIONAL_GUESTAGENTS_PATH_COMMON).zip:
829 make clean additional-guestagents
830 cd _output && $(ZIP) -r ../$@ *
831
832# generate manpages using native limactl.
833manpages-using-native-limactl: GOOS = $(GOHOSTOS)
834manpages-using-native-limactl: GOARCH = $(GOHOSTARCH)
835manpages-using-native-limactl: manpages
836
837# returns "manpages-using-native-limactl" if $(1) is not equal to $(GOHOSTOS).
838# $(1): GOOS
839generate_manpages_if_needed = $(if $(filter $(if $(1),$(1),$(GOOS)),$(GOHOSTOS)),,manpages-using-native-limactl)
840
841# build native arch first, then build other archs.
842artifact_goarchs = arm64 amd64
843goarchs_native_and_others = $(GOHOSTARCH) $(filter-out $(GOHOSTARCH),$(artifact_goarchs))
844
845# artifacts is artifact bundles for each OS.
846# if target GOOS is native, build native arch first, generate manpages, then build other archs.
847# if target GOOS is not native, build native limactl, generate manpages, then build the target GOOS with archs.
848.PHONY: artifacts artifacts-darwin artifacts-linux artifacts-windows
849artifacts: $$(addprefix artifact-$$(GOOS)-,$$(goarchs_native_and_others))
850artifacts-darwin: $$(call generate_manpages_if_needed,darwin) $$(addprefix artifact-darwin-,$$(goarchs_native_and_others))
851artifacts-linux: $$(call generate_manpages_if_needed,linux) $$(addprefix artifact-linux-,$$(goarchs_native_and_others))
852# FIXME: remove shell scripts from Windows artifacts?
853artifacts-windows: $$(call generate_manpages_if_needed,windows) $$(addprefix artifact-windows-,$$(goarchs_native_and_others))
854
855# set variables for artifact variant targets.
856artifact-darwin% artifact-darwin: GOOS = darwin
857artifact-linux% artifact-linux: GOOS = linux
858artifact-windows% artifact-windows: GOOS = windows
859artifact-%-amd64 artifact-%-x86_64 artifact-amd64 artifact-x86_64: GOARCH = amd64
860artifact-%-arm64 artifact-%-aarch64 artifact-arm64 artifact-aarch64: GOARCH = arm64
861
862# build cross arch binaries.
863artifact-%: $$(call generate_manpages_if_needed)
864 make clean artifact GOOS=$(GOOS) GOARCH=$(GOARCH)
865
866.PHONY: artifacts-jsonschema
867artifacts-jsonschema: schema-limayaml.json | _artifacts
868 $(CP) $^ _artifacts/
869
870.PHONY: artifacts-misc
871artifacts-misc: sbom | _artifacts
872 go mod vendor
873 $(TAR) --no-xattrs -czf _artifacts/lima-$(VERSION_TRIMMED)-go-mod-vendor.tar.gz go.mod go.sum vendor
874 $(TAR) --no-xattrs -czf _artifacts/lima-$(VERSION_TRIMMED)-sbom.tar.gz *bom.json
875
876MKDIR_TARGETS += _artifacts
877
878################################################################################
879# This target must be placed after any changes to the `MKDIR_TARGETS` variable.
880# It seems that variable expansion in Makefile targets is not done recursively.
881$(MKDIR_TARGETS):
882 mkdir -p $@