On a mailing list I belong to (X-Unix) the question came up of how to make a universal binary of a command line program. For the simple programs its pretty easy. Run the “configure” utility. That will output the “Makefile”. Find the “CFLAGS”, “CPPFLAGS”, and “CXXFLAGS” entries in the “Makefile”. Make them look like this:
CFLAGS = -g -O2 -mmacosx-version-min=10.4 -arch i386 -arch ppc
CPPFLAGS = -mmacosx-version-min=10.4 -arch i386 -arch ppc
CXXFLAGS = -g -O2 -Wall -W -mmacosx-version-min=10.4 -arch i386 -arch ppc
The 10.4 code also allows compilation on 10.5 but execution on 10.4. It is not needed (but I do it anyway).
However, that doesn’t work for the more complex apps which use certain gcc switches. So you have to do two builds- have one i386 and the other ppc. Then you have to combine them together.
You have to use “lipo” for that. So if I had two builds test.ppc and test.i386 and I wanted to make a universal build, I would put this on the command line:
lipo test.ppc test.i386 -output test.uni
That’s it! It took me a bit of experimentation to figure that out, so I hope others can get some use out of it.