Macportsでユニバーサルバイナリを作る

ユニバーサルバイナリを作る際にはリンクする共有ライブラリもユニバーサルバイナリでなければならない。Mac OS Xに標準でインストールされているライブラリは全てユニバーサルバイナリだが、Macportsなどパッケージ管理ソフトウェアを用いてインストールしたものは標準ではユニバーサルバイナリではない。

port installをする時に+universal を指定するとユニバーサルバイナリが作られるはずだが、-isysroot /Developer/SDKs/10.4u.sdk (Mac OS Xppc版でユニバーサルバイナリを作る時に必要なオプション)の設定がされているが、10.5の場合はこのオプションでは動かない。Xcode 3.0のライブラリをインストールした上でそのライブラリを読むように設定しなければならない。
1.Xcode 3.0をインストールする
Mac OS X 1.5インストールDVDに収録されているXcode 3.0をインストールする。この作業は割愛する。
2.10.5のライブラリを読み込むようにファイルを書き換える
/opt/local/share/macports/Tcl/port1.0/portconfigure.tclと/opt/local/share/macports/Tcl/port1.0/portconfigure.tclを次のように書き換える

#portconfigure.tcl
#l.65
default configure.universal_cflags		{"-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"} 
-> default configure.universal_cflags		{"-isysroot /Developer/SDKs/MacOSX10.5.sdk -arch i386 -arch ppc -arch x86_64 -arch ppc64"}

#l.68
default configure.universal_cxxflags	{"-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"} 
-> default configure.universal_cxxflags	{"-isysroot /Developer/SDKs/MacOSX10.5.sdk -arch i386 -arch ppc -arch x86_64 -arch ppc64"}

#l.69
default configure.universal_ldflags		{"-arch i386 -arch ppc"} 
-> default configure.universal_ldflags		{"-arch i386 -arch ppc -arch x86_64 -arch ppc64"}
#portmain.tcl
#l.106
 if {![file exists /Developer/SDKs/MacOSX10.4u.sdk/]} { -> if {![file exists /Developer/SDKs/MacOSX10.5.sdk/]} {

#l.107
return -code error "MacOS X 10.4 universal SDK is not installed (are we running on 10.3? did you forget to install it?) and building with +universal will very likely fail" 
-> return -code error "MacOS X 10.5 universal SDK is not installed (are we running on 10.4? did you forget to install it?) and building with +universal will very likely fail"

3.macportsでソフトをインストールする時に+universal オプションを指定する。これでユニバーサルバイナリを構築できることができる。

ただし、ユニバーサルバイナリを生成する方法をMacportsデフォルトではなく、独自に行っているパッケージでは失敗することが多い。