golang.zx2c4.com/wireguard/windows@v0.5.4-0.20230123132234-dcc0eb72a04b/Makefile (about)

     1  GOFLAGS := -tags load_wgnt_from_rsrc -ldflags="-H windowsgui -s -w" -trimpath -buildvcs=false -v
     2  export GOOS := windows
     3  export PATH := $(CURDIR)/.deps/go/bin:$(PATH)
     4  
     5  VERSION := $(shell sed -n 's/^\s*Number\s*=\s*"\([0-9.]\+\)"$$/\1/p' version/version.go)
     6  empty :=
     7  space := $(empty) $(empty)
     8  comma := ,
     9  RCFLAGS := -DWIREGUARD_VERSION_ARRAY=$(subst $(space),$(comma),$(wordlist 1,4,$(subst .,$(space),$(VERSION)) 0 0 0 0)) -DWIREGUARD_VERSION_STR=$(VERSION) -O coff -c 65001
    10  
    11  rwildcard=$(foreach d,$(filter-out .deps,$(wildcard $1*)),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
    12  SOURCE_FILES := $(call rwildcard,,*.go) .deps/go/prepared go.mod go.sum
    13  RESOURCE_FILES := resources.rc version/version.go manifest.xml $(patsubst %.svg,%.ico,$(wildcard ui/icon/*.svg)) .deps/wireguard-nt/prepared
    14  
    15  DEPLOYMENT_HOST ?= winvm
    16  DEPLOYMENT_PATH ?= Desktop
    17  
    18  all: amd64/wireguard.exe x86/wireguard.exe arm64/wireguard.exe
    19  
    20  define download =
    21  .distfiles/$(1):
    22  	mkdir -p .distfiles
    23  	if ! curl -L#o $$@.unverified $(2); then rm -f $$@.unverified; exit 1; fi
    24  	if ! echo "$(3)  $$@.unverified" | sha256sum -c; then rm -f $$@.unverified; exit 1; fi
    25  	if ! mv $$@.unverified $$@; then rm -f $$@.unverified; exit 1; fi
    26  endef
    27  
    28  $(eval $(call download,go.tar.gz,https://go.dev/dl/go1.18.linux-amd64.tar.gz,e85278e98f57cdb150fe8409e6e5df5343ecb13cebf03a5d5ff12bd55a80264f))
    29  $(eval $(call download,wireguard-nt.zip,https://download.wireguard.com/wireguard-nt/wireguard-nt-0.10.1.zip,772c0b1463d8d2212716f43f06f4594d880dea4f735165bd68e388fc41b81605))
    30  
    31  .deps/go/prepared: .distfiles/go.tar.gz
    32  	mkdir -p .deps
    33  	rm -rf .deps/go
    34  	bsdtar -C .deps -xf .distfiles/go.tar.gz
    35  	chmod -R +w .deps/go
    36  	touch $@
    37  
    38  .deps/wireguard-nt/prepared: .distfiles/wireguard-nt.zip
    39  	mkdir -p .deps
    40  	rm -rf .deps/wireguard-nt
    41  	bsdtar -C .deps -xf .distfiles/wireguard-nt.zip
    42  	touch $@
    43  
    44  %.ico: %.svg
    45  	convert -background none $< -define icon:auto-resize="256,192,128,96,64,48,40,32,24,20,16" -compress zip $@
    46  
    47  resources_amd64.syso: $(RESOURCE_FILES)
    48  	x86_64-w64-mingw32-windres $(RCFLAGS) -I .deps/wireguard-nt/bin/amd64 -i $< -o $@
    49  
    50  resources_386.syso: $(RESOURCE_FILES)
    51  	i686-w64-mingw32-windres $(RCFLAGS) -I .deps/wireguard-nt/bin/x86 -i $< -o $@
    52  
    53  resources_arm64.syso: $(RESOURCE_FILES)
    54  	aarch64-w64-mingw32-windres $(RCFLAGS) -I .deps/wireguard-nt/bin/arm64 -i $< -o $@
    55  
    56  amd64/wireguard.exe: export GOARCH := amd64
    57  amd64/wireguard.exe: resources_amd64.syso $(SOURCE_FILES)
    58  	go build $(GOFLAGS) -o $@
    59  
    60  x86/wireguard.exe: export GOARCH := 386
    61  x86/wireguard.exe: resources_386.syso $(SOURCE_FILES)
    62  	go build $(GOFLAGS) -o $@
    63  
    64  arm64/wireguard.exe: export GOARCH := arm64
    65  arm64/wireguard.exe: resources_arm64.syso $(SOURCE_FILES)
    66  	go build $(GOFLAGS) -o $@
    67  
    68  remaster: export GOARCH := amd64
    69  remaster: export GOPROXY := direct
    70  remaster: .deps/go/prepared
    71  	rm -f go.sum go.mod
    72  	cp go.mod.master go.mod
    73  	go get -d
    74  	sed -i $(shell curl -L 'https://go.dev/dl/?mode=json&include=all' | jq -r '(".windows-amd64.zip",".linux-amd64.tar.gz") as $$suffix | .[0].files[] | select(.filename|endswith($$suffix)) | ("-e", "s/go[0-9][^ ]*\\\($$suffix)\\([ ,]\\)[a-f0-9]\\+/\(.filename)\\1\(.sha256)/") | @sh') Makefile build.bat
    75  
    76  fmt: export GOARCH := amd64
    77  fmt: .deps/go/prepared
    78  	go fmt ./...
    79  
    80  generate: export GOOS :=
    81  generate: .deps/go/prepared
    82  	go generate -mod=mod ./...
    83  
    84  crowdin:
    85  	find locales -maxdepth 1 -mindepth 1 -type d \! -name en -exec rm -rf {} +
    86  	curl -Lo - https://crowdin.com/backend/download/project/wireguard.zip | bsdtar -C locales -x -f - --strip-components 2 wireguard-windows
    87  	find locales -name messages.gotext.json -exec bash -c '[[ $$(jq ".messages | length" {}) -ne 0 ]] || rm -rf "$$(dirname {})"' \;
    88  	@$(MAKE) --no-print-directory generate
    89  
    90  deploy: amd64/wireguard.exe
    91  	-ssh $(DEPLOYMENT_HOST) -- 'taskkill /im wireguard.exe /f'
    92  	scp $< $(DEPLOYMENT_HOST):$(DEPLOYMENT_PATH)
    93  
    94  clean:
    95  	rm -rf *.syso ui/icon/*.ico x86/ amd64/ arm64/ .deps
    96  
    97  distclean: clean
    98  	rm -rf .distfiles
    99  
   100  .PHONY: deploy clean distclean fmt remaster generate all