Skip to content

Commit e7535a0

Browse files
committed
Add target to cross-compile a Windows binary
1 parent b985fe2 commit e7535a0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Makefile

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22

33
all:
44
@echo "Usage:"
5-
@echo "• make release - build release binary on Mac"
6-
@echo "• make linux - build release binary on Linux through Docker"
5+
@echo "• make release - build release binary on macOS"
6+
@echo "• make cross-linux - build release binary on Linux through Docker"
7+
@echo "• make cross-windows - build release binary on Windows"
78

89
release:
910
go build -ldflags '-s -w' -o g64drive-mac.binary
1011
upx --quiet --quiet --lzma g64drive-mac.binary
1112

12-
linux:
13+
cross-linux:
1314
docker build -t g64drive_linux .
1415
docker run --rm --entrypoint cat g64drive_linux /src/g64drive_linux >g64drive-linux64.binary
1516
chmod +x g64drive-linux64.binary
1617
upx --quiet --quiet --lzma g64drive-linux64.binary
18+
19+
cross-windows:
20+
env GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC="x86_64-w64-mingw32-gcc" go build -ldflags '-s -w'
21+
upx --quiet --quiet --lzma g64drive.exe

0 commit comments

Comments
 (0)