blob: d0e28eef8771ac258241cbbaedce9749f1f15c81 [file] [log] [blame]
sewardj37ed97b2011-07-12 13:34:31 +00001
2How to cross-compile for Android.
3
4This is known to work at least for Android 3.0 running on a Motorola
5Xoom. Other configurations and toolchains might work, but haven't
6been tested. Feedback is welcome.
7
8You need the android-ndk-r5c native development kit. Install it
9somewhere. Then do this:
10
11# Maybe not all of these are necessary -- I'm just being cautious.
12#
13export AR=/path/to/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar
14export CPP=/path/to/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-cpp
15export LD=/path/to/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ld
16export CXX=/path/to/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++
17export CC=/path/to/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc
18
19# Configure. This will build a Valgrind that needs to go in
20# /data/local/Inst on the device and that uses /data/local/tmp
21# as the tmp dir on the device. This means it can operate on
22# non-rooted (production) devices.
23#
24
25cd trunk
26./autogen.sh
27
28CPPFLAGS="--sysroot=/path/to/android-ndk-r5c/platforms/android-3/arch-arm" \
29 CFLAGS="--sysroot=/path/to/android-ndk-r5c/platforms/android-3/arch-arm" \
30 ./configure --prefix=/data/local/Inst \
31 --host=armv7-unknown-linux --target=armv7-unknown-linux \
32 --with-tmpdir=/data/local/tmp
33
34
35# At the end of the configure run, a few lines of details
36# are printed. Make sure that you see these two lines:
37#
38# Platform variant: android
39# Primary -DVGPV string: -DVGPV_arm_linux_android=1
40#
41# If you see anything else at this point, something is wrong, and
42# either the build will fail, or will succeed but you'll get something
43# which won't work.
44
45
46# Build, and park the install tree in `pwd`/Inst
47make
48make install DESTDIR=`pwd`/Inst
49
50
51# To get the install tree onto the device:
52# (I don't know why it's not "adb push Inst /data/local", but this
53# formulation does appear to put the result in /data/local/Inst.)
54#
55adb push Inst /
56
57# To run (on the device)
58/data/local/Bin/valgrind [the usual args etc]