Bubble android client. Fork of https://git.zx2c4.com/wireguard-android/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

50 line
2.0 KiB

  1. # SPDX-License-Identifier: Apache-2.0
  2. #
  3. # Copyright © 2017-2019 WireGuard LLC. All Rights Reserved.
  4. BUILDDIR ?= $(CURDIR)/build
  5. DESTDIR ?= $(CURDIR)/out
  6. NDK_GO_ARCH_MAP_x86 := 386
  7. NDK_GO_ARCH_MAP_x86_64 := amd64
  8. NDK_GO_ARCH_MAP_arm := arm
  9. NDK_GO_ARCH_MAP_arm64 := arm64
  10. NDK_GO_ARCH_MAP_mips := mipsx
  11. NDK_GO_ARCH_MAP_mips64 := mips64x
  12. CLANG_FLAGS := --target=$(ANDROID_LLVM_TRIPLE) --gcc-toolchain=$(ANDROID_TOOLCHAIN_ROOT) --sysroot=$(ANDROID_SYSROOT)
  13. export CGO_CFLAGS := $(CLANG_FLAGS) $(CFLAGS)
  14. export CGO_LDFLAGS := $(CLANG_FLAGS) $(LDFLAGS)
  15. export CC := $(ANDROID_C_COMPILER)
  16. export GOARCH := $(NDK_GO_ARCH_MAP_$(ANDROID_ARCH_NAME))
  17. export GOOS := android
  18. export CGO_ENABLED := 1
  19. default: $(DESTDIR)/libwg-go.so
  20. GOBUILDARCH := $(NDK_GO_ARCH_MAP_$(shell uname -m))
  21. GOBUILDOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
  22. GOBUILDVERSION := 1.12.10
  23. GOBUILDTARBALL := https://dl.google.com/go/go$(GOBUILDVERSION).$(GOBUILDOS)-$(GOBUILDARCH).tar.gz
  24. GOBUILDVERSION_NEEDED := go version go$(GOBUILDVERSION) $(GOBUILDOS)/$(GOBUILDARCH)
  25. export GOROOT := $(BUILDDIR)/goroot
  26. export GOPATH := $(BUILDDIR)/gopath
  27. export PATH := $(GOROOT)/bin:$(PATH)
  28. GOBUILDVERSION_CURRENT := $(shell $(GOROOT)/bin/go version 2>/dev/null)
  29. ifneq ($(GOBUILDVERSION_NEEDED),$(GOBUILDVERSION_CURRENT))
  30. $(shell rm -f $(GOROOT)/bin/go)
  31. endif
  32. $(GOROOT)/bin/go:
  33. rm -rf "$(GOROOT)"
  34. mkdir -p "$(GOROOT)"
  35. curl "$(GOBUILDTARBALL)" | tar -C "$(GOROOT)" --strip-components=1 -xzf - || { rm -rf "$(GOROOT)"; exit 1; }
  36. patch -p1 -f -N -r- -d "$(GOROOT)" < goruntime-boottime-over-monotonic.diff || { rm -rf "$(GOROOT)"; exit 1; }
  37. $(shell test "$$(cat $(BUILDDIR)/.gobuildversion 2>/dev/null)" = "$(GOBUILDVERSION_CURRENT)" || rm -f "$(DESTDIR)/libwg-go.so")
  38. $(DESTDIR)/libwg-go.so: $(GOROOT)/bin/go
  39. go get -tags linux || { chmod -fR +w "$(GOPATH)/pkg/mod"; rm -rf "$(GOPATH)/pkg/mod"; exit 1; }
  40. chmod -fR +w "$(GOPATH)/pkg/mod"
  41. go build -tags linux -ldflags="-X main.socketDirectory=/data/data/$(ANDROID_PACKAGE_NAME)/cache/wireguard" -v -o "$@" -buildmode c-shared
  42. go version > $(BUILDDIR)/.gobuildversion