Building Firefox on Mountain Lion 10.8

All the work that I’ve done on Firefox so far has been on a linux box.
I bought a mac recently so I’m in the process of switching all my dev tools.
To build Firefox on a mac is almost as straight forward as building on a linux distro.

Here are the steps:


First you’ll need to install macports.
Download the pkg installer for Mountain Lion or whatever version you are running and install macports

After the installation you’ll need to restart your shell so the $PATH gets updated.
You can find more details here

Once macports is installed:

$ sudo port selfupdate
$ sudo port sync
$ sudo port install libidl autoconf213 yasm mercurial ccache

The commands above will install all the dependencies you need to build firefox.

**More info on how to configure ccache here


Next it’s time to checkout the source code.

hg clone

It might take a while to clone the whole repo.


Now that you have both the dev dependencies and the source code the last thing missing is a .mozconfig file.
Below is a default configuration:

 ac_add_options –enable-debug  
 ac_add_options –enable-trace-malloc  
 ac_add_options –enable-accessibility  
 ac_add_options –enable-signmar

# Enable parallel compiling  
 mk_add_options MOZ_MAKE_FLAGS="-j12"

# Treat warnings as errors in directories with FAIL_ON_WARNINGS.  
 ac_add_options –enable-warnings-as-errors  
 ac_add_options –with-ccache

# Package js shell.  

You can find more info about .mozconfig here


Now it is time to start building.

First run:

make -f configure

That will make sure everything is setup properly, if you don’t see any error messages then you can start the build:

make -f build > build.out

A trick is to redirect the output of make to a file, it not only makes it easier to spot errors but it also decreases the build time.

Depending on your computer the build might take some time, don’t expect the build to finish before 15min, it will probably take something between 30min to 2h


Once the build is done, you can run Firefox by going to dir obj-dir/dist/ and launch the firefox executable.

Simple Firefox build
Mac OS X Build Prerequisites