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.

Makefile 2.2 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. containing = $(foreach v,$2,$(if $(findstring $1,$v),$v))
  2. FILES := $(wildcard ../wireguard-go/*/*.go) $(wildcard ../wireguard-go/*.go)
  3. FILES := $(filter-out %/main.go $(filter-out %_linux.go,$(call containing,_,$(FILES))),$(FILES))
  4. NDK_GO_ARCH_MAP_x86 := 386
  5. NDK_GO_ARCH_MAP_x86_64 := amd64
  6. NDK_GO_ARCH_MAP_arm := arm
  7. NDK_GO_ARCH_MAP_arm64 := arm64
  8. NDK_GO_ARCH_MAP_mips := mipsx
  9. NDK_GO_ARCH_MAP_mips64 := mips64x
  10. export GOPATH := $(CURDIR)/gopath
  11. CLANG_FLAGS := --target=$(ANDROID_LLVM_TRIPLE) --gcc-toolchain=$(ANDROID_TOOLCHAIN_ROOT) --sysroot=$(ANDROID_SYSROOT)
  12. export CGO_CFLAGS := $(CLANG_FLAGS) $(CFLAGS)
  13. export CGO_LDFLAGS := $(CLANG_FLAGS) $(LDFLAGS)
  14. export CC := $(ANDROID_C_COMPILER)
  15. export GOARCH := $(NDK_GO_ARCH_MAP_$(ANDROID_ARCH_NAME))
  16. export GOOS := android
  17. export CGO_ENABLED := 1
  18. default: $(DESTDIR)/libwg-go.so
  19. GOBUILDARCH := $(NDK_GO_ARCH_MAP_$(shell uname -m))
  20. GOBUILDOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
  21. GOBUILDVERSION := 1.10.2
  22. GOBUILDTARBALL := https://dl.google.com/go/go$(GOBUILDVERSION).$(GOBUILDOS)-$(GOBUILDARCH).tar.gz
  23. GOBUILDVERSION_NEEDED := go version go$(GOBUILDVERSION) $(GOBUILDOS)/$(GOBUILDARCH)
  24. GOBUILDVERSION_CURRENT := $(shell go version 2>/dev/null)
  25. ifeq ($(GOBUILDVERSION_NEEDED),$(GOBUILDVERSION_CURRENT))
  26. $(info Using system go)
  27. else
  28. export GOROOT := $(CURDIR)/goroot
  29. export PATH := $(GOROOT)/bin:$(PATH)
  30. GOBUILDVERSION_CURRENT := $(shell $(GOROOT)/bin/go version 2>/dev/null)
  31. ifneq ($(GOBUILDVERSION_NEEDED),$(GOBUILDVERSION_CURRENT))
  32. $(shell rm -f $(GOROOT)/bin/go)
  33. endif
  34. $(GOROOT)/bin/go:
  35. rm -rf "$(GOROOT)"
  36. mkdir -p "$(GOROOT)"
  37. curl "$(GOBUILDTARBALL)" | tar -C "$(GOROOT)" --strip-components=1 -xzf - || { rm -rf "$(GOROOT)"; exit 1; }
  38. $(DESTDIR)/libwg-go.so: $(GOROOT)/bin/go
  39. endif
  40. $(shell test "$$(cat .gobuildversion 2>/dev/null)" = "$(GOBUILDVERSION_CURRENT)" || rm -f "$(DESTDIR)/libwg-go.so")
  41. $(DESTDIR)/libwg-go.so: $(FILES) api-android.go jni.c
  42. find . -name '*.go' -type l -delete
  43. find . -type d -empty -delete
  44. mkdir -p $(subst ../wireguard-go/,./,$(dir $(FILES)))
  45. $(foreach FILE,$(FILES),ln -sfrt $(subst ../wireguard-go/,./,$(dir $(FILE))) $(FILE);)
  46. go get -v -d
  47. go build -v -o $(DESTDIR)/libwg-go.so -buildmode c-shared
  48. go version > .gobuildversion