diff options
Diffstat (limited to 'app/tools')
-rw-r--r-- | app/tools/libwg-go/Makefile | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/app/tools/libwg-go/Makefile b/app/tools/libwg-go/Makefile index 43af1439..d931c056 100644 --- a/app/tools/libwg-go/Makefile +++ b/app/tools/libwg-go/Makefile @@ -10,8 +10,6 @@ NDK_GO_ARCH_MAP_mips := mipsx NDK_GO_ARCH_MAP_mips64 := mips64x export GOPATH := $(CURDIR)/gopath -export GOROOT := $(CURDIR)/goroot -export PATH := $(GOROOT)/bin:$(PATH) CLANG_FLAGS := --target=$(ANDROID_LLVM_TRIPLE) --gcc-toolchain=$(ANDROID_TOOLCHAIN_ROOT) --sysroot=$(ANDROID_SYSROOT) export CGO_CFLAGS := $(CLANG_FLAGS) $(CFLAGS) export CGO_LDFLAGS := $(CLANG_FLAGS) $(LDFLAGS) @@ -20,20 +18,32 @@ export GOARCH := $(NDK_GO_ARCH_MAP_$(ANDROID_ARCH_NAME)) export GOOS := android export CGO_ENABLED := 1 -GORELEASEVERSION := 1.10.1 -GORELEASETARBALL := https://dl.google.com/go/go$(GORELEASEVERSION).$(shell uname -s | tr '[:upper:]' '[:lower:]')-$(NDK_GO_ARCH_MAP_$(shell uname -m)).tar.gz - default: $(DESTDIR)/libwg-go.so +GOBUILDARCH := $(NDK_GO_ARCH_MAP_$(shell uname -m)) +GOBUILDOS := $(shell uname -s | tr '[:upper:]' '[:lower:]') +GOBUILDVERSION := 1.10.1 +GOBUILDTARBALL := https://dl.google.com/go/go$(GOBUILDVERSION).$(GOBUILDOS)-$(GOBUILDARCH).tar.gz + +ifeq (go version go$(GOBUILDVERSION) $(GOBUILDOS)/$(GOBUILDARCH),$(shell go version 2>/dev/null)) +ensure_go_exists: + @echo "Using system go" +else +export GOROOT := $(CURDIR)/goroot +export PATH := $(GOROOT)/bin:$(PATH) $(GOROOT)/bin/go: rm -rf "$(GOROOT)" mkdir -p "$(GOROOT)" - curl "$(GORELEASETARBALL)" | tar -C "$(GOROOT)" --strip-components=1 -xzf - || rm -rf "$(GOROOT)" + curl "$(GOBUILDTARBALL)" | tar -C "$(GOROOT)" --strip-components=1 -xzf - || rm -rf "$(GOROOT)" +ensure_go_exists: $(GOROOT)/bin/go +endif -$(DESTDIR)/libwg-go.so: $(FILES) api-android.go jni.c $(GOROOT)/bin/go +$(DESTDIR)/libwg-go.so: $(FILES) api-android.go jni.c ensure_go_exists 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 |