How to build a Universal Gecko SDK
The builds that I created are available for download. (See attachments at the bottom of the page.)
-
Follow Mac OS X Prerequisites from Mozilla
http://developer.mozilla.org/en/docs/Mac_OS_X_Build_PrerequisitesWhen installing Xcode, you'll need to customise the install and select the option to "support OS X 10.3.9" or similar. This will install GCC 3.3, which you'll need in order to build the PowerPC part of the SDK. If you use Fink, you may find that the
orbitandorbit-devpackages did not provide an adequate libIDL for the XULRunner build. There is a package namedlibidl2that seems to do the trick. You can use FinkCommander to remove the orbit packages and install a binarylibidl2in its place. MacPorts just works :) -
To build binary XPCOM components on the Mac, we need not only the SDK but the XUL framework. Both of these can be compiled from the XULRunner source code.
Mozilla hosts source code snapshots of various versions of xulrunner:
ftp://ftp.mozilla.org/pub/mozilla.org/xulrunner/releasesMozilla is unable to complete a universal XULRunner build before version 1.8.0.7. If there is a source package available (in a source subdirectory) for 1.8.0.7 or later, you can download that and unpack it. Otherwise, you'll have to obtain the source via CVS (read on).
To get the source from CVS, run the following commands from a terminal:
cd ~/Desktop
cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co -r FIREFOX_2_0_0_3_RELEASE mozilla/client.mk
cd mozilla
make -f client.mk checkout MOZ_CO_PROJECT=xulrunnerFIREFOX_2_0_0_3_RELEASE is a branch name. There may be newer branches by the time you read this. Visit the following page for more on obtaining mozilla source from CVS:
http://developer.mozilla.org/en/docs/Mozilla_Source_Code_%28CVS%29Don't worry about the CVS warnings that appear about a missing file in your home directory.
You can safely delete the cvsco.log file from your desktop when the checkout is complete. -
Create a file named
.mozconfigin the mozilla directory with the following contents:. $topsrcdir/xulrunner/config/mozconfig
. $topsrcdir/build/macosx/universal/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/xr-opt
ac_add_options --enable-optimize
ac_add_options --disable-debug
ac_add_options --disable-tests
ac_add_app_options ppc --with-macos-sdk=/Developer/SDKs/MacOSX10.3.9.sdk
ac_add_app_options ppc --enable-prebindingSee the following link for other possible build options:
http://developer.mozilla.org/en/docs/Configuring_Build_OptionsLook here for information concerning configuration for universal mozilla builds:
http://developer.mozilla.org/en/docs/Mac_OS_X_Universal_Binaries -
In the Mozilla source directory, run
makeusing the following arguments. It will invoke configure automatically.make -f client.mk buildCross your fingers :)
-
The Universal
XUL.frameworkhas been built. Copy it from thexr-opt/ppc/dist/universal/xulrunnerdirectory to/Library/Frameworksusing Finder. -
The build has created two separate SDKs, and we'll have to merge them together manually. The SDKs in the source tree contain many symbolic links and so depend on the source tree. Firstly, build a standalone version of each SDK using make and copy them onto the Desktop:
for arch in i386 ppc; do
make -C xr-opt/$arch/xulrunner/installer make-sdk
cp -R xr-opt/$arch/dist/gecko-sdk ~/Desktop/gecko-sdk-mac-$arch
doneNote: For Gecko 1.9 builds (e.g. for Firefox 3), use the following instead, as the SDK is built in a different location:
for arch in i386 ppc; do
make -C xr-opt/$arch/xulrunner/installer make-sdk
cp -R xr-opt/$arch/dist/xulrunner-sdk/sdk ~/Desktop/gecko-sdk-mac-$arch
doneNow we create a new directory (copy of the i386 SDK) to form the base for our universal SDK. We'll keep the two originals clean just in case something goes wrong:
cd ~/Desktop
cp -R gecko-sdk-mac-i386 gecko-sdk-mac-universalWe can use the "lipo" tool to combine the libraries in the "lib" and "bin" directories of the SDKs. Firstly, we join the libraries. The expression in the for loop ensures we run the command only on the binaries, and not the .jar files:
for library in $(ls gecko-sdk-mac-i386/lib | egrep '\.dylib|\.a'); do
lipo -create -output gecko-sdk-mac-universal/lib/$library -arch ppc gecko-sdk-mac-ppc/lib/$library -arch i386 gecko-sdk-mac-i386/lib/$library;
doneYou can check that the universal libs were correctly build using the following command:
file gecko-sdk-mac-universal/lib/libxpcom.dylibThe output should indicate "
Mach-O universal binary with 2 architectures". Now we do the same thing for the executables:for executable in $(ls gecko-sdk-mac-i386/bin); do
lipo -create -output gecko-sdk-mac-universal/bin/$executable -arch ppc gecko-sdk-mac-ppc/bin/$executable -arch i386 gecko-sdk-mac-i386/bin/$executable;
doneIf this step fails due to a missing
xpidlin the PPC SDK, see the next step. If all went well, check that the files were correctly built and skip the next step:file gecko-sdk-mac-universal/bin/xpidl -
When I reached the stage of building the universal executables (in the
bindirectory), I discovered thatxpidlis in fact not compiled for the PPC build. Looking into this, it turns out it's a difficulty in cross-compiling this binary due to libraries it depends on. (I'm building on an Intel Mac.) If you'll only be using the SDK on your computer (most likely), you can ignore this problem.If you do need a truly universal
xpidl, you'll have to perform some steps on a Mac of the opposite architecture (in my case, PPC):- Repeat steps 1 and 2 above.
-
Repeat step 3 using the following .mozconfig file instead of the original:
. $topsrcdir/xulrunner/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/xr-opt
ac_add_options --enable-optimize
ac_add_options --disable-debug
ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.3.9.sdk
ac_add_options --enable-prebinding -
Run the following commands from the mozilla directory to build just
xpidl:mkdir xr-opt
cd xr-opt
../configure
make -C config(You can ignore the error messages at the end of the output here. It doesn't seem to affect our build.)
make -C nsprpub
make -C xpcom/typelib -
Now you can copy the binary
xpidlfrom thexr-opt/xpcom/typelib/xpidldirectory into the originalgecko-sdk-mac-ppc/bindirectory from step 6 and retry the merging process for thebindirectory.
-
The Universal SDK in ready, and you can move it to wherever you want it to be kept.
You can now remove the two original directories, and the mozilla source root:rm -rf gecko-sdk-mac-{i386,ppc} mozilla
Danns.co.uk
Comments
Library not loaded: /sw/lib/libIDL-2.0.dylib
I've downloaded your prebuild xpidl stuff and when i start xpidl i get the error:
Library not loaded: /sw/lib/libIDL-2.0.dylib
Any hints?
Fink
In order to use the prebuilt binaries I provided, you'll have to follow step 1 above (installing Fink and libIDL). That should fix the problem.