Add support for Android L

Build position-indepent executables, required for Android L (5.0+)
They also work with kitkat.

Add new maketarget "cross-android-old" that builds without PIE
for older versions.

Include both new and old versions in latest-android.zip. Add arm64.

Hopefully solves github PR #14.
This commit is contained in:
Erik Ekman 2015-08-05 19:33:50 +02:00
parent d8bf5cc85b
commit c269a00344
6 changed files with 46 additions and 11 deletions

View File

@ -56,15 +56,32 @@ iodine-latest:
@for i in README.md CHANGELOG TODO; do cp $$i iodine-latest/$$i.txt; done @for i in README.md CHANGELOG TODO; do cp $$i iodine-latest/$$i.txt; done
@unix2dos iodine-latest/* @unix2dos iodine-latest/*
#non-PIE build for old android
cross-android-old:
@(cd src; $(MAKE) base64u.c base64u.h)
@(cd src; ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk MY_PLATFORM=old)
#Position-indepedent build for modern android
cross-android: cross-android:
@(cd src; $(MAKE) base64u.c base64u.h) @(cd src; $(MAKE) base64u.c base64u.h)
@(cd src; ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk) @(cd src; ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk MY_PLATFORM=kitkat)
iodine-latest-android.zip: iodine-latest iodine-latest-android.zip: iodine-latest
@mv iodine-latest iodine-latest-android @mv iodine-latest iodine-latest-android
@mkdir -p iodine-latest-android/armeabi iodine-latest-android/x86 @mkdir -p iodine-latest-android/pre-kitkat/armeabi
@mkdir -p iodine-latest-android/pre-kitkat/x86
@$(MAKE) cross-android-old TARGET_ARCH_ABI=armeabi
@cp src/libs/armeabi/* iodine-latest-android/pre-kitkat/armeabi
@$(MAKE) cross-android-old TARGET_ARCH_ABI=x86
@cp src/libs/x86/* iodine-latest-android/pre-kitkat/x86
@rm -rf src/libs src/obj
@mkdir -p iodine-latest-android/armeabi
@mkdir -p iodine-latest-android/arm64-v8a
@mkdir -p iodine-latest-android/x86
@$(MAKE) cross-android TARGET_ARCH_ABI=armeabi @$(MAKE) cross-android TARGET_ARCH_ABI=armeabi
@cp src/libs/armeabi/* iodine-latest-android/armeabi @cp src/libs/armeabi/* iodine-latest-android/armeabi
@$(MAKE) cross-android TARGET_ARCH_ABI=arm64-v8a
@cp src/libs/arm64-v8a/* iodine-latest-android/arm64-v8a
@$(MAKE) cross-android TARGET_ARCH_ABI=x86 @$(MAKE) cross-android TARGET_ARCH_ABI=x86
@cp src/libs/x86/* iodine-latest-android/x86 @cp src/libs/x86/* iodine-latest-android/x86
@cp README-android.txt iodine-latest-android @cp README-android.txt iodine-latest-android

View File

@ -13,7 +13,7 @@ Extra README file for Android
2. Find/build a compatible tun.ko for your specific Android kernel 2. Find/build a compatible tun.ko for your specific Android kernel
3. Copy tun.ko and the iodine binary to your device: 3. Copy tun.ko and the iodine binary to your device:
(Almost all devices need the armeabi binary. Only Intel powered (Almost all devices need the armeabi binary. Only Intel powered
ones need the x86 build.) ones need the x86 build.)
adb push tun.ko /data/local/tmp adb push tun.ko /data/local/tmp
@ -35,11 +35,15 @@ For more information: http://blog.bokhorst.biz/5123
2. Download and unpack the iodine sources 2. Download and unpack the iodine sources
3. Build: 3. Build:
cd src cd src
make base64u.h base64u.c make base64u.h base64u.c
ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk MY_PLATFORM=kitkat
or run "make cross-android" in the iodine root directory. or run "make cross-android" in the iodine root directory.
To build for other archs, specify TARGET_ARCH_ABI: To build for other archs, specify TARGET_ARCH_ABI:
"make cross-android TARGET_ARCH_ABI=x86" "make cross-android TARGET_ARCH_ABI=x86"
For older android versions (pre-kitkat), build with "make cross-android" in the
root directory, or manually like above but without the MY_PLATFORM part.
The iodine binary ends up in src/libs/<arch>/iodine

View File

@ -20,5 +20,14 @@ LOCAL_SRC_FILES := tun.c dns.c read.c encoding.c login.c base32.c base64.c base6
LOCAL_CFLAGS := -c -DANDROID -DLINUX -DIFCONFIGPATH=\"/system/bin/\" -Wall -DGITREVISION=\"$(HEAD_COMMIT)\" LOCAL_CFLAGS := -c -DANDROID -DLINUX -DIFCONFIGPATH=\"/system/bin/\" -Wall -DGITREVISION=\"$(HEAD_COMMIT)\"
LOCAL_LDLIBS := -lz LOCAL_LDLIBS := -lz
#Choose platform level (for PIE support)
ifeq (kitkat, $(strip $(MY_PLATFORM)))
APP_PLATFORM := android-16
LOCAL_CFLAGS += -fPIE
LOCAL_LDFLAGS += -fPIE -pie
else
APP_PLATFORM := android-3
endif
include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE)

View File

@ -17,6 +17,9 @@
#ifndef __FIX_ANDROID_H__ #ifndef __FIX_ANDROID_H__
#define __FIX_ANDROID_H__ #define __FIX_ANDROID_H__
/* Newer android platforms can have this data already */
#ifndef C_IN
typedef struct { typedef struct {
unsigned id :16; unsigned id :16;
unsigned rd :1; unsigned rd :1;
@ -51,4 +54,6 @@ typedef struct {
#define T_TXT 16 #define T_TXT 16
#define T_SRV 33 #define T_SRV 33
#endif /* !C_IN */
#endif #endif

View File

@ -32,10 +32,10 @@
#ifdef WINDOWS32 #ifdef WINDOWS32
#include "windows.h" #include "windows.h"
#else #else
#include <arpa/nameser.h>
#ifdef ANDROID #ifdef ANDROID
#include "android_dns.h" #include "android_dns.h"
#endif #endif
#include <arpa/nameser.h>
#ifdef DARWIN #ifdef DARWIN
#define BIND_8_COMPAT #define BIND_8_COMPAT
#include <arpa/nameser_compat.h> #include <arpa/nameser_compat.h>

View File

@ -27,9 +27,6 @@
#ifdef WINDOWS32 #ifdef WINDOWS32
#include "windows.h" #include "windows.h"
#else #else
#ifdef ANDROID
#include "android_dns.h"
#endif
#include <arpa/nameser.h> #include <arpa/nameser.h>
#ifdef DARWIN #ifdef DARWIN
#define BIND_8_COMPAT #define BIND_8_COMPAT
@ -38,6 +35,9 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <err.h> #include <err.h>
#ifdef ANDROID
#include "android_dns.h"
#endif
#endif #endif