This is what I do. Most days, it is good fun. Some days, it is a little full on.
Recently I’ve been trying to build a C application on OS X. It actually worked first time for me on an Intel MacBook Pro on Leopard (10.5) just via gcc *.c -o [outputfile] … but yesterday it was pointed out that the resulting binary is useless on a G4 Mac Mini.
The nice thing about Apple’s move from PowerPC to Intel chips is that they have this concept of a Universal binary – the same binary file can run on both PPC and Intel. The slightly complicated part is that you have to actually build your binary as Universal, it doesn’t happen automatically.
So it turns out the the corresponding magic-fu is:
gcc -O2 -Wall -force_cpusubtype_ALL -mmacosx-version-min=10.4 -arch i386 -arch ppc *.c -o [outputfile]
At a high level I’m telling the compiler to build for both i386 and ppc architectures. Note that I’ve also set a flag here to specify a minimum OS X level of 10.4 (Tiger).
Of course there are sometimes some coding changes required to support both processor architectures. Apple’s Universal Binary Programming Guidelines should help there.