So back in the day, we used to build a lot of UNIX apps for the iphone, and one thing that we really miss in the new SDK is a quick way to do the old:
./configure --host=arm-apple-darwin trick
The stuff that follows seems to work just fine for us but your mileage as always may vary.
None of this relies on the open SDK. There are other howtos out there that show you how to make a frankenSDK. We were just trying to get to the bottom of why the CLI does not work out of the box. By default you are forced to either use xcode to build things, or xcodebuild assuming you have a project file. Often in *nix land you don't have that luxury.
Here's the deal:
Make some sym links in /usr/bin:
ln -s /Developer/Platforms/iPhoneOS.platform/ Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1 /usr/bin/arm-apple-darwin-gcc
you can do the same trick for all the other stuff that cross compilers like to see prefixes for from the same directory and path.
arm-apple-darwin-ar
arm-apple-darwin-nm
arm-apple-darwin-ld
arm-apple-darwin-g++
arm-apple-darwin-cc
etc.
Then you will want to source a script that looks like this (sorry I like tcsh, yes I know it is a disease). Best that you don't just cut and paste this, worth checking it out as a concept first.
[isrv:~/iphone] core% cat setup.sh setenv DEV /Developer/Platforms/iPhoneOS.platform/ Developer/SDKs/iPhoneOS2.0.sdk setenv CFLAGS "-I$DEV/usr/lib/gcc/arm-apple-darwin9/4.0.1/include/ -I$DEV/usr/include/ -arch armv6 -g -pipe -no-cpp-precomp -isysroot $DEV" setenv LDFLAGS "-L$DEV/usr/lib/" setenv CPP "/usr/bin/cpp -I$DEV/usr/lib/gcc/arm-apple-darwin9/4.0.1/include/ -I$DEV/usr/include/" setenv CPPFLAGS "-I$DEV/usr/lib/gcc/arm-apple-darwin9/4.0.1/include/ -I$DEV/usr/include/"
Then you can now go build all those unix things with configure scripts really easily, using the 2.0 SDK native toolchain and their (albeit hidden until now) existing cross compiler:
104 16:20 tar zxvf tcpxd-1.4.tar.gz 105 16:20 cd tcpxd-1.4 106 16:20 ./configure --host=arm-apple-darwin 107 16:21 make [isrv:~/iphone/tcpxd-1.4] core% file tcpxd tcpxd: Mach-O executable arm
(yes you can probably see where we were heading with tcpxd ;))
We have successfully built viable versions of openssl, sshd and a copy of bash with this same process. There are many ways to achieve the same result, some probably more elegant than this, but for now it works for us.
The machine we used has never been near an open SDK, so in theory it should also work for you. For some of the strange things you may want to copy some header files into the $DEV/usr/include directory.
Now that's all fine, for now. You will have to tune in again sometime as we work out how on earth we are ever going to actually to use these binaries on our 2.0 iPhones, out side of our ever watchful parents.
It turns out that PARENTAGE is both a digital and legal guardian.
A whole day of fork() failures is long enough for us to know that this was probably all a rather significant waste of time. Maybe it will come in handy, so we will leave it up here.
The best use we can think of right now is building support libraries to be bundled with applications later on...
Thank you James, this is pretty useful stuff.
This trick does not seem to work for iPhoneSimulator though.
On my system, the directory:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.1.sdk/usr/bin
does not contain a compiler.
How would you go about building autoconf projects to be used with the iPhone simulator sdk ?
thx
Bram