summaryrefslogtreecommitdiffhomepage
path: root/app/tools/libwg-go/Makefile
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-02-07 19:19:20 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2018-02-17 21:14:09 +0100
commit0ea6f73332cf48374b8a98b16d68e25217ebf068 (patch)
tree53694268b30823c8973d6ae280ed766f4b44b974 /app/tools/libwg-go/Makefile
parentb923f7bc57c39687bed225badeac0b35a7dee855 (diff)
GoBackend: integrate into app
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/tools/libwg-go/Makefile')
-rw-r--r--app/tools/libwg-go/Makefile21
1 files changed, 21 insertions, 0 deletions
diff --git a/app/tools/libwg-go/Makefile b/app/tools/libwg-go/Makefile
new file mode 100644
index 00000000..300b3841
--- /dev/null
+++ b/app/tools/libwg-go/Makefile
@@ -0,0 +1,21 @@
+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))
+
+export GOPATH := $(CURDIR)/go
+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)
+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 GOOS := android
+export CGO_ENABLED := 1
+
+$(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