2018-07-06 04:09:48 +02:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2018-05-02 21:40:01 +02:00
|
|
|
#
|
2019-01-02 01:57:15 +01:00
|
|
|
# Copyright © 2017-2019 WireGuard LLC. All Rights Reserved.
|
2018-05-02 21:40:01 +02:00
|
|
|
|
2018-10-09 18:26:21 +02:00
|
|
|
BUILDDIR ?= $(CURDIR)/build
|
|
|
|
DESTDIR ?= $(CURDIR)/out
|
2018-02-07 19:19:20 +01:00
|
|
|
|
2018-04-25 14:36:33 +02:00
|
|
|
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
|
|
|
|
|
2018-02-07 19:19:20 +01:00
|
|
|
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)
|
2018-04-25 14:36:33 +02:00
|
|
|
export GOARCH := $(NDK_GO_ARCH_MAP_$(ANDROID_ARCH_NAME))
|
2018-02-07 19:19:20 +01:00
|
|
|
export GOOS := android
|
|
|
|
export CGO_ENABLED := 1
|
|
|
|
|
2020-03-22 08:07:20 +01:00
|
|
|
DESIRED_GO_VERSION := 1.14.1
|
2018-04-24 15:19:53 +02:00
|
|
|
|
2019-10-12 11:43:16 +02:00
|
|
|
default: $(DESTDIR)/libwg-go.so
|
2018-04-24 15:19:53 +02:00
|
|
|
|
2019-10-12 11:43:16 +02:00
|
|
|
$(BUILDDIR)/go-$(DESIRED_GO_VERSION)/.prepared:
|
|
|
|
mkdir -p "$(dir $@)"
|
|
|
|
curl "https://dl.google.com/go/go$(DESIRED_GO_VERSION).$(shell uname -s | tr '[:upper:]' '[:lower:]')-$(NDK_GO_ARCH_MAP_$(shell uname -m)).tar.gz" | tar -C "$(dir $@)" --strip-components=1 -xzf -
|
|
|
|
patch -p1 -f -N -r- -d "$(dir $@)" < goruntime-boottime-over-monotonic.diff
|
|
|
|
touch "$@"
|
2018-10-09 18:26:21 +02:00
|
|
|
|
2019-10-12 11:43:16 +02:00
|
|
|
$(DESTDIR)/libwg-go.so: export PATH := $(BUILDDIR)/go-$(DESIRED_GO_VERSION)/bin/:$(PATH)
|
|
|
|
$(DESTDIR)/libwg-go.so: $(BUILDDIR)/go-$(DESIRED_GO_VERSION)/.prepared go.mod
|
2019-10-13 10:47:44 +02:00
|
|
|
go build -tags linux -ldflags="-X golang.zx2c4.com/wireguard/ipc.socketDirectory=/data/data/$(ANDROID_PACKAGE_NAME)/cache/wireguard" -v -trimpath -o "$@" -buildmode c-shared
|