Skip to content

Instantly share code, notes, and snippets.

@abhiyerra
Created February 23, 2009 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhiyerra/68757 to your computer and use it in GitHub Desktop.
Save abhiyerra/68757 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Thanks to http://latenitesoft.blogspot.com/2008/10/iphone-programming-tips-building-unix.html
export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS2.2.sdk
export LIBNAME="osip"
U_CC=$CC
U_CFLAGS=$CFLAGS
U_LD=$LD
U_LDFLAGS=$LDFLAGS
U_CPP=$CPP
U_CPPFLAGS=$CPPFLAGS
export CPPFLAGS="-I$SDKROOT/usr/lib/gcc/arm-apple-darwin9/4.0.1/include/ -I$SDKROOT/usr/include/"
export CFLAGS="$CPPFLAGS -arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT"
export CPP="/usr/bin/cpp $CPPFLAGS"
# dynamic library location generated by the Unix package
LIBPATH=src/.libs/$LIBNAME.dylib
LIBNAME=`basename $LIBPATH`
export LDFLAGS="-L$SDKROOT/usr/lib/ -Wl,-dylib_install_name,@executable_path/$LIBNAME"
# static library that will be generated
LIBPATH_static=src/.libs/$LIBNAME.a
LIBNAME_static=`basename $LIBPATH_static`
./configure CC=$DEVROOT/usr/bin/arm-apple-darwin9-gcc-4.0.1 LD=$DEVROOT/usr/bin/ld --host=arm-apple-darwin
make
mkdir -p lnsout
cp $LIBPATH_static lnsout/$LIBNAME_static.arm
make distclean
# Use default environment
export CC=$U_CC
export CFLAGS=$U_CFLAGS
export LD=$U_LD
export LDFLAGS=$U_LDFLAGS
export CPP=$U_CPP
export CPPFLAGS=$U_CPPFLAGS
# Overwrite LDFLAGS
# Dynamic linking, relative to executable_path
# Use otool -D to check the install name
export LDFLAGS="-Wl,-dylib_install_name,@executable_path/$LIBNAME"
# ToDo - error checking
./configure
make
# Save generated binaries
cp $LIBPATH_static lnsout/$LIBNAME_static.i386
$DEVROOT/usr/bin/lipo -arch arm lnsout/$LIBNAME_static.arm -arch i386 lnsout/$LIBNAME_static.i386 -create -output lnsout/$LIBNAME_static
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment