blob: ca5d9f08cfa2ea60d74fcd5e91367c94155a53fe (
plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
#!/bin/sh
#
F="configure-android"
if test "$*" = "--help" -o "$*" = "-h"; then
echo "$F [--use-ndk-cflags] [OPTIONS]"
echo ""
echo "where:"
echo " --use-ndk-cflags Optional parameter to use the same compilation flags"
echo " as the one used by ndk-build"
echo " OPTIONS Other options that will be passed directly to"
echo " ./aconfigure script. Run ./aconfigure --help"
echo " for more info."
echo ""
echo "Environment variables:"
echo " ANDROID_NDK_ROOT Specify the directory of Android NDK to use."
echo " APP_PLATFORM Optionally specify the platform level used, e.g."
echo " android-9. By default, configure will use the"
echo " maximum platform level detected."
echo " TARGET_ABI Optionally specify a single target architecture,"
echo " e.g. armeabi-v7a, mips, x86. By default, the target"
echo " architecture is armeabi. Only used when"
echo " --use-ndk-cflags is specified."
echo ""
exit 0
fi
if test "x${ANDROID_NDK_ROOT}" = "x"; then
echo "$F error: ANDROID_NDK_ROOT must be specified"
exit 0
fi
#if test "$1" = "--simulator"; then
if test "1" = "0"; then
shift
TARGET_HOST="i686-android-linux"
TC_DIR="x86"
else
TARGET_HOST="arm-linux-androideabi"
TC_DIR=${TARGET_HOST}
fi
if test "x$APP_PLATFORM" = "x"; then
APP_PLATFORM=`ls ${ANDROID_NDK_ROOT}/platforms/ | sed 's/android-//' | sort -gr | head -1`
APP_PLATFORM="android-${APP_PLATFORM}"
echo "$F: APP_PLATFORM not specified, using ${APP_PLATFORM}"
fi
if test "x$TARGET_ABI" = "x"; then
TARGET_ABI="armeabi"
echo "$F: TARGET_ABI not specified, using ${TARGET_ABI}"
fi
if test "$1" = "--use-ndk-cflags"; then
shift
ADD_CFLAGS="1"
for i in `${ANDROID_NDK_ROOT}/ndk-build -n -C ${ANDROID_NDK_ROOT}/samples/hello-jni NDK_LOG=1 APP_PLATFORM=${APP_PLATFORM} APP_ABI=${TARGET_ABI}`; do
if test "x${NDK_CXX}" != "x" -a "$i" = "-o"; then break; fi
# Parse NDK CXXFLAGS
if test "x${NDK_CXX}" != "x" -a "x`echo $i|grep 'hello-jni'`" = "x"; then
if test "x`echo $i|grep '\-\-sysroot='`" != "x"; then
ANDROID_SYSROOT=`echo $i|sed 's/--sysroot=//'`;
fi
NDK_CXXFLAGS="${NDK_CXXFLAGS} $i"
fi
# Parse NDK CFLAGS
if test "x${NDK_CC}" != "x" -a "x`echo $i|grep 'hello-jni'`" = "x" -a "x`echo $i|grep '\-M'`" = "x" -a "${ADD_CFLAGS}" = "1"; then
if test "$i" = "-c"; then ADD_CFLAGS="0"; else
NDK_CFLAGS="${NDK_CFLAGS} $i"
fi
fi
# Find gcc toolchain
if test "x${NDK_CC}" = "x" -a "x`echo $i | grep 'gcc'`" != "x"; then
NDK_CC=$i
fi
# Find g++ toolchain
if test "x`echo $i | grep 'g++'`" != "x"; then
NDK_CXX=$i
fi
done
export CC="${NDK_CC}"
export CXX="${NDK_CXX}"
export LDFLAGS="${LDFLAGS} -nostdlib -L${ANDROID_SYSROOT}/usr/lib/"
export LIBS="${LIBS} -lc -lgcc"
export CFLAGS="${CFLAGS} ${NDK_CFLAGS}"
export CPPFLAGS="${CFLAGS}"
export CXXFLAGS="${NDK_CXXFLAGS}"
else
ANDROID_TC_VER=`ls -d ${ANDROID_NDK_ROOT}/toolchains/${TC_DIR}-* | sed 's/clang/0/' | sort -gr | head -1`
ANDROID_TC=`ls -d ${ANDROID_TC_VER}/prebuilt/*`
if test ! -d ${ANDROID_TC}; then
echo "$F error: unable to find directory ${ANDROID_TC} in Android NDK"
exit 1
fi
export ANDROID_SYSROOT="${ANDROID_NDK_ROOT}/platforms/${APP_PLATFORM}/arch-arm"
if test ! -d ${ANDROID_SYSROOT}; then
echo "$F error: unable to find sysroot dir ${ANDROID_SYSROOT} in Android NDK"
exit 1
fi
export CC="${ANDROID_TC}/bin/${TARGET_HOST}-gcc"
export CXX="${ANDROID_TC}/bin/${TARGET_HOST}-g++"
export LDFLAGS="${LDFLAGS} -nostdlib -L${ANDROID_SYSROOT}/usr/lib/"
export LIBS="${LIBS} -lc -lgcc"
export CFLAGS="${CFLAGS} -I${ANDROID_SYSROOT}/usr/include"
export CPPFLAGS="${CFLAGS}"
export CXXFLAGS="${CXXFLAGS} -shared --sysroot=${ANDROID_SYSROOT}"
fi
# Print settings
if test "1" = "1"; then
echo "$F: calling ./configure with env vars:"
echo " CC = ${CC}"
echo " CXX = ${CXX}"
echo " CFLAGS = ${CFLAGS}"
echo " CXXFLAGS = ${CXXFLAGS}"
echo " LDFLAGS = ${LDFLAGS}"
echo " LIBS = ${LIBS}"
fi
./configure --host=${TARGET_HOST} --disable-video $*
|