aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Makefile
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-04-25 14:24:38 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-04-25 14:36:10 +0200
commitaa70c24c733bb52c7f239d6c28aa14362265b720 (patch)
treeb96ab235190a0bf9799f9a2f74aec9a8f6d5b716 /Makefile
parentbuild: %errorlevel% doesn't seem to be set after curl and go calls (diff)
downloadwireguard-windows-aa70c24c733bb52c7f239d6c28aa14362265b720.tar.xz
wireguard-windows-aa70c24c733bb52c7f239d6c28aa14362265b720.zip
Makefile: support dual architecture
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile34
1 files changed, 23 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 720c0099..23bba17c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,27 +1,39 @@
export CFLAGS := -O3 -Wall -std=gnu11
-export CC := x86_64-w64-mingw32-gcc
+GOFLAGS := -ldflags="-H windowsgui -s -w" -v
WINDRES := x86_64-w64-mingw32-windres
export CGO_ENABLED := 1
export GOOS := windows
-export GOARCH := amd64
+
+rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
+SOURCE_FILES := $(call rwildcard,,*.go *.c *.h)
+RESOURCE_FILES := resources.rc manifest.xml ui/icon/icon.ico
DEPLOYMENT_HOST ?= winvm
DEPLOYMENT_PATH ?= Desktop
-all: wireguard.exe
+all: amd64/wireguard.exe x86/wireguard.exe
-resources.syso: resources.rc manifest.xml ui/icon/icon.ico
- $(WINDRES) -i $< -o $@ -O coff
+resources_amd64.syso: $(RESOURCE_FILES)
+ x86_64-w64-mingw32-windres -i $< -o $@ -O coff
-rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
-wireguard.exe: resources.syso $(call rwildcard,,*.go *.c *.h)
- go build -ldflags="-H windowsgui -s -w" -v -o $@
+resources_386.syso: $(RESOURCE_FILES)
+ i686-w64-mingw32-windres -i $< -o $@ -O coff
+
+amd64/wireguard.exe: export CC := x86_64-w64-mingw32-gcc
+amd64/wireguard.exe: export GOARCH := amd64
+amd64/wireguard.exe: resources_amd64.syso $(SOURCE_FILES)
+ go build $(GOFLAGS) -o $@
+
+x86/wireguard.exe: export CC := i686-w64-mingw32-gcc
+x86/wireguard.exe: export GOARCH := 386
+x86/wireguard.exe: resources_386.syso $(SOURCE_FILES)
+ go build $(GOFLAGS) -o $@
-deploy: wireguard.exe
+deploy: amd64/wireguard.exe
-ssh $(DEPLOYMENT_HOST) -- 'taskkill /im wireguard.exe /f'
- scp wireguard.exe $(DEPLOYMENT_HOST):$(DEPLOYMENT_PATH)
+ scp $< $(DEPLOYMENT_HOST):$(DEPLOYMENT_PATH)
clean:
- rm -rf resources.syso wireguard.exe
+ rm -rf *.syso x86/ amd64/
.PHONY: deploy clean all