So, I need to have a build of Firefox 4 ready to go by Friday. I use a Mac, so I built it for Mac OS X 10.6 x64. Here’s what I did to get it working.
Mac OS X Build Prerequisites
First, you’ll want to visit the Mozilla’s Mac OS X Build Prerequisites page. It has a detailed list of instructions that are guaranteed to work.
The first prerequisite is getting Xcode installed. Xcode is Apple’s IDE for Mac OS X and iOS development, but it also installs all of the CLI tools you’ll need to compile Firefox. I already have Xcode installed so I can skip this step. But if you need to install it, it’s available on Apple’s Developer site, you just need to sign up for a free developer account.
The next prerequisites to install are: libidl, autoconf213 and yasm. Now I’ve used macports, fink, and darwinports, but I heard about this new package manager called Homebrew. It is a lightweight package manager built on Ruby and git that utilizes Apple’s own libraries where possible to avoid conflicts. It seems pretty slick, so I’m going to use this instead of macports like Firefox demonstrates.
First, you install Homebrew by opening up Terminal.app and running:
ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"
This will download the homebrew install script, and install it into /usr/local, which is exactly where you want it:
Once you’ve installed homebrew, you can install libidl and yasm by running:
brew install libidl yasm
It’ll take a few minutes to install all the dependencies for libidl and yasm, but that’s all you need to do here. Now installing autoconf213 is a bit more work, because they don’t include the recipe for it. Fortunately, it looks like others have run into the same problem. Simply copy the following formula to /usr/local/Library/Formula/autoconf213.rb:
Once you’ve done that, you can now install autoconf213:
brew install autoconf213
Now you see that message about how Mac OS X already has autoconf installed? It’s true, you have version 2.61 installed. To use version 2.31 of autoconf, we need to run the link command:
brew link autoconf213
There’s one more program we need to install to compile Firefox: Mercurial. Mercurial is a distributed version control system (DVCS) built on Python, which means that it’s better than any regular VCS, and it’s more Windows-compatible than that other DVCS. If you have an hour of free time, you should watch Linus Torvalds’ Google tech talk “Source code control the way it was meant to be!”:
He makes a number of great points as to why we should all be using DVCS systems. Again, my personal preference is Mercurial because it’s more compatible with Windows, but I’ll take git if I can’t get Mercurial.
Downloading the source code
Now we need to grab the Firefox source code. Find somewhere you want to keep it and type:
hg clone http://hg.mozilla.org/mozilla-central
You’ll need to wait for it to download 1.1GB of data:
Configuring and Building Firefox
First thing we need to do is configure some build options. Create a file called .mozconfig in your home directory:
touch ~/.mozconfig
Then edit this file to the following:
. $topsrcdir/browser/config/mozconfig mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-ff-dbg mk_add_options MOZ_MAKE_FLAGS="-s -j4" ac_add_options --enable-debug ac_add_options --disable-optimize
Now we’re ready to build Firefox. cd to the root of mozilla-central and run:
make -f client.mk build
Now go and make dinner or something, because this’ll take awhile…

Congratulations! Assuming the build didn’t fail for some reason, you have a perfectly working copy of Firefox. You can run it by typing:
open obj-ff-dbg/dist/MinefieldDebug.app



