aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-11-29 03:19:44 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2017-11-29 04:52:14 +0100
commit6f8011804709004938a23017128533ab204d0e03 (patch)
treed689c97f2508aca3bb1fb7205a49c8ad6cbd61c9
parentstandalone: some people want to do things a la carte (diff)
downloadandroid_kernel_wireguard-6f8011804709004938a23017128533ab204d0e03.tar.xz
android_kernel_wireguard-6f8011804709004938a23017128533ab204d0e03.zip
standalone: use ndk properly
-rw-r--r--standalone/.gitignore3
-rw-r--r--standalone/Makefile24
-rw-r--r--standalone/README.md19
-rwxr-xr-xstandalone/build-wg.sh53
l---------standalone/wg-quick.bash1
5 files changed, 30 insertions, 70 deletions
diff --git a/standalone/.gitignore b/standalone/.gitignore
index 7f29ff5..1ab7ab1 100644
--- a/standalone/.gitignore
+++ b/standalone/.gitignore
@@ -1 +1,2 @@
-wg
+wg-build/
+*.tar.gz
diff --git a/standalone/Makefile b/standalone/Makefile
new file mode 100644
index 0000000..5c0bf62
--- /dev/null
+++ b/standalone/Makefile
@@ -0,0 +1,24 @@
+ARCHS := arm64-v8a armeabi armeabi-v7a mips mips64 x86 x86_64
+
+all: $(foreach ARCH,$(ARCHS),wg-tools-$(ARCH).tar.gz)
+
+clean:
+ rm -rf wg-build $(foreach ARCH,$(ARCHS),wg-tools-$(ARCH).tar.gz)
+
+wg:
+ rm -rf wg-build
+ mkdir -p wg-build
+ ndk-build NDK_PROJECT_PATH=$(PWD)/wg-build APP_BUILD_SCRIPT=$(PWD)/../Android.mk APP_PLATFORM=24
+
+define arch_rule
+wg-build/libs/$(1)/wg: wg
+wg-tools-$(1).tar.gz: wg-build/libs/$(1)/wg install.sh ../wg-quick.bash addonsd.sh
+ rm -f $$@
+ mkdir -p wg-build/libs/$(1)/wg-tools
+ ln -frst wg-build/libs/$(1)/wg-tools/ $$^
+ tar -chzf $$@ -C wg-build/libs/$(1) wg-tools
+endef
+$(foreach ARCH,$(ARCHS),$(eval $(call arch_rule,$(ARCH))))
+
+.PHONY: clean all
+.SECONDARY:
diff --git a/standalone/README.md b/standalone/README.md
index 87d7734..afd5a0f 100644
--- a/standalone/README.md
+++ b/standalone/README.md
@@ -1,20 +1,9 @@
# Standalone WireGuard Tools for Android
-This currently contains a version of wg-quick.bash that works with
-Android 7's `ndc` command. It requires the WireGuard module to be
-part of your kernel, but after that, the usual `wg-quick up` and
-`wg-quick down` commands work normally.
+This compiles and creates a tarball which you can use to install the
+WireGuard tools into an existing ROM via root.
## Installation
-Build a `wg` binary for Android using the `build-wg.sh` script.
-Then copy this folder some place on your phone, and run `sh ./install.sh`
-as root. It should survive ROM flashes.
-
-## Usage
-
-Compared to the ordinary wg-quick, this one does not support SaveConfig
-and {Pre,Post}{Up,Down}.
-
-Put your configuration files into `/data/misc/wireguard/`. After that,
-the normal `wg-quick up|down` commands will work.
+Type `make`, copy the resulting `.tar.gz` to your device, and as root,
+run `sh ./install.sh`. The installation should survive ROM reflashes.
diff --git a/standalone/build-wg.sh b/standalone/build-wg.sh
deleted file mode 100755
index d2bb5b1..0000000
--- a/standalone/build-wg.sh
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/bash
-
-set -e
-
-ARCH="arm64"
-ANDROID_PLATFORM="24"
-
-case "$ARCH" in
- arm) ANDROID_MACHINE="arm-linux-androideabi"; ;;
- arm64) ANDROID_MACHINE="aarch64-linux-android"; ;;
- mips) ANDROID_MACHINE="mipsel-linux-android"; ;;
- mips64) ANDROID_MACHINE="mips64el-linux-android"; ;;
- x86) ANDROID_MACHINE="x86-linux-android"; ;;
- x86_64) ANDROID_MACHINE="x86_64-linux-android"; ;;
- *) echo "Error: unknown architecture" >&2; exit 1; ;;
-esac
-
-GCC_VERSION="4.9"
-ANDROID_PLATFORM="/opt/android-ndk/platforms/android-$ANDROID_PLATFORM/arch-$ARCH/usr"
-ANDROID_TOOLCHAIN="/opt/android-ndk/toolchains/$ANDROID_MACHINE-$GCC_VERSION/prebuilt/linux-$(uname -m)/bin"
-
-export PATH="$ANDROID_TOOLCHAIN:$PATH"
-export CC="$ANDROID_MACHINE-gcc --sysroot $ANDROID_PLATFORM"
-export LD="$ANDROID_MACHINE-ld --sysroot $ANDROID_PLATFORM"
-export CFLAGS="-O3 -fomit-frame-pointer -I$ANDROID_PLATFORM/include -fPIE"
-export LDFLAGS="-pie"
-
-trap 'cd /; rm -rf "$where"' EXIT
-where="$(mktemp -d)"
-here="$PWD"
-cd "$where"
-
-. "$here/../fetch.sh"
-
-cd libmnl
-./configure --enable-static --disable-shared --host="$ANDROID_MACHINE"
-make -j$(nproc)
-
-cd ..
-
-cd wireguard/src/tools
-export CFLAGS="$CFLAGS -I../../../libmnl/include"
-export LDFLAGS="$LDFLAGS -L../../../libmnl/src/.libs"
-make -j$(nproc)
-"$ANDROID_MACHINE-strip" wg
-mv wg "$here/wg"
-
-echo
-echo
-echo ===============================================
-echo Build complete:
-ls -l "$here/wg"
-echo ===============================================
diff --git a/standalone/wg-quick.bash b/standalone/wg-quick.bash
deleted file mode 120000
index f4eca54..0000000
--- a/standalone/wg-quick.bash
+++ /dev/null
@@ -1 +0,0 @@
-../wg-quick.bash \ No newline at end of file