develooper Front page | perl.perl5.porters | Postings from September 2013

Re: Question on porting perl 5.16 to Android (no /bin/sh)

Thread Previous | Thread Next
Brian Fraser
September 4, 2013 18:43
Re: Question on porting perl 5.16 to Android (no /bin/sh)
Message ID:
On Wed, Sep 4, 2013 at 3:17 PM, Ben Greear <> wrote:

> On 09/04/2013 10:21 AM, Brian Fraser wrote:
>  On Wed, Sep 4, 2013 at 1:50 PM, Ben Greear <<mailto:
>> greearb@candelatech.**com <>>> wrote:
>>     I used the perldroid project to cross-compile perl 5.16 for android
>> (ARM) using
>>     the latest Android NDK stand-alone toolchain.  After hacking on
>> perldroid to
>>     fix a few things I got a mostly-working perl binary & libraries.
>>     One problem remains however.  If I have perl code that does something
>> like this,
>>     it will not work:
>>     my @foo =  `ls run_*.PID 2>/dev/null`;
>>     I think this might be because Android has no /bin/sh.  Instead, it
>> puts the shell
>>     at /system/bin/sh.
>>     Maybe lacking /bin/sh perl uses some interal minimal fake shell and
>> thus fails to handle
>>     more advanced system calls?
>>     Anyone know if perl can be configured to use a different shell by
>> default, or where
>>     the code is that could be changed to use /system/bin/sh?
>>     Thanks,
>>     Ben
>> Rather than using perldroid, try using castaway's branch here:
>> Which solves that and several other issues with perl on android, such as
>> making 'system "echo", "foo"' work, even though "echo" is a shell builtin
>> in Android,
>> or being able to use both List::Util and Hash::Util in the same program,
>> which fails on perldroid due to some limitations in the android linker.
>> Also, for the time being, perhaps considering using
>>**utf8mess/tree/configure-for-**cross<>instead, at least until that's merged into the
>> main branch, if you want to run a successful 'make test' after building,
>> to ensure that your perl is working properly.
>> With that branch, building perl on android is pretty simple:
> I took a look at the jrobinson stuff yesterday, but I'd rather not use
> an emulator

You don't have to -- I build on my phone regularly. Just replace the
'emulator-5554' above with whatever adb devices says your phone's device
name is; everything else should be the same.

> , and I want the end result to be a foo/perl/lib and foo/perl/bin
> (or similar) directory structure that I can copy over to my phone via
> sftp or some other external means.

That's what the 'make DESTDIR=... install' bit does. You'll have a bin/ and
lib/ in the specified directory, and you can then copy that over. I
recommend using adb push to copy files over.

> I also have a stand-alone toolchain set up already, so it seems I can skip
> some of these steps.

> I'll try based on your instructions below and see what I can see.
> For your instructions below, is there a particular place on the
> droid file system at which perl is expecting to be installed?

None; it's up for you to decide where your perl goes. /data/data/my.perl,
maybe? Just make sure *not* to install it on the sdcard, because android
disallows executables there.

>  I
> can fiddle with @INC if needed, but easier if I don't have to.
On castaway's branch, perl on android is built with -Duserelocatableinc by
default, so hopefully @INC munging will not be needed.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About