Building Firefox

I was having weird problems with Firefox lagging every once in a while, so I decided to just build my own for Mac OS X Leopard on my Intel Core 2 Duo Mac Pro. Didn't turn out to be too difficult; Neil Lee at BeatnikPad already has Intel and G5 specialized builds of Firefox 3 available, but I like having the default branding (Firefox instead of Minefield, the fox icon instead of the weird bomb-planet thing) and a little more customized optimization. Here's a basic walkthrough of how I did it; you'll need the latest version of Xcode installed, a passing familiarity with the Terminal, and the latest version of libIDL (if you have Fink, fink install libidl2; for MacPorts, sudo port install libidl).

Start out by creating a Mozilla directory, or some other such directory. Open a terminal, cd into that directory, and (assuming you want the 3.0 branch of Firefox) check out the Mozilla client makefile from CVS:

  1. $ cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co -r BRANCH mozilla/client.mk

If you want the absolute latest version, omit the -r BRANCH segment; otherwise, replace BRANCH with the name of a Mozilla CVS tag (FIREFOX_3_0_1_RELEASE for the latest 3.0 branch release, for example). Starting with the 3.1 branch Mercurial will become the main development version control system for Firefox/Thunderbird/&c., but this article assumes you just want to build for yourself the latest public release version; 3.1 is still very unstable.

Anyway, next you need the configuration file that instructs the make process on how to configure your build of Firefox. The easiest place to put this is in your home directory, as a plain text file named .mozconfig. My file is below:

  1. mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../OBJ-@CONFIG_GUESS@
  2.  
  3. ac_add_options --enable-application=browser
  4. mk_add_options MOZ_CO_PROJECT=browser
  5. ac_add_options --disable-tests
  6. ac_add_options --enable-official-branding
  7.  
  8. mk_add_options MOZ_MAKE_FLAGS="-s -j4"
  9. ac_add_options --enable-optimize

This makes an officially-branded (ac_add_options --enable-official-branding) Firefox (ac_add_options --enable-application=browser and mk_add_options MOZ_CO_PROJECT=browser) release build (ac_add_options --disable-tests), putting all build files in a separate folder in the Mozilla folder (mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../OBJ-@CONFIG-GUESS@), utilizing four simultaneous build processes (mk_add_options MOZ_MAKE_FLAGS="-s -j4") and the default optimization options (ac_add_options --enable-optimize). There are a number of other options available; this is what worked for me for creating an official-release-like build. Be careful with any other options, make sure you know what an option does before you put it into your .mozconfig file.

Back in the terminal (you should still be in the Mozilla directory), cd into the mozilla directory created by the CVS checkout you did earlier. This next command will check out the Firefox browser code for the tag you selected (or the latest bleeding-edge 3.0 series code if you didn't specify a tag):

  1. $ make -f client.mk checkout

This may take a while, but when your prompt comes back you'll have all the files you need to build Firefox:

  1. $ make -f client.mk build

This will take even longer, as long as half an hour to 45 minutes. Once it's finished, there will be a new Firefox.app in the Mozilla/OBJ-SOMETHING/dist directory. You can use this as it is; the only caveat being, you can't delete the build directory if you do, because that package still depends on files residing in the build directory. What you probably want to do to use this build as your everyday Firefox in your Applications folder is create a disk image:

  1. $ make -C ../OBJ*/browser/installer

This will create a disk image, in the same style that Mozilla makes available their public releases, in the same place as Firefox.app. Mount it and drag Firefox from it to your Applications folder; then copy the disk image elsewhere if you want and delete the build folder. If you're going to be making changes and rebuilding Firefox later though, it'll make that process go faster if you leave the build files in place since it won't have to rebuild everything.

If later on you want to upgrade your build to a newer version in the 3.0 branch, open a terminal, go to the Mozilla/mozilla directory again, and

  1. $ cvs up -r BRANCH client.mk

or to upgrade from a specific branch to the latest HEAD revision:

  1. $ cvs up -a client.mk

and use the same method to check out the source tree as above:

  1. $ make -f client.mk checkout

and use the same build procedure from there.

Compiled from the Mozilla Developer Center (various linked pages) and Bluish Coder.

Comments

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.