This repository has been archived by the owner on Mar 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcross-android
executable file
·60 lines (50 loc) · 1.65 KB
/
cross-android
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
set -e
if [ $# -lt 1 ]; then
echo "$0 x86|x86_64|armeabi-v7a|arm64-v8a [.../]configure [args...]" 1>&2
exit 1
fi
if [ "$ANDROID_NDK_ROOT" = "" ]; then
echo "FATAL: You must export ANDROID_NDK_ROOT" 1>&2
exit 1
fi
architecture=$1
shift
if [ "$architecture" = "x86" ]; then
tool_prefix=i686-linux-android
compiler_prefix=${tool_prefix}16
configureflags="--host=$tool_prefix"
elif [ "$architecture" = "x86_64" ]; then
tool_prefix=x86_64-linux-android
compiler_prefix=${tool_prefix}21
configureflags="--host=$tool_prefix"
elif [ "$architecture" = "armeabi-v7a" ]; then
# There is some inconsistency in tool names
tool_prefix=arm-linux-androideabi
compiler_prefix=armv7a-linux-androideabi16
extraflags="-mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb"
configureflags="--host=$compiler_prefix"
elif [ "$architecture" = "arm64-v8a" ]; then
tool_prefix=aarch64-linux-android
compiler_prefix=${tool_prefix}21
configureflags="--host=$tool_prefix"
else
echo "$0: unsupported architecture: $architecture" 1>&2
exit 1
fi
sysname="`uname -s|tr [A-Z] [a-z]`-`uname -m`"
bindir="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$sysname/bin"
set -x
export AR="$bindir/$tool_prefix-ar"
export AS="$bindir/$tool_prefix-as"
export CC="$bindir/$compiler_prefix-clang"
export CFLAGS="-O2 -fPIC $extraflags $CFLAGS"
export CPP="$bindir/$compiler_prefix-clang -E"
export CPPFLAGS="$CPPFLAGS"
export CXX="$bindir/$compiler_prefix-clang++"
export CXXFLAGS="-O2 -fPIC $extraflags $CXXFLAGS"
export LD="$bindir/$tool_prefix-ld"
export NM="$bindir/$tool_prefix-nm"
export RANLIB="$bindir/$tool_prefix-ranlib"
export STRIP="$bindir/$tool_prefix-strip"
$@ $configureflags