Easy ways of compiling Mozilla from source

Written by Klaus-Peter Schrage on 10-May-2004

'Easy' is a relative notion. Hard stuff for others might be trivial for you, so I'd define: A way of doing things that I experienced to be rather intuitive and easy to reproduce.

Installing mozilla binary builds in Linux

When a new version of mozilla comes up, ready-made builds for various computer architectures are offered for download at [1] in a subdirectory named

where '1.x' reflects the respective version number. You best get a file with a name like mozilla-i686-pc-linux-gnu-1.7.tar.gz, meaning a download of about 13 MB. From this, it is easy to install mozilla: Just drop it to a location that suits you, like /usr, /usr/local or /opt (do this as root), and uncompress it with
tar xfvz mozilla-i686-pc-linux-gnu-1.7.tar.gz
This creates a mozilla subdirectory. Change to this (as normal user) and start mozilla:
cd /opt/mozilla
That's all you have to do to launch the install process. A 'profile' named .mozilla to carry all your settings, bookmarks, mail boxes ... is created inside your $HOME directory, and if it is already there from an earlier installation, mozilla will recognize it.

Uninstalling mozilla is very easy: As all files are collected into a single mozilla directory, simply remove that and, apart from your personal settings in your profiles directory in $HOME/.mozilla/, there will be no traces left.

So far so good. If you are content with what you have now, you don't need to read on. But you can imagine that the builds from mozilla.org are configured (I'll talk about that later) to be like a least common denominator in order to run on nearly all flavours of Linux. If you want a special feature like xft-support to have smooth, antialiased fonts, you might be lucky to find a gtk2/xft enabled build in the

subdirectory of the ftp location [1], but these are published with a considerable time lag, and betas or release candidates aren't officially xft-tized at all.

So the idea comes up to roll your own mozilla binary from source. I don't want to compete with Doug's [2] and James' [3] articles on this topic to be found on the SxS site. The way I choose is more in line with the documentation at [4] and is guided by what you may call script avoidance.

There are some caveats against compiling mozilla on your own: You must be willing to handle a rather huge source that is a download of more than 33 MB and, being uncompressed, takes up more than 300 MB on your computer. And you have to spend a little time: A compile on my 2 GHz Pentium 4 system takes more than 40 minutes.
What annoys me a bit is the fact that, when a new version comes up, I can't find any diffs offered at mozilla.org to patch my source to the new version - I have to get 33 MB again to upgrade from, say, 1.7rc1 to 1.7 (please correct me if I'm wrong). You may use cvs to upgrade, but then you are on the bleeding edge of mozilla's developement. I don't use this on mozilla and I don't cover it here, see [4] for details.


I don't talk much about them. If you have a modern distro and have successfully done compiles before, it should work on mozilla as well. For details, see [4] and [5].

Get the source

which is NOT easy when you have a modem. It can be found in the

subdirectory of [1].

I fetched the tar.bz2 version (there is an even larger tar.gz file ) which you uncompress with

tar xfvj mozilla-source-1.7.tar.bz2

This will create a mozilla directory wherever you have dropped and uncompressed the .tar file.

Prepare the build

Change into the mozilla source directory:

cd mozilla
The following settings are not vital; they seem to provide for the correct build date and ID in your binary:
The next and probably most important step is the ./configure command. I use these settings:
./configure \
  --disable-tests \
  --disable-debug \
  --enable-optimize \
  --without-system-nspr \
  --without-system-zlib \
  --without-system-jpeg \
  --without-system-png \
  --without-system-mng \
  --enable-crypto \
  --enable-xft \
For me, the last two ones are most interesting. (Remember that the command has to be writted in a single line). There is an alternative way of passing these parameters to the ./configure command:

A good explanation of the parameters is given in [5].
By the way, the above mentioned settings are exactly those used in recent gtk2/xft enabled builds from [1].

If ./configure stops with an error message about missing gtk2 or xft libraries, either install them or deactivate the last two options. This gives you what I have called a least common denominator above.


Simply type

and listen to a nice CD, the compilation should take about that long.

If the make command finishes without errors, you are nearly done. If not, you are in trouble and should carefully read Requirements above ;-).

You can immediately test your build by typing (you are still in you mozilla source directory):

cd dist/bin
You might run mozilla as often as you want from this location. But, after 'make", your source has blown up to nearly 400 MB, so you'd prefere to have a binary to install it elsewhere and then to clean up your source with
make clean
or even remove it.

Optimizing a configuration

You can try to change all or several of the 'without' terms in the configuration to 'with' if you want to utilize the corresponding libraries that are probably already installed on your system. Strange enough, I found no measurable space savings compared to having mozilla build its own libraries.
If you want to experiment with different configurations, dont forget to type

make clean
before starting anew - I know what I'm talking about!

There are recommendations to patch the source code directly to make mozilla a little bit more secure, see [2] or [6] for that.


Version 1: Make your own tar.gz installation package

There is a mechanism included in the source to prepare a package similar to the binary builds available from mozilla.org that you can install the way described above. Change to the following directory in your source

and type

This process will take some minutes. After it has finished, you will find a file named

in the
subdirectory that you can treat like an official mozilla.org build - you can even port it to another computer if you like.

Version 2: Simple copy

Create (as root) a target directory of your choice

mkdir /opt/mozilla
change to
and copy over all files from there:
cp -aL * /opt/mozilla/
The directory dist/bin/ contains a lot of links to files in other locations inside the source. The 'L' parameter assures that all these files are copied properly.

Version 3: make install


make install
as root from the top source directory surely is the classic installation method. Different types of files are spread to their proper locations:


All three methods will give you a working mozilla suite. None of them is explicitely recommended at [4] - their build instructions only cover the make process, running mozilla from dist/bin/, and preparing a tar.gz file for the purpose of distribution (version 1 above). I personally prefer version 1, there is some housekeeping going on before copying and compressing the build files, so that the space requirements are somewhat minimized. A comparison, based on the same build configuration mentioned above, yields:
   version 1 : version 2 : version 3 = 40 MB : 47 MB : 58 MB.
Furthermore, I like the simple way of uninstalling a version, allowing to keep multiple mozilla builds for testing before finally switching to an upgrade. With version 3, there is no 'make uninstall' target to get rid of the beast the easy way.


[1] ftp://ftp.mozilla.org/pub/mozilla.org/mozilla/releases/

[2] Doug Hunley: Compiling Mozilla from source

[3] James McDonald: mozilla / firebird / thunderbird build system

[4] www.mozilla.org/build

[5] http://www.linuxfromscratch.org/blfs/view/stable/xsoft/mozilla.html

[6] Salvador J. Peralta: Mozilla Optimization Mini-HOWTO

searchSearch Index