aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk14
-rwxr-xr-xversion-check.sh6
2 files changed, 20 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk
index 953bece..d3ad721 100644
--- a/Android.mk
+++ b/Android.mk
@@ -4,10 +4,24 @@ fetch:
cd $(WIREGUARD_PATH) && ./fetch.sh
TARGET_KERNEL_BINARIES: patch-wireguard
+ifeq ($(shell $(WIREGUARD_PATH)/version-check.sh "$(TARGET_KERNEL_SOURCE)" && echo compatible),compatible)
patch-wireguard: fetch
ln -vsfT "$$(realpath --relative-to="$(TARGET_KERNEL_SOURCE)/net)" "$(WIREGUARD_PATH)/wireguard/src" || readlink -f "$(WIREGUARD_PATH)/wireguard/src")" "$(TARGET_KERNEL_SOURCE)/net/wireguard"
grep -q wireguard "$(TARGET_KERNEL_SOURCE)/net/Makefile" || sed -i "/^obj-\\\$$(CONFIG_NETFILTER).*+=/a obj-\$$(CONFIG_WIREGUARD) += wireguard/" "$(TARGET_KERNEL_SOURCE)/net/Makefile"
grep -q wireguard "$(TARGET_KERNEL_SOURCE)/net/Kconfig" || sed -i "/^if INET\$$/a source \"net/wireguard/Kconfig\"" "$(TARGET_KERNEL_SOURCE)/net/Kconfig"
+else
+patch-wireguard:
+ @echo -e "\e[1;37;41m=================================================\e[0m" >&2
+ @echo -e "\e[1;37;41m+ WARNING WARNING WARNING +\e[0m" >&2
+ @echo -e "\e[1;37;41m+ +\e[0m" >&2
+ @echo -e "\e[1;37;41m+ You are trying to build WireGuard into a +\e[0m" >&2
+ @echo -e "\e[1;37;41m+ kernel that is too old to run it. Please use +\e[0m" >&2
+ @echo -e "\e[1;37;41m+ kernel >=3.10. This build will NOT have +\e[0m" >&2
+ @echo -e "\e[1;37;41m+ WireGuard. You likely added this to your +\e[0m" >&2
+ @echo -e "\e[1;37;41m+ local_manifest.xml without understanding this +\e[0m" >&2
+ @echo -e "\e[1;37;41m+ requirement. Sorry for the inconvenience. +\e[0m" >&2
+ @echo -e "\e[1;37;41m=================================================\e[0m" >&2
+endif
.PHONY: patch-wireguard fetch
diff --git a/version-check.sh b/version-check.sh
new file mode 100755
index 0000000..a85f023
--- /dev/null
+++ b/version-check.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+set -e
+[[ -n $1 && -f $1/Makefile ]]
+[[ $(< "$1/Makefile") =~ VERSION[[:space:]]*=[[:space:]]*([0-9]+).*PATCHLEVEL[[:space:]]*=[[:space:]]*([0-9]+).*SUBLEVEL[[:space:]]*=[[:space:]]*([0-9]+) ]]
+LINUX_VERSION_CODE=$(( (${BASH_REMATCH[1]} << 16) | (${BASH_REMATCH[2]} << 8) | ${BASH_REMATCH[3]} ))
+(( LINUX_VERSION_CODE >= ((3 << 16) | (10 << 8) | 0) ))