A way to run GNU autoconf configure
scripts using the Android NDK platform headers and libraries, improving on this:
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
|
#!/bin/bash
#
# Go to the directory containing the configure script.
#
# Then just run something like:
#
EXAMPLE="~/android-ndk-r9 ./ndk-configure.sh android-9 arch-arm"
if [ -z "${NDK}" ]; then
echo "Need to specify NDK environment variable when calling."
echo " -- e.g. ${EXAMPLE}"
exit 1
fi
if [ "$#" -lt "2" ]; then
echo "Usage: ./ndk-configure.sh <platform> <architecture>"
echo " -- e.g. ${EXAMPLE}"
exit 1
else
PLATFORM=$1
shift
ARCHITECTURE=$1
shift
if [ -x "config.guess" ]; then
wget --output-file=config.guess http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
fi
if [ -x "config.sub" ]; then
wget --output-file=config.sub http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
fi
COMPILER_VERSION="4.8"
export NDK_TOOLCHAIN=${NDK}/toolchains/arm-linux-androideabi-${COMPILER_VERSION}/prebuilt/linux-x86_64/bin
export CROSS_COMPILE=arm-linux-androideabi
export AR=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-ar
export CC=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-gcc
export CXX=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-g++
export CXXCPP=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-cpp
export LD=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-ld
export NM=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-nm
export OBJDUMP=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-objdump
export RANLIB=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-ranlib
export STRIP=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-strip
export SYSROOT=${NDK}/platforms/${PLATFORM}/${ARCHITECTURE} # Needed for the Android-specific headers and libs.
export CXX_SYSROOT=${NDK}/sources/cxx-stl/gnu-libstdc++/${COMPILER_VERSION} # Needed for the STL headers and libs.
export CXX_BITS_INCLUDE=${CXX_SYSROOT}/libs/armeabi/include # Needed for the <bits/c++config.h> and other headers.
# Certain STL classes, like <unordered_map> won't be
# usable otherwise.
export CPPFLAGS="-I${SYSROOT}/usr/include"
export CFLAGS="--sysroot=${SYSROOT}"
export CXXFLAGS="--std=c++11 --sysroot=${SYSROOT} -I${CXX_SYSROOT}/include -I${CXX_BITS_INCLUDE}"
export LIBS="-lc"
export LDFLAGS="-Wl,-rpath-link=${SYSROOT}/usr/lib -L${SYSROOT}/usr/lib -L${CXX_SYSROOT}/lib"
export ac_cv_func_malloc_0_nonnull=yes
export ac_cv_func_realloc_0_nonnull=yes
MACHINE=$( ${CXX} -dumpmachine )
echo "Machine: ${MACHINE}"
echo "Sysroot (Android): ${SYSROOT}"
echo "Sysroot (cxx): ${CXX_SYSROOT}"
echo "Bits include: ${CXX_BITS_INCLUDE}"
argString=""
while [ "$1" != "" ]; do
argString="${argString} $1"
shift
done
./configure --host="${MACHINE}" --target="${MACHINE}" --with-sysroot="${SYSROOT}" $argString
fi
|
References
1. http://stackoverflow.com/questions/5908581/is-hash-map-part-of-the-stl
2. http://protobuf.googlecode.com/svn/trunk/m4/stl_hash.m4
3. http://stackoverflow.com/questions/9201521/g-4-6-issue-no-bits-cconfig-h-file-as-required-by-the-header-cstring