sewardj | 37ed97b | 2011-07-12 13:34:31 +0000 | [diff] [blame] | 1 | |
| 2 | How to cross-compile for Android. |
| 3 | |
| 4 | This is known to work at least for Android 3.0 running on a Motorola |
| 5 | Xoom. Other configurations and toolchains might work, but haven't |
| 6 | been tested. Feedback is welcome. |
| 7 | |
| 8 | You need the android-ndk-r5c native development kit. Install it |
| 9 | somewhere. Then do this: |
| 10 | |
| 11 | # Maybe not all of these are necessary -- I'm just being cautious. |
| 12 | # |
| 13 | export AR=/path/to/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar |
| 14 | export CPP=/path/to/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-cpp |
| 15 | export LD=/path/to/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ld |
| 16 | export CXX=/path/to/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++ |
| 17 | export 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 | |
| 25 | cd trunk |
| 26 | ./autogen.sh |
| 27 | |
| 28 | CPPFLAGS="--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 |
| 47 | make |
| 48 | make 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 | # |
| 55 | adb push Inst / |
| 56 | |
| 57 | # To run (on the device) |
| 58 | /data/local/Bin/valgrind [the usual args etc] |