Last Wednesday, I started working at Mozilla, the awesome company responsible for leading and coordinating the development of the Firefox browser. I’m now working for their labs team, exploring new ways of making the internet easier to use. Everyone I’ve met here so far is very friendly, intelligent, and motivated to make the web a better place; I’m really looking forward to working with them more.
One of the first tasks I’ve given myself here has been to get myself acquainted with the Mozilla build system, which is used to build Firefox, among other Mozilla projects. I’m most familiar with SCons, a Python-based tool we use at Humanized to develop Enso, and while I have some experience with Makefiles and the GNU Autotools, it’s been enlightening to see how the build system for a project as large as Firefox works.
While doing this, I spoke with Mike Meltzner, who passed me some gems of wisdom that were given to him by Vlad Vukicevic regarding a different way of setting up the build system than the one prescribed in the Mozilla Build Documentation.
I thought that the way Mike and Vlad did things was much more preferable than the one prescribed in the traditional build documentation, largely because it kept the CVS checkout 100% “pristine” and used a completely separate, parallel directory structure for everything else; aside from providing a really clean separation between what was under version control and what wasn’t, this gave me a much better idea of how the build system actually worked. Mike said that his way of doing things wasn’t documented anywhere, so I figured I’d write a simple script/tutorial that walks a reader through the setting up of the build system, the checking-out of Firefox from the source code repository, and the building of the application itself. It works on my OS X machine; I’m not sure if it works under cygwin or Linux, but I imagine it should.
Feedback is appreciated.
This is a script that will set up the Mozilla build system on your
computer and use it to check out and build Firefox.
It’s based on the information found here:
as well as some super-secret tricks that Mike Beltzner told me, which
were passed down to him by Vlad Vukicevic.
This script sets up the following directory structure:
mozilla-stuff/ - Root dir for everything.
mozilla/ - Contains the Mozilla CVS checkout,
and nothing else.
client.mk - The main Makefile for all Mozilla
builds/ - Contains build config files,
basic-firefox.mozconfig - A configuration file to build Firefox
with no bells or whistles.
basic-firefox/ - Where configuration-specific
makefiles and Firefox itself will
be built for the ‘basic-firefox’
‘mozilla-stuff’ will be the directory that stores our cvs checkout,
as well our build configuration information.
Check out the Mozilla makefile; this will also create the
‘mozilla-stuff/mozilla’ subdirectory, which will contain everything
cvs -d :pserver:email@example.com:/cvsroot co mozilla/client.mk
Use the Mozilla makefile to check out the ‘browser’ project
(firefox) to ‘mozilla-stuff/mozilla’.
make -f client.mk checkout MOZ_CO_PROJECT=browser
Create the ‘mozilla-stuff/builds’ directory. This will contain all
the build configuration files that we make, as well as the build
makefiles and all object files created by the build process.
Create a basic Mozilla configuration file that tells
the build system to create Firefox. You can embellish
this build configuration file later–for more information on that,
echo “. \$topsrcdir/browser/config/mozconfig” > basic-firefox.mozconfig
Create a directory for the makefiles and object files–formally
called an ‘objdir’–for our build of Firefox.
Build the makefiles for our build of Firefox.
Build Firefox. You may also want to use any of the following
* ‘-s’ tells the build script to run silently, which
improves build speed by about 20%.
* If you’re on a dual-core machine, ‘-j2’ will build things
Assuming this went okay, you should now have a build of Firefox on
your system. To run it on Windows/Unix systems, the Firefox executable
should be located in the directory:
To run Firefox on OS X systems, assuming that the Firefox
application name is ‘Minefield’, the Firefox executable should be
located in the directory:
Whenever you want to update your Firefox build, do the following:
(1) Enter ‘mozilla-stuff/mozilla’.
(2) Run ‘make -f client.mk checkout MOZ_CO_PROJECT=browser’.
(3) Enter ‘mozilla-stuff/builds/basic-firefox’.
(4) Run ‘make’.
(5) If step 4 worked, you’re golden. Otherwise, run
and go back to step 4.