diff --git a/Makefile b/Makefile index aded785..131ff65 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,37 @@ -all: linux-amd64 +CGO_ENABLED = 1 +DIR = ./build -.ONESHELL: -linux-amd64: fmt - GOARCH=amd64 GOOS=linux go build -ldflags '-s -w' -v -o build/wireguard-gui-amd64 . +GO_ARCH_AMD = amd64 +GO_OS_LINUX = linux + +EXECUTABLE = wireguard-gui + +BIN_LINUX_AMD64 = $(DIR)/$(EXECUTABLE)-linux-$(GO_ARCH_AMD) +BIN_LINUX_ARM64 = $(DIR)/$(EXECUTABLE)-linux-$(GO_ARCH_ARM) + +CC = go build +LDFLAGS = all=-w -s + +.PHONY: all +all: linux + +.PHONY: linux +linux: $(BIN_LINUX_AMD64) + chmod +x $(BIN_LINUX_AMD64) + +.PHONY: $(BIN_LINUX_AMD64) +$(BIN_LINUX_AMD64): + GOARCH=$(GO_ARCH_AMD) \ + GOOS=$(GO_OS_LINUX) \ + $(CC) -ldflags="$(LDFLAGS)" \ + -o $(BIN_LINUX_AMD64) . + +.PHONY: clean +clean: + rm -rf $(DIR)/* tool-gofumpt: which golangci-lint > /dev/null 2>&1 || go install mvdan.cc/gofumpt@latest fmt: tool-gofumpt - gofumpt -w --extra ./ + gofumpt -w --extra .