aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-05-24 01:52:22 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-05-24 02:25:36 +0200
commit4a9de3218e6445742f29fef06f8b2f1dcef6306f (patch)
tree0c5ed4576b7d59c696f567530f6b7cb96f56f490 /Makefile
parentEye before ee except after see (diff)
downloadwireguard-go-4a9de3218e6445742f29fef06f8b2f1dcef6306f.tar.xz
wireguard-go-4a9de3218e6445742f29fef06f8b2f1dcef6306f.zip
Add undocumented --version flag
Diffstat (limited to '')
-rw-r--r--Makefile12
1 files changed, 10 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 4cba1de..93874e9 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,14 @@ export GOPATH := $(CURDIR)/.gopath
export PATH := $(PATH):$(CURDIR)/.gopath/bin
GO_IMPORT_PATH := git.zx2c4.com/wireguard-go
+version.go:
+ @export GIT_CEILING_DIRECTORIES="$(realpath $(CURDIR)/..)" && \
+ tag="$$(git describe --dirty 2>/dev/null)" && \
+ ver="$$(printf 'package main\nconst WireGuardGoVersion = "%s"\n' "$$tag")" && \
+ [ "$$(cat $@ 2>/dev/null)" != "$$ver" ] && \
+ echo "$$ver" > $@ && \
+ git update-index --assume-unchanged $@ || true
+
.gopath/.created:
rm -rf .gopath
mkdir -p $(dir .gopath/src/$(GO_IMPORT_PATH))
@@ -27,7 +35,7 @@ vendor/.created: Gopkg.toml Gopkg.lock | .gopath/.created
cd .gopath/src/$(GO_IMPORT_PATH) && dep ensure -vendor-only -v
touch $@
-wireguard-go: $(wildcard *.go) $(wildcard */*.go) .gopath/.created vendor/.created
+wireguard-go: $(wildcard *.go) $(wildcard */*.go) .gopath/.created vendor/.created version.go
go build $(GO_BUILD_EXTRA_ARGS) -v $(GO_IMPORT_PATH)
install: wireguard-go
@@ -40,4 +48,4 @@ update-dep: | .gopath/.created
command -v dep >/dev/null || go get -v github.com/golang/dep/cmd/dep
cd .gopath/src/$(GO_IMPORT_PATH) && dep ensure -update -v
-.PHONY: clean install update-dep
+.PHONY: clean install update-dep version.go