@@ -243,18 +243,48 @@ endif
243243# calls the native resolver library and not the simplistic version in the Go library.
244244ENVS__output/bin/limactl$(exe) = CGO_ENABLED=1 GOOS="$(GOOS ) " GOARCH="$(GOARCH ) " CC="$(CC ) "
245245
246+ LIMACTL_DRIVER_TAGS :=
247+ ifneq (,$(findstring vz,$(ADDITIONAL_DRIVERS ) ) )
248+ LIMACTL_DRIVER_TAGS += external_vz
249+ endif
250+ ifneq (,$(findstring qemu,$(ADDITIONAL_DRIVERS ) ) )
251+ LIMACTL_DRIVER_TAGS += external_qemu
252+ endif
253+ ifneq (,$(findstring wsl2,$(ADDITIONAL_DRIVERS ) ) )
254+ LIMACTL_DRIVER_TAGS += external_wsl2
255+ endif
256+
257+ GO_BUILDTAGS ?=
258+ GO_BUILDTAGS_LIMACTL := $(strip $(GO_BUILDTAGS ) $(LIMACTL_DRIVER_TAGS ) )
259+
246260_output/bin/limactl$(exe ) : $(LIMACTL_DEPS ) $$(call force_build,$$@ )
247- # If the previous cross-compilation was for GOOS=windows, limactl.exe might still be present.
248261ifneq ($(GOOS ) ,windows) #
249262 @rm -rf _output/bin/limactl.exe
250263else
251264 @rm -rf _output/bin/limactl
252265endif
253- $(ENVS_$@) $(GO_BUILD) -o $@ ./cmd/limactl
266+ $(ENVS_$@) $(GO_BUILD) -tags '$(GO_BUILDTAGS_LIMACTL)' - o $@ ./cmd/limactl
254267ifeq ($(GOOS ) ,darwin)
255268 codesign -f -v --entitlements vz.entitlements -s - $@
256269endif
257270
271+ DRIVER_INSTALL_DIR := _output/libexec/lima
272+
273+ .PHONY : additional-drivers
274+ additional-drivers :
275+ @mkdir -p $(DRIVER_INSTALL_DIR )
276+ @for drv in $(ADDITIONAL_DRIVERS ) ; do \
277+ echo " Building $$ drv as external" ; \
278+ if [ " $( GOOS) " = " windows" ]; then \
279+ $(GO_BUILD ) -o $(DRIVER_INSTALL_DIR ) /lima-driver-$$ drv.exe ./cmd/lima-driver-$$ drv; \
280+ else \
281+ $(GO_BUILD ) -o $(DRIVER_INSTALL_DIR ) /lima-driver-$$ drv ./cmd/lima-driver-$$ drv; \
282+ fi ; \
283+ if [ " $$ drv" = " vz" ] && [ " $( GOOS) " = " darwin" ]; then \
284+ codesign -f -v --entitlements vz.entitlements -s - $(DRIVER_INSTALL_DIR ) /lima-driver-vz; \
285+ fi ; \
286+ done
287+
258288LIMA_CMDS = $(sort lima lima$(bat ) ) # $(sort ...) deduplicates the list
259289LIMA_DEPS = $(addprefix _output/bin/,$(LIMA_CMDS ) )
260290lima : $(LIMA_DEPS )
0 commit comments