diff --git a/example/linux/Makefile b/example/linux/Makefile index 260b05ef..541adff9 100644 --- a/example/linux/Makefile +++ b/example/linux/Makefile @@ -5,6 +5,19 @@ all: build codesign codesign: codesign --entitlements vz.entitlements -s - ./virtualization -.PHONY: build +.PHONY: build cross-build build: go build -o virtualization . + +cross-build: virtualization-amd64 virtualization-arm64 + +virtualization-amd64 virtualization-arm64: virtualization-%: force-build + CGO_ENABLED=1 GOOS=darwin GOARCH=$* go build -o $@ . + +# the go compiler is doing a good job at not rebuilding unchanged files +# this phony target ensures out/vfkit-* are always considered out of date +# and rebuilt. If the code was unchanged, go won't rebuild anything so that's +# fast. Forcing the rebuild ensure we rebuild when needed, ie when the source code +# changed, without adding explicit dependencies to the go files/go.mod +.PHONY: force-build +force-build: diff --git a/example/macOS/Makefile b/example/macOS/Makefile index 260b05ef..541adff9 100644 --- a/example/macOS/Makefile +++ b/example/macOS/Makefile @@ -5,6 +5,19 @@ all: build codesign codesign: codesign --entitlements vz.entitlements -s - ./virtualization -.PHONY: build +.PHONY: build cross-build build: go build -o virtualization . + +cross-build: virtualization-amd64 virtualization-arm64 + +virtualization-amd64 virtualization-arm64: virtualization-%: force-build + CGO_ENABLED=1 GOOS=darwin GOARCH=$* go build -o $@ . + +# the go compiler is doing a good job at not rebuilding unchanged files +# this phony target ensures out/vfkit-* are always considered out of date +# and rebuilt. If the code was unchanged, go won't rebuild anything so that's +# fast. Forcing the rebuild ensure we rebuild when needed, ie when the source code +# changed, without adding explicit dependencies to the go files/go.mod +.PHONY: force-build +force-build: