Building Firefox
Posted by: Jesse in How-To, Programming, tags: CVS, Firefox, Mac, make, Mozilla, XcodeI 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 native 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:
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:
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../OBJ-@CONFIG_GUESS@ mk_add_options MOZ_CO_PROJECT=browser mk_add_options MOZ_MAKE_FLAGS="-j5" mk_add_options PROFILE_GEN_SCRIPT='$(PYTHON) $(MOZOBJDIR)/_profile/pgo/profileserve$ ac_add_options --enable-application=browser ac_add_options --disable-update-channel ac_add_options --enable-optimize ac_add_options --disable-debug ac_add_options --disable-tests ac_add_options --disable-update-packaging ac_add_options --enable-official-branding
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):
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:
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:
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 the 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
cvs up -r BRANCH client.mk
replacing BRANCH with the name of the branch or tag you want to upgrade to; or to upgrade from a specific branch to the latest HEAD revision:
cvs up -a client.mk
and use the same make commands to check out the source tree and rebuild as above. Compiled from the Mozilla Developer Center (various linked pages) and Bluish Coder.

Entries (RSS)