Note: This post is outdated, please refer to Cross-compiling Haskell to OMAP3 and iPhone platforms
Since I did the compilation a month ago, there could be missing pieces.
steps
- I'm using Snow Leopard (Leopard might work, not tested)
- install GHC 6.10.2 (using other version caused problem for me)
- do the Mac trick for 32bit libs
- download GHC iPhone, need the source package
- before start, briefly go through the documentation in the package (pdf)
- prepare to hack:
Everything that follows applies to both iphone and iphone simulator. I recommend prepare 2 directories to compile for iphone and iphone simulator respectively, a simple make clean might not be enough from my experience:
compilation details
OK, here's what need to be changed,
- config-iphone.sh (point every /Developer path to the current SDK)
- download required stock packages (HTTP, etc, refer to documentation) into the proper location, that is, the actually GHC source dir, where you would find
README, configureetc - start to compile. Note: compiling will fail, in particular, I had to use undefine on almost every functions from : 1. network, 2.system.direcotry. Expect to do the same.
- After compilation, follow documentation to install.
after install
unixpackage is not present on my system.networkis not usable, but it's not a big deal, NSConnection can get the job done.- since unix is missing, it's not possible to use functions like
directoryExist, fileExistand such, those abilities could be imported from Core Foundation.
dev hints
- try to see the 2 examples bundled in GHC-iPhone package, they provide valuable information to get you started. They might not compile though.
- read on haskell FFI if not already familiar, it's the primary tool to talk to the iPhone
conclude
I compiled GHC 5 times in a day on a laptop to get it working, it's not as simple as it sounds. But once it's compiled, many things work unexpectedly well, even Controll.Concurrent is working without a hassle, not to mention endless packages on Hackage.