2007-11-22

Universal Binaries from Autotool'd Projects

A frequent question I get is "how do I build a universal binary from an autotool'd project?". Unfortunately, as with all things autotools, the answer isn't quite straightforward. The best approach is to configure and make the project multiple times, once for each architecture you want in your UB, with different compiler settings each time.

Since autotool'd projects vary widely, the details for each will differ, but at the least, you'll need to set the CFLAGS environment variable appropriately (eg. -arch ppc -isysroot /Developer/SDKs/MacOSX10.3.9.sdk -mmacosx-version-min=10.3), and pass the correct host for a cross-compile to configure (eg. .configure --prefix=`pwd`/build/ppc --host=powerpc-apple-darwin7).

Once you've got a version for each architecture built, you can use lipo to join them together into a UB.

If all that sounds like too much effort, my "Third-Party" project does it already for a few common open-source libraries, and the infrastructure there makes it easy to add more.

0 comments: