Cross compiling autoconf packages for iPhone

While the MacOS X iPhone Developer package contains the needed cross-compiling tools, I haven’t found anywhere a clear explanation regarding how the environment should be set for compiling some standard autoconf/automake package.
I’m using the following script (works on the XCode 3.2.2 on Snow Leopard):

#!/bin/sh
export CPP="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1 -E"
export  CC="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1"
export CXX="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-g++-4.2.1"
 
export CPPFLAGS='-I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/usr/lib/gcc/arm-apple-darwin10/4.2.1/include -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/usr/include'
export LDFLAGS="-L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/usr/lib"
export CFLAGS="-Os -pipe $CPPFLAGS $LDFLAGS"
export CXXFLAGS="$CFLAGS"
 
export PATH="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/bin:/usr/bin"
 
export ARCH=arm-apple-darwin10
 
./configure --build=i386-apple-darwin10 --host=$ARCH --enable-shared=no --prefix=/usr $@

And then either use the resulting library, or add the source files alongside the generated config.h

Leave a Reply

Pages

Adsense