Miriam Ruiz
random thoughts on technology and life

{September 01, 2009}   Compiling Firefox from scratch (in Debian)

After Madrid Mozilla Technologies Course (MMTC) in July, which was great, and apart from finding out that the people involved in the development of Mozilla are really lovely, I also found out that the technologies they support are very powerful and solid. As I learn more about Mozilla code, I plan to keep posting stuff here. Please, don’t be too hard with me if I say any stupid or obvious thing, keep in mind that I’m just learning for the moment. Of course, comments and feedback is totally welcome, especially if I can learn from it. You can also go to the Mozilla/URJC Planet to find more about the people involved in the course.

Lets start by downloading the latest source code. We shall use Mercurial for that. We can get the latest source code by doing

hg clone http://hg.mozilla.org/mozilla-central/ src

but, as it is explained here, you might want to check the status of the code regarding the automatic tests beforehand. To avoid poisoning my system with the tests I’ll do, I’m gonna use “/opt/mozilla” as my working directory. I might have used something under “/usr/local/” instead, it doesn’t really matter.

$ sudo mkdir /opt/mozilla
$ sudo chown miriam:miriam /opt/mozilla
$ cd /opt/mozilla
$ sudo aptitude install mercurial
$ hg clone http://hg.mozilla.org/mozilla-central/ src

OK, it will take a while to fetch the whole code tree, so take it easy.

Now, lets install the dependencies. According to the build-dependencies of xulrunner-1.9.1, these should be:

$ sudo aptitude install build-essential automake autoconf2.13 libtool \
libx11-dev libxt-dev libidl-dev libgtk2.0-dev libstartup-notification0-dev \
libgnomevfs2-dev libgnome2-dev libgnomeui-dev libcairo2-dev libpng12-dev \
libjpeg62-dev zlib1g-dev libbz2-dev libreadline5-dev libkrb5-dev python-dev \
libnspr4-dev libnss3-dev libhunspell-dev libdbus-glib-1-dev libsqlite3-dev \
liblcms1-dev libasound2-dev zip xvfb xfonts-base xauth java-gcj-compat-dev

Not bad, isn’t it? :)

The next step will be to set some sane build configuration options from which we can start working. We can store them in a file called .mozconfig inside the src directory. You can have a look at mine if you want.

Last, but not least, you might have a problem if the libpng in your system does not support the APNG format. You can choose between using the libpng that comes with Mozilla instead of the system one, or you can apply a patch to be able to compile it even without APNG support. Your choice.

Now, we’re really close now. Lets build the program:

$ export JAVA_HOME=/usr/lib/jvm/java-gcj
$ autoreconf --force
$ ./configure
$ make
$ make install

According to the parameter “–prefix=/opt/mozilla” in .mozconfig, the program will be installed in that directory. As we already have assigned it to our current user, there’s no need to be root or use sudo for that.

You can run it with “/opt/mozilla/bin/firefox”

OK, we now have our building system ready for modifying it and see what happens :P

Paul says:

Well well well… that’s a good start, but not the best way.
“./configure && make && make install” works, but there’s a more “beautiful” way:

Create your mozconfig:
$ cat mozilla-central/mozconfig
. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../build/
mk_add_options MOZ_MAKE_FLAGS=-j4
then, a simple:
$ make -f client.mk build
is enough
(make -f client.mk configure is like ./configure)
We have a lot of different useful rules in our Makefile, for example to build a Firefox package, à la http://ftp.mozilla.org.


Miry says:

Thanks Paul!

Oh, I forgot to add. If you, as me, want to test your new Firefox while you keep browsing the web with your stable one, just do:

/opt/mozilla/bin/firefox --createProfile DEV
/opt/mozilla/bin/firefox -P DEV

It might be useful to add it to your alias for a quick access (for example, to ~/.bashrc):

alias firefox-dev=’/opt/mozilla/bin/firefox -P DEV’

Leave a Reply


This is a personal webpage that belongs to Miriam Ruiz.
If you want to contact her, you can do at:

August 2019
« Nov    

La Lista de Sinde