Universal Libraries and Extensions for OS X 10.4+
Introduction and Background
Recent versions of Xcode for Mac OS X 10.4 Tiger introduced the ability to create multi-architecture (PowerPC and x86) executables and libraries, known as Universal binaries. Most UNIX librariesÂ’ build configurations have not adapted their build 'recipes' to utilize this capability, so they produce only the approriate binary for the platform on which they were compiled, resulting in slower or no execution on the other platform. This is certainly true of PIL, the Python Imaging Library, as of version 1.1.5. While each build 'recipe' differs depending upon the tools used by its maker and the libraries it is dependent upon, here are some instructions for builidng a Universal PIL and associated libraries, and a few tips on getting 'off-the-shelf' UNIX libraries to compile as Universal libraries.
Note: Prebuilt universal packages for Python 2.4 are available at http://pythonmac.org/packages/py24-fat/index.html"
To build a Universal PIL, we must first build Universal versions of its depedent libraries:
first get the source and put it a working directory you choose: http://easynews.dl.sourceforge.net/sourceforge/freetype/freetype-2.1.10.tar.gz open a Terminal window and change your working directory to the local of the archive file: unarchive it: change to the working directory for the source: configure the source for your platform: find the file freetype uses to determine hwo to compile the source on UNIX platforms and open it in your favorite text editor: change the line: build the library: Install it in the default location (/usr/local); return to the original directory:
first get the source and put it a working directory you choose: http://www.ijg.org/files/jpegsrc.v6b.tar.gz open a Terminal window and change your working directory to the local of the archive file: unarchive it: change to the working directory for the source: configure the source for your platform: find the make file created by the change the line: build the library: Install it in the default location (/usr/local): copy the manifest files to a standard'include' directory: copy the static library to the standard library directory for add-ons: use 'ranlib' to ensure a proper table of contents is generated for the library: return to the original directory:
first get the source and put it a working directory you choose: http://effbot.org/downloads/Imaging-1.1.5.tar.gz -o Imaging-1.1.5.tar.gz open a Terminal window and change your working directory to the local of the archive file: unarchive it: change to the working directory for the source: find the file used by Python to guide a build of an extension module: change the line: build the Python extension: run the self tests to ensure it all worked: if it passes all 55 tests, install the PIL module: We are done. return to the starting point
"It just goes to show you--there's always -- Emily Latella (Gilda Radner) from Saturday Night Each library has its own tricks but there are some standard way of changing the build environment and paramters without making permanent changes to the files. Why didn't I use them above? Because, just as the famous saying for that PIL (Python Imaging Library) Example
*Since Apple includes zlib with OS X 10.4, we only have to make Universal binaries for freetype2 and jpeg-6b. Notes and Assumptions
Universal freetype2
pushd <your directory path here> Universal jpeg-6b
pushd <your directory path here> Universal PIL
pushd <you directory path here> A few More
LIVE
- Most make files use standard variable names for their configuraiton parameters and setting those same variables in the shell environment (either permanently or for that shell) will override them.
For example we could have set the CFLAGS variable in our shell after the configure command but before the make command to compile and link libjpeg as Universal build. Of course if the make file also sets a value for that paramter in the make file, then setting our own value will mask that and the build operation may not go as planned. we would set it just for the shell session thus CFLAGS="--arch ppc -arch i386 " (note: the space at the end is important as these values may be followed by others for the individual make commands and without the space, the command line may become garbled.
- Some build 'recipes' are just not easy to modify because they are inscrutable due to complexity or they were not deisgned to be built in optional ways without permanent changes. Freetype2, because it uses the Jam tool, is one such example.
[Reader note: Copying the files /usr/share/libtool/config.sub and config.guess into your build directory will cause the ./configure script to work properly for jpeg-6a and freetype2]