From 86ffb2474883642c3f95698d47acea32458247e0 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 25 Apr 2018 14:36:33 +0200 Subject: [PATCH] Use variable map instead of shell switch Signed-off-by: Jason A. Donenfeld --- app/tools/libwg-go/Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/tools/libwg-go/Makefile b/app/tools/libwg-go/Makefile index c54797c7..43af1439 100644 --- a/app/tools/libwg-go/Makefile +++ b/app/tools/libwg-go/Makefile @@ -2,6 +2,13 @@ containing = $(foreach v,$2,$(if $(findstring $1,$v),$v)) FILES := $(wildcard ../wireguard-go/*/*.go) $(wildcard ../wireguard-go/*.go) FILES := $(filter-out %/main.go $(filter-out %_linux.go,$(call containing,_,$(FILES))),$(FILES)) +NDK_GO_ARCH_MAP_x86 := 386 +NDK_GO_ARCH_MAP_x86_64 := amd64 +NDK_GO_ARCH_MAP_arm := arm +NDK_GO_ARCH_MAP_arm64 := arm64 +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) @@ -9,12 +16,12 @@ CLANG_FLAGS := --target=$(ANDROID_LLVM_TRIPLE) --gcc-toolchain=$(ANDROID_TOOLCHA export CGO_CFLAGS := $(CLANG_FLAGS) $(CFLAGS) export CGO_LDFLAGS := $(CLANG_FLAGS) $(LDFLAGS) export CC := $(ANDROID_C_COMPILER) -GO_ARCH_FILTER := case "$(ANDROID_ARCH_NAME)" in x86) echo 386 ;; x86_64) echo amd64 ;; *) echo $(ANDROID_ARCH_NAME) ;; esac -export GOARCH := $(shell $(GO_ARCH_FILTER)) +export GOARCH := $(NDK_GO_ARCH_MAP_$(ANDROID_ARCH_NAME)) export GOOS := android export CGO_ENABLED := 1 -GORELEASETARBALL := https://dl.google.com/go/go1.10.1.$(shell uname -s | tr '[:upper:]' '[:lower:]')-amd64.tar.gz +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