2018-05-15 00:15:16 +00:00
|
|
|
PREFIX ?= /usr
|
|
|
|
DESTDIR ?=
|
|
|
|
BINDIR ?= $(PREFIX)/bin
|
2018-10-11 23:45:33 +00:00
|
|
|
export GO111MODULE := on
|
2018-10-11 23:12:00 +00:00
|
|
|
|
2018-10-17 19:45:16 +00:00
|
|
|
all: generate-version-and-build
|
2018-05-15 00:15:16 +00:00
|
|
|
|
2018-10-11 23:12:00 +00:00
|
|
|
MAKEFLAGS += --no-print-directory
|
2018-05-23 01:17:51 +00:00
|
|
|
|
2018-10-11 23:12:00 +00:00
|
|
|
generate-version-and-build:
|
2018-05-23 23:52:22 +00:00
|
|
|
@export GIT_CEILING_DIRECTORIES="$(realpath $(CURDIR)/..)" && \
|
|
|
|
tag="$$(git describe --dirty 2>/dev/null)" && \
|
2021-05-07 10:56:10 +00:00
|
|
|
ver="$$(printf 'package main\n\nconst Version = "%s"\n' "$$tag")" && \
|
2021-01-28 16:23:39 +00:00
|
|
|
[ "$$(cat version.go 2>/dev/null)" != "$$ver" ] && \
|
|
|
|
echo "$$ver" > version.go && \
|
|
|
|
git update-index --assume-unchanged version.go || true
|
2018-10-11 23:12:00 +00:00
|
|
|
@$(MAKE) wireguard-go
|
2018-05-23 23:52:22 +00:00
|
|
|
|
2018-10-09 16:11:36 +00:00
|
|
|
wireguard-go: $(wildcard *.go) $(wildcard */*.go)
|
|
|
|
go build -v -o "$@"
|
2018-05-15 00:15:16 +00:00
|
|
|
|
|
|
|
install: wireguard-go
|
2018-10-09 16:11:36 +00:00
|
|
|
@install -v -d "$(DESTDIR)$(BINDIR)" && install -v -m 0755 "$<" "$(DESTDIR)$(BINDIR)/wireguard-go"
|
2017-06-28 21:45:45 +00:00
|
|
|
|
2020-07-15 14:22:18 +00:00
|
|
|
test:
|
2021-11-16 19:59:40 +00:00
|
|
|
go test ./...
|
2020-07-15 14:22:18 +00:00
|
|
|
|
2017-06-28 21:45:45 +00:00
|
|
|
clean:
|
2017-08-01 12:41:32 +00:00
|
|
|
rm -f wireguard-go
|
2017-06-28 21:45:45 +00:00
|
|
|
|
2020-07-15 14:22:18 +00:00
|
|
|
.PHONY: all clean test install generate-version-and-build
|