Universal Binary

A universal binary is a Mac executable which contains native code for both PPC and i386 platforms.

This page contains an incomplete guide on how Tribler was made Universal. It is incomplete because for some odd reason, I didn't have to recompile bsddb?

Prerequisites

You need:

Global picture

  1. Make sure you're always using the Universal Binary version of Python. Default install puts python at /Library/Frameworks/Python.framework/Versions/2.4/Resources/Python.app/Contents/MacOS/Python.
  2. Follow the instructions below to build OpenSSL.
  3. Build M2Crypto. Make sure you wipe the old building dir first.
  4. Build Tribler.

OpenSSL

OpenSSL needs to be compiled twice: once for each platform. The following script can be used, following instructions http://developer.apple.com/opensource/buildingopensourceuniversal.html:

#!/bin/bash

mkdir -p build-ppc build-i386



# build PPC version

make clean

./Configure darwin-ppc-cc

make build_libs

mv *.a build-ppc



# build i386 version

make clean

./Configure 386 darwin-i386-cc

make build_libs "CC=cc -arch i386"

mv *.a build-i386



# merge them

for i in libssl.a libcrypto.a

do

  lipo -create -output $i build-ppc/$i build-i386/$i

  ranlib $i

done

You can verify that the created libraries are indeed fat:

$ file *.a

libcrypto.a: Mach-O fat file with 2 architectures

libcrypto.a (for architecture ppc):     current ar archive

libcrypto.a (for architecture i386):    current ar archive random library

libssl.a:    Mach-O fat file with 2 architectures

libssl.a (for architecture ppc):        current ar archive

libssl.a (for architecture i386):       current ar archive random library

M2Crypto

M2Crypto should compile correctly. Make sure you use the universal version of Python:

rm -rf build

python2.4 setup.py build

To verify the result:

$ file build/lib.macosx-*-fat-*/M2Crypto/__m2crypto.so 

build/lib.macosx-10.3-fat-2.4/M2Crypto/__m2crypto.so: Mach-O fat file with 2 architectures

build/lib.macosx-10.3-fat-2.4/M2Crypto/__m2crypto.so (for architecture i386):   Mach-O bundle i386

build/lib.macosx-10.3-fat-2.4/M2Crypto/__m2crypto.so (for architecture ppc):    Mach-O bundle ppc

Tribler

Finally we can build Tribler:

python2.4 setuptriblermac.py build

Verify the resulting application on both platforms to be sure :)