From e25ca62728875332847e7e9f5ce45a3a4d193522 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Tue, 3 Oct 2023 16:41:28 +0200 Subject: [PATCH] build: Add codesigning target Running `make` twice currently ends with an error: ``` % make [...] % make CGO_ENABLED=1 CGO_CFLAGS=-mmacosx-version-min=11.0 GOOS=darwin GOARCH=amd64 go build -o out/vfkit-amd64 ./cmd/vfkit codesign --entitlements vf.entitlements -s - out/vfkit-amd64 out/vfkit-amd64: is already signed make: *** [out/vfkit-amd64] Error 1 ``` This commit moves codesigning to its own target, and makes use of 'stamp' files to detect when codesigning needs to be redone. --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 43d30163..fac3d461 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ test: build @go test ./pkg/... ./test clean: + rm codesign-{amd64,arm64}-stamp rm -rf out out/vfkit-amd64 out/vfkit-arm64: out/vfkit-%: force-build @@ -20,7 +21,12 @@ out/vfkit-amd64 out/vfkit-arm64: out/vfkit-%: force-build CGO_ENABLED=1 CGO_CFLAGS=$(CGO_CFLAGS) GOOS=darwin GOARCH=$* go build -o $@ ./cmd/vfkit codesign -f --entitlements vf.entitlements -s - $@ -out/vfkit: out/vfkit-amd64 out/vfkit-arm64 +codesign-amd64-stamp codesign-arm64-stamp: codesign-%-stamp: out/vfkit-% + codesign -f --entitlements vf.entitlements -s - $< + touch $@ + + +out/vfkit: codesign-amd64-stamp codesign-arm64-stamp cd $(@D) && lipo -create $(^F) -output $(@F) # the go compiler is doing a good job at not rebuilding unchanged files