libgmp is the big number library. Firstly, we need to make it build using the cross compiler. Secondly, apply a small patch to the ARM assembly code, which is needed because Apple ships a pre-historic version of the GNU assembler. --- ghc-6.10.2.orig/gmp/Makefile 2009-03-31 06:13:16.000000000 +1300 +++ ghc-6.10.2/gmp/Makefile 2009-06-18 15:54:37.000000000 +1200 @@ -63,27 +63,41 @@ stamp.gmp.static: $(RM) -rf $(GMP_DIR) gmpbuild $(TAR) -zxf $(GMP_TARBALL) + cat iphone.patch | (cd $(GMP_DIR) && patch -p1) mv $(GMP_DIR) gmpbuild chmod +x ln (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \ PATH=`pwd`:$$PATH; \ export PATH; \ cd gmpbuild && \ - CC=$(WhatGccIsCalled) $(SHELL) configure \ - --enable-shared=no --host=$(PLATFORM) --build=$(PLATFORM) + CC="$(TARGET_GCC)" \ + AR="$(TARGET_AR)" \ + LD="$(TARGET_LD)" \ + CFLAGS="$(TARGET_CFLAGS)" \ + CPPFLAGS="$(TARGET_CPPFLAGS)" \ + LDFLAGS="$(TARGET_LDFLAGS)" \ + $(SHELL) configure \ + --enable-shared=no --host=$(PLATFORM) touch $@ stamp.gmp.shared: $(RM) -rf $(GMP_DIR) gmpbuild-shared $(TAR) -zxf $(GMP_TARBALL) + cat iphone.patch | (cd $(GMP_DIR) && patch -p1) mv $(GMP_DIR) gmpbuild-shared chmod +x ln (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \ PATH=`pwd`:$$PATH; \ export PATH; \ cd gmpbuild-shared && \ - CC=$(WhatGccIsCalled) $(SHELL) configure \ - --enable-shared=yes --disable-static --host=$(PLATFORM) --build=$(PLATFORM) + CC="$(TARGET_GCC)" \ + AR="$(TARGET_AR)" \ + LD="$(TARGET_LD)" \ + CFLAGS="$(TARGET_CFLAGS)" \ + CPPFLAGS="$(TARGET_CPPFLAGS)" \ + LDFLAGS="$(TARGET_LDFLAGS)" \ + $(SHELL) configure \ + --enable-shared=yes --disable-static --host=$(PLATFORM) touch $@ gmp.h: stamp.gmp.static --- ghc-6.10.2.orig/gmp/iphone.patch 1970-01-01 12:00:00.000000000 +1200 +++ ghc-6.10.2/gmp/iphone.patch 2009-06-18 15:54:37.000000000 +1200 @@ -0,0 +1,11 @@ +--- gmpbuild.orig/mpn/arm/invert_limb.asm 2006-03-15 04:57:54.000000000 +1300 ++++ gmpbuild/mpn/arm/invert_limb.asm 2009-04-14 15:27:40.000000000 +1200 +@@ -29,7 +29,7 @@ + stmfd sp!, {r4, lr} + mov r3, d, lsr #23 + sub r3, r3, #256 +- add r2, pc, #invtab-.-8 ++ adr r2, invtab + mov r3, r3, lsl #1 + ldrh r1, [r2, r3] C get initial approximation from table + mov r2, r1, lsl #6 C start iteration 1