diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-02 03:55:18 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-02 06:02:15 +0200 |
commit | a46b2eb9e5a593a952a5f81365086be022e72b20 (patch) | |
tree | d2b7c38f54ee92034e5f25d01ffa6853589666ae /app | |
parent | a77ff1627d653dec4153f5298a5d74b7c76887b2 (diff) |
libwg-go: avoid phony target and update go
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/tools/libwg-go/.gitignore | 1 | ||||
-rw-r--r-- | app/tools/libwg-go/Makefile | 24 |
2 files changed, 16 insertions, 9 deletions
diff --git a/app/tools/libwg-go/.gitignore b/app/tools/libwg-go/.gitignore index f24a1ad8..2a4c5348 100644 --- a/app/tools/libwg-go/.gitignore +++ b/app/tools/libwg-go/.gitignore @@ -4,3 +4,4 @@ libwg-go.h jni.o gopath/ goroot/ +.gobuildversion diff --git a/app/tools/libwg-go/Makefile b/app/tools/libwg-go/Makefile index d931c056..8c397bc2 100644 --- a/app/tools/libwg-go/Makefile +++ b/app/tools/libwg-go/Makefile @@ -22,28 +22,34 @@ default: $(DESTDIR)/libwg-go.so GOBUILDARCH := $(NDK_GO_ARCH_MAP_$(shell uname -m)) GOBUILDOS := $(shell uname -s | tr '[:upper:]' '[:lower:]') -GOBUILDVERSION := 1.10.1 +GOBUILDVERSION := 1.10.2 GOBUILDTARBALL := https://dl.google.com/go/go$(GOBUILDVERSION).$(GOBUILDOS)-$(GOBUILDARCH).tar.gz +GOBUILDVERSION_NEEDED := go version go$(GOBUILDVERSION) $(GOBUILDOS)/$(GOBUILDARCH) -ifeq (go version go$(GOBUILDVERSION) $(GOBUILDOS)/$(GOBUILDARCH),$(shell go version 2>/dev/null)) -ensure_go_exists: - @echo "Using system go" +GOBUILDVERSION_CURRENT := $(shell go version 2>/dev/null) +ifeq ($(GOBUILDVERSION_NEEDED),$(GOBUILDVERSION_CURRENT)) +$(info Using system go) else export GOROOT := $(CURDIR)/goroot export PATH := $(GOROOT)/bin:$(PATH) +GOBUILDVERSION_CURRENT := $(shell $(GOROOT)/bin/go version 2>/dev/null) +ifneq ($(GOBUILDVERSION_NEEDED),$(GOBUILDVERSION_CURRENT)) +$(shell rm -f $(GOROOT)/bin/go) +endif $(GOROOT)/bin/go: rm -rf "$(GOROOT)" mkdir -p "$(GOROOT)" - curl "$(GOBUILDTARBALL)" | tar -C "$(GOROOT)" --strip-components=1 -xzf - || rm -rf "$(GOROOT)" -ensure_go_exists: $(GOROOT)/bin/go + curl "$(GOBUILDTARBALL)" | tar -C "$(GOROOT)" --strip-components=1 -xzf - || { rm -rf "$(GOROOT)"; exit 1; } +$(DESTDIR)/libwg-go.so: $(GOROOT)/bin/go endif -$(DESTDIR)/libwg-go.so: $(FILES) api-android.go jni.c ensure_go_exists +$(shell test "$$(cat .gobuildversion 2>/dev/null)" = "$(GOBUILDVERSION_CURRENT)" || rm -f "$(DESTDIR)/libwg-go.so") + +$(DESTDIR)/libwg-go.so: $(FILES) api-android.go jni.c find . -name '*.go' -type l -delete find . -type d -empty -delete mkdir -p $(subst ../wireguard-go/,./,$(dir $(FILES))) $(foreach FILE,$(FILES),ln -sfrt $(subst ../wireguard-go/,./,$(dir $(FILE))) $(FILE);) go get -v -d go build -v -o $(DESTDIR)/libwg-go.so -buildmode c-shared - -.PHONY: ensure_go_exists + go version > .gobuildversion |