How to build a Universal Gecko SDK

The builds that I created are available for download. (See attachments at the bottom of the page.)

  1. Follow Mac OS X Prerequisites from Mozilla
    http://developer.mozilla.org/en/docs/Mac_OS_X_Build_Prerequisites

    When 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 orbit and orbit-dev packages did not provide an adequate libIDL for the XULRunner build. There is a package named libidl2 that seems to do the trick. You can use FinkCommander to remove the orbit packages and install a binary libidl2 in its place. MacPorts just works :)

  2. 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/releases

    Mozilla 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=xulrunner

    FIREFOX_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%29

    Don'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.

  3. Create a file named .mozconfig in 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-prebinding

    See the following link for other possible build options:
    http://developer.mozilla.org/en/docs/Configuring_Build_Options

    Look here for information concerning configuration for universal mozilla builds:
    http://developer.mozilla.org/en/docs/Mac_OS_X_Universal_Binaries

  4. In the Mozilla source directory, run make using the following arguments. It will invoke configure automatically.

    make -f client.mk build

    Cross your fingers :)

  5. The Universal XUL.framework has been built. Copy it from the xr-opt/ppc/dist/universal/xulrunner directory to /Library/Frameworks using Finder.
  6. 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
    done

    Note: 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
    done

    Now 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-universal

    We 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;
    done

    You can check that the universal libs were correctly build using the following command:

    file gecko-sdk-mac-universal/lib/libxpcom.dylib

    The 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;
    done

    If this step fails due to a missing xpidl in 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

  7. When I reached the stage of building the universal executables (in the bin directory), I discovered that xpidl is 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):

    1. Repeat steps 1 and 2 above.
    2. 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

    3. 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

    4. Now you can copy the binary xpidl from the xr-opt/xpcom/typelib/xpidl directory into the original gecko-sdk-mac-ppc/bin directory from step 6 and retry the merging process for the bin directory.
  8. 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


Filename/TitleSize
gecko-sdk-mac-universal.zip2.82 MB
XUL.framework.zip17.48 MB

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.

Back to top