2021-01-19 14:18:44 +01:00
|
|
|
export GO111MODULE := on
|
|
|
|
GO ?= go
|
|
|
|
GOFLAGS ?= -ldflags '-s -w -extldflags "-static"'
|
|
|
|
GOARM ?= 5
|
|
|
|
GOARCH ?= amd64
|
|
|
|
|
|
|
|
ifeq ($(GOARCH),arm)
|
|
|
|
GOARMLINE := GOARM=$(GOARM)
|
|
|
|
else
|
|
|
|
GOARMLINE :=
|
|
|
|
endif
|
|
|
|
|
2022-02-07 15:24:04 +01:00
|
|
|
GORELEASER := $(GO) run github.com/goreleaser/goreleaser@v1.3.1
|
|
|
|
GOLANGCI_LINT := $(GO) run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.44.0
|
2022-01-07 20:20:48 +01:00
|
|
|
|
2021-01-19 14:18:44 +01:00
|
|
|
all: clean wg-quicker
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2021-01-20 15:03:21 +01:00
|
|
|
rm wg-quicker || true
|
2021-01-22 11:05:17 +01:00
|
|
|
rm third_party/wireguard-go/wireguard-go || true
|
2021-04-16 14:21:36 +02:00
|
|
|
rm assets/wireguard-go/wireguard-go || true
|
2021-01-19 14:18:44 +01:00
|
|
|
|
|
|
|
.PHONY: wireguard-go
|
|
|
|
wireguard-go: clean
|
2021-01-22 11:05:17 +01:00
|
|
|
cd third_party/wireguard-go; \
|
2021-01-19 14:18:44 +01:00
|
|
|
GOOS=linux GOARCH=$(GOARCH) $(GOARMLINE) $(GO) build -v -o wireguard-go $(GOFLAGS) .
|
2021-04-16 14:21:36 +02:00
|
|
|
cp third_party/wireguard-go/wireguard-go assets/wireguard-go
|
2021-01-19 14:18:44 +01:00
|
|
|
|
|
|
|
.PHONY: generate
|
2021-04-16 14:21:36 +02:00
|
|
|
generate:
|
2022-01-07 20:20:48 +01:00
|
|
|
$(GO) generate ./...
|
2021-01-19 14:18:44 +01:00
|
|
|
|
2021-04-16 14:21:36 +02:00
|
|
|
wg-quicker: wireguard-go
|
2021-01-19 14:18:44 +01:00
|
|
|
$(GO) build -v $(GOFLAGS) -o "$@" cmd/wg-quicker/main.go
|
|
|
|
|
|
|
|
.PHONY: build
|
|
|
|
build:
|
2022-01-07 20:20:48 +01:00
|
|
|
$(GORELEASER) build --rm-dist --snapshot --parallelism=1
|
2021-01-19 14:18:44 +01:00
|
|
|
|
|
|
|
.PHONY: release
|
|
|
|
release:
|
2022-02-07 15:24:04 +01:00
|
|
|
$(GORELEASER) release --rm-dist --parallelism=1
|
2021-01-19 14:18:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
test:
|
2022-01-07 20:20:48 +01:00
|
|
|
GOFLAGS=-mod=vendor $(GO) test -race -cover -v ./...
|
2021-01-19 14:18:44 +01:00
|
|
|
|
|
|
|
.PHONY: lint
|
|
|
|
lint:
|
2022-01-07 20:20:48 +01:00
|
|
|
$(GOLANGCI_LINT) run \
|
|
|
|
--enable-all \
|
|
|
|
--disable gomnd \
|
|
|
|
--disable godox \
|
|
|
|
--disable exhaustivestruct \
|
|
|
|
--disable varnamelen \
|
|
|
|
--timeout 5m
|
|
|
|
|
|
|
|
.PHONY: tidy
|
|
|
|
tidy:
|
|
|
|
$(GO) mod tidy
|
|
|
|
$(GO) mod vendor
|