I got PARI (http://pari.math.u-bordeaux.fr/), which is a very powerful C program for doing number theory, to run natively on my iPad and iPhone!
"All" I had to do was:
1. Jailbreak my iPad using Spirit.
2. Make a gcc wrapper script on my MAC laptop that can cross-compiler binaries for iPhoneOS, and put this script first in my path (I called it gcc):
# the following is all on one line:
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv6 -mthumb -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk/ "$@"
3. Download the PARI source code and extract it:
4. Configure and build PARI (this requires that you have the latex XCode installed).
5. The build fails, so I edited the file src/kernel/none/mp_indep.c in a somewhat random way to get it to compile. More precisely, I commented out lines 794-801, and replaced them by:
# define INDEX0 1
# define INDEX1 0
6. Copy Odarwin-i386/gp-sta over to the iPad/iPhone using ssh (I installed an ssh daemon using Cydia).
7. Run it, via iSSH (purchased from the App store) connected to localhost -- see above.
Here is a link to my gp-sta, in case you want to just drop it on your phone and run it.
If I can put a simple GUI on this, I may try to submit this to the App store, so that anybody can trivially install GP for free. Another possibility would be to get it included in Cydia.
This is of course just a tiny step on the way to porting Sage to the iPad.
I was also able to build Pari *directly* on the iPhone with readline support. Installing GCC was pretty crazy.
William-A-Steins-iPad:~/pari/pari-2.3.5 mobile$ Odarwin-arm/gp-sta GP/PARI CALCULATOR Version 2.3.5 (released) arm running darwin (portable C kernel) 32-bit version compiled: Jun 7 2010, gcc-4.2.1 (Based on Apple Inc. build 5555) (readline v6.0 enabled, extended help not available) Copyright (C) 2000-2006 The PARI Group PARI/GP is free software, covered by the GNU General Public License, and comes WITHOUT ANY WARRANTY WHATSOEVER. Type ? for help, \q to quit. Type ?12 for how to get moral (and possibly technical) support. parisize = 4000000, primelimit = 500000 ? 2+3 %1 = 5 ?
My notes for installing GCC on the iphone:
1) Install this http://files.getdropbox.com/u/876743/fake-libgcc_1.0_iphoneos-arm.deb dpkg -i fake-libgcc_1.0_iphoneos-arm.deb 2) apt-get install iphone-gcc 3) Install headers: Copy these over, which I got from http://www.megaupload.com/?d=55ZNOCKI, and extra to /usr/include sdk-2.0-headers.tar.gz I literally just put them in /usr/include/ 4) Missing /usr/lib/libgcc_s.1.dylib ... wget http://apt.saurik.com/debs/libgcc_4.2-20080410-1-6_iphoneos-arm.deb 5) Hmm: http://blog.aaronash.com/?p=15 I downloaded this and extracted it as lib, and had to use some funny password. "aksblog.co.nr" Then I copied lib/libSystem.dylib to /usr/lib/ on my iPad ... and now gcc seems to work! 6) This isn't needed for some reason: Make it so I can sign my apps: apt-get install ldid ldid -S main Maybe I don't need this only because I'm not making a gui yet. 7) Compiling runs into fork limits a lot, so raise the limit: William-A-Steins-iPad:~/pari/pari-2.3.5 mobile$ sysctl -w kern.maxprocperuid=64 kern.maxprocperuid: 26 sysctl: kern.maxprocperuid: Operation not permitted William-A-Steins-iPad:~/pari/pari-2.3.5 mobile$ sudo sysctl -w kern.maxprocperuid=64 Password: kern.maxprocperuid: 26 -> 64