After tweaking with Scratchbox, I could not build a perl linked with bionic with it.
However, it is possible to build perl with bionic using the standard Android toolchain, something I was thinking not possible. Here is how I did.
To facilitate the procedure (and even make it possible), I used the script agcc by Andrew Ross.
I opened a Google code project named perldroid.
Let's start from scratch. I'm still on an Ubuntu Intrepid (8.10), I'll try to build perl 5.10.0, the same version as on Intrepid (this is not a coincidence).
$HOME/mydroid). There is a small mistake on the page, you should install libreadline5-dev instead of lib32readline5-dev that does not exists on Ubuntu 32 bit. Also, we don't need valgrind. Don't forget to build the code with make because it builds some files we need.$HOME/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.3.1/bin in your $PATH.cd; gunzip -c perl-5.10.0.android.patch.gz | patch -p0 »cd ~/perl-5.10.0/Cross less README.android # always useful make -f Makefile.android patch make -f Makefile.android perl
If everything is OK, the resulting executables, libraries and modules should be installed in $HOME/perl-5.10.0/install_me_here/.
Unfortunately, it is not (yet) possible to install it on the real phone because the Android source (and the bionic libc it provides) is too recent and not compatible. When I (or someone else) find a way to download the bionic version that is on the phone, I will mention it.
Follow this procedure to create a custom ramdisk with perl inside it:
cd mkdir androidrd.perl; cd androidrd.perl cp ~/mydroid/out/target/product/generic/ramdisk.img . gunzip -S.img ramdisk.img cpio -i -F ramdisk cpio -t -F ramdisk >ramdisk_list rm -rf usr cp -r ~/perl-5.10.0/install_me_here/usr . find usr >>ramdisk_list cat ramdisk_list | cpio -o -H newc -O mydisk gzip -S.img mydisk
Now start the Android source emulator with:
export ANDROID_PRODUCT_OUT=$HOME/mydroid/out/target/product/generic ~/mydroid/out/host/linux-x86/bin/emulator -ramdisk ~/androidrd.perl/mydisk.img &
and log in to try perl:
adb shell /usr/bin/perl -I /usr/lib/perl -V
should output:
output of perl -V
The -I switch is necessary because the config file to build perl is designed ot put /data/data/org.gtmp.perl/lib/perl in @INC, not /usr/lib/perl. This was done because of the packaging foreseen for the perl executable. More on this when it will be done.
Feel free to try whatever perl script you like but be aware that everything is not available on the Android platform.
precise what is not available.
Thanks to Benoît Rouits for bundling the patch, writing the README.android file and for some tweakings on the Cross/config.sh-arm-eabi file.