blob: e86c9fe41b716eff63ad7f31dec452df4ccf9cd2 [file] [log] [blame]
sewardj37ed97b2011-07-12 13:34:31 +00001
2How to cross-compile for Android.
3
sewardja0b4dbc2011-09-10 11:28:51 +00004This is known to work at least for Android 2.3.4 running on a (rooted,
5AOSP build) Nexus S. It has also worked in the past on a
6un-messed-with Motorola Xoom, although I haven't tested it recently.
7Other configurations and toolchains might work, but haven't been
8tested. Feedback is welcome.
sewardj37ed97b2011-07-12 13:34:31 +00009
sewardja0b4dbc2011-09-10 11:28:51 +000010You need the android-ndk-r6 native development kit. Install it
sewardj37ed97b2011-07-12 13:34:31 +000011somewhere. Then do this:
12
sewardj37ed97b2011-07-12 13:34:31 +000013
sewardja0b4dbc2011-09-10 11:28:51 +000014# Modify this (obviously).
sewardj37ed97b2011-07-12 13:34:31 +000015#
sewardja0b4dbc2011-09-10 11:28:51 +000016export NDKROOT=/path/to/android-ndk-r6
sewardj37ed97b2011-07-12 13:34:31 +000017
sewardja0b4dbc2011-09-10 11:28:51 +000018
19# And then (unmodified)
20#
21export AR=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar
22export CPP=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-cpp
23export LD=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ld
24export CXX=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++
25export CC=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc
26
27
28# Then cd to the root of your Valgrind source tree.
29#
30cd /path/to/valgrind/source/tree
31
32
33# Do configuration stuff. Don't mess with the --prefix in the
34# configure command below, even if you think it's wrong.
35
sewardj37ed97b2011-07-12 13:34:31 +000036./autogen.sh
37
sewardja0b4dbc2011-09-10 11:28:51 +000038CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm" \
39 CFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm" \
sewardj37ed97b2011-07-12 13:34:31 +000040 ./configure --prefix=/data/local/Inst \
41 --host=armv7-unknown-linux --target=armv7-unknown-linux \
sewardja0b4dbc2011-09-10 11:28:51 +000042 --with-tmpdir=/sdcard
sewardj37ed97b2011-07-12 13:34:31 +000043
44
45# At the end of the configure run, a few lines of details
46# are printed. Make sure that you see these two lines:
47#
48# Platform variant: android
49# Primary -DVGPV string: -DVGPV_arm_linux_android=1
50#
51# If you see anything else at this point, something is wrong, and
52# either the build will fail, or will succeed but you'll get something
53# which won't work.
54
55
56# Build, and park the install tree in `pwd`/Inst
sewardja0b4dbc2011-09-10 11:28:51 +000057#
58make -j2
59make -j2 install DESTDIR=`pwd`/Inst
sewardj37ed97b2011-07-12 13:34:31 +000060
61
62# To get the install tree onto the device:
63# (I don't know why it's not "adb push Inst /data/local", but this
64# formulation does appear to put the result in /data/local/Inst.)
65#
66adb push Inst /
67
68# To run (on the device)
sewardja0b4dbc2011-09-10 11:28:51 +000069/data/local/Inst/bin/valgrind [the usual args etc]
70
71
72# Once you're up and running, a handy modify-V-rebuild-reinstall
73# command line (on the host, of course) is
74#
75mq -j2 && mq -j2 install DESTDIR=`pwd`/Inst && adb push Inst /
76#
77# where 'mq' is an alias for 'make --quiet'.
78
79
80# One common cause of runs failing at startup is the inability of
81# Valgrind to find a suitable temporary directory. On the device,
82# there doesn't seem to be any one location which we always have
83# permission to write to. The instructions above use /sdcard. If
84# that doesn't work for you, and you're Valgrinding one specific
85# application which is already installed, you could try using its
86# temporary directory, in /data/data, for example
87# /data/data/org.mozilla.firefox_beta.
88#
89# Using /system/bin/logcat on the device is helpful for diagnosing
90# these kinds of problems.