diff --git a/Makefile b/Makefile index 8300553..5823b6e 100644 --- a/Makefile +++ b/Makefile @@ -40,8 +40,7 @@ bin/twenty-twenty-twenty: # - bin/twenty-twenty-twenty-windows-386 # - bin/twenty-twenty-twenty-windows-arm64 # - bin/twenty-twenty-twenty-windows-amd64 -.PHONY: bin/twenty-twenty-twenty-%.exe -bin/twenty-twenty-twenty-%.exe: +bin/twenty-twenty-twenty-%.exe: PHONY_TARGET GOOS=$(word 1,$(subst -, ,$*)) GOARCH=$(word 2,$(subst -, ,$*)) CGO_ENABLED=0 \ go build -v -ldflags="-H=windowsgui $(LDFLAGS)" -o $@ @@ -50,44 +49,29 @@ bin/twenty-twenty-twenty-%.exe: # - bin/twenty-twenty-twenty-linux-amd64 # - bin/twenty-twenty-twenty-linux-arm64 # Since we set CGO_ENABLED=0, some features may be missing (e.g.: sound) -.PHONY: bin/twenty-twenty-twenty-% -bin/twenty-twenty-twenty-%: +bin/twenty-twenty-twenty-%: PHONY_TARGET GOOS=$(word 1,$(subst -, ,$*)) GOARCH=$(word 2,$(subst -, ,$*)) CGO_ENABLED=0 \ go build -v -ldflags="$(LDFLAGS)" -o $@ # Nix target for static binaries in Linux # Needs to be run from the same host that the binaries will be built -.PHONY: bin/twenty-twenty-twenty-linux-amd64-static -bin/twenty-twenty-twenty-linux-amd64-static: +bin/twenty-twenty-twenty-linux-%-static: PHONY_TARGET mkdir -p bin - cp $(shell nix build '.#packages.x86_64-linux.twenty-twenty-twenty-static' --no-link --json | jq -r .[].outputs.out)/bin/twenty-twenty-twenty $@ - chmod +rwx $@ - -.PHONY: bin/twenty-twenty-twenty-linux-arm64-static -bin/twenty-twenty-twenty-linux-arm64-static: - mkdir -p bin - cp $(shell nix build '.#packages.aarch64-linux.twenty-twenty-twenty-static' --no-link --json | jq -r .[].outputs.out)/bin/twenty-twenty-twenty $@ + cp $(shell nix build '.#packages.$*-linux.twenty-twenty-twenty-static' --no-link --json | jq -r .[].outputs.out)/bin/twenty-twenty-twenty $@ chmod +rwx $@ # macOS builds needs an .app bundle and (adhoc) signature to work -.PHONY: bin/TwentyTwentyTwenty_arm64.app -bin/TwentyTwentyTwenty_arm64.app: - go run gioui.org/cmd/gogio -x -arch=arm64 -target=macos -ldflags="$(LDFLAGS)" -icon=./assets/eye.png -o=$@ . - cp $@/Contents/Resources/icon.icns assets/macos/TwentyTwentyTwenty.app/Contents/Resources/icon.icns - cp assets/macos/TwentyTwentyTwenty.app/Contents/Info.plist $@/Contents/Info.plist - mv $@/Contents/MacOS/TwentyTwentyTwenty_arm64 $@/Contents/MacOS/TwentyTwentyTwenty - codesign -s - $@ - -.PHONY: bin/TwentyTwentyTwenty_amd64.app -bin/TwentyTwentyTwenty_amd64.app: - go run gioui.org/cmd/gogio -x -arch=amd64 -target=macos -ldflags="$(LDFLAGS)" -icon=./assets/eye.png -o=$@ . +bin/TwentyTwentyTwenty_%.app: PHONY_TARGET + go run gioui.org/cmd/gogio -x -arch=$* -target=macos -ldflags="$(LDFLAGS)" -icon=./assets/eye.png -o=$@ . cp $@/Contents/Resources/icon.icns assets/macos/TwentyTwentyTwenty.app/Contents/Resources/icon.icns cp assets/macos/TwentyTwentyTwenty.app/Contents/Info.plist $@/Contents/Info.plist - mv $@/Contents/MacOS/TwentyTwentyTwenty_amd64 $@/Contents/MacOS/TwentyTwentyTwenty + mv $@/Contents/MacOS/TwentyTwentyTwenty_$* $@/Contents/MacOS/TwentyTwentyTwenty codesign -s - $@ -bin/TwentyTwentyTwenty_arm64.zip: bin/TwentyTwentyTwenty_arm64.app - cd bin && zip -rv TwentyTwentyTwenty_arm64.zip TwentyTwentyTwenty_arm64.app +bin/TwentyTwentyTwenty_%.zip: bin/TwentyTwentyTwenty_%.app + cd bin && zip -rv TwentyTwentyTwenty_$*.zip TwentyTwentyTwenty_$*.app -bin/TwentyTwentyTwenty_amd64.zip: bin/TwentyTwentyTwenty_amd64.app - cd bin && zip -rv TwentyTwentyTwenty_amd64.zip TwentyTwentyTwenty_amd64.app +# To be used for targets with pattern (e.g.: %) since Makefile doesn't +# understand patterns in PHONY targets +.PHONY: PHONY_TARGET +PHONY_TARGET: