Making a Quad-FAT Universal Binary for CKit
I saw something like this on Apple's Developer website while looking for some help in getting the PPC build of CKit working the other day. It was a way to combine two binaries and make a universal (or FAT) binary as the output. So you'd compile a PPC library and an Intel one, and then merge the two together. Pretty slick. It's a simple command:
$ lipo -create one.dylib two.dylib -output final.dylib
This creates a single final.dylib file from the two inputs. Very nice.
So I decided to try my hand at creating a single quad-FAT CKit library: 32/64-bit, PPC/Intel. All I needed to do was to change the lines in the Makefile from:
ifeq ($(shell uname),Darwin) all: $(LIB_FILE) $(LIB64_FILE) else
to:
ifeq ($(shell uname),Darwin) all: $(LIB_FILE) $(LIB64_FILE) lipo -create $(LIB_FILE) $(LIB64_FILE) -output $(LIB_FILE) else
Where the original 'all' target just required the two library files to be generated, and now it does that but then it uses the lipo command to stitch the two libraries together into one. This has the effect of leaving the 64-bit PPC/Intel library alone, but glues it onto the 32-bit version. What an amazingly simple thing to do!
I do love these tools!