Building Firefox on Linux is actually pretty easy. It used to be a bit harder with earlier versions of Firefox, but since Gecko 5.0 it’s not hard at all.
Since we are building on BackTrack 5, which is a Debian offspring, we more or less need to follow the instructions on building Firefox on Ubuntu. Some details about that can be found at Simple Firefox build. As you will see later, the only tricky part is to get all the required packages for the build process.
Get the Source, Luke
First we have to install the suggested packages with apt-get:
root@bt:~/firefox# apt-get install mercurial libasound2-dev libcurl4-openssl-dev libnotify-dev libxt-dev libiw-dev mesa-common-dev autoconf2.13 yasm
Now, let’s get the latest Firefox source through mercurial:
root@bt:~/firefox# hg clone http://hg.mozilla.org/mozilla-central/
All that is left to do is to start the build:
root@bt:~/firefox/mozilla-central# make -f client.mk
Missing Dependencies
At the beginning of the build process it checks that all the needed build tools and libraries are installed. Unfortunately, it complained that the installed version of yasm was too old in my case:
checking for YASM assembler... checking for yasm... yasm configure: error: yasm 1.0.1 or greater is required to build with libjpeg-turbo's optimized JPEG decoding routines, but you appear to have version 0.8.0. Upgrade to the newest version or configure with --disable-libjpeg-turbo to use the pure C JPEG decoder. See https://developer.mozilla.org/en/YASM for more details. *** Fix above errors and then restart with "make -f client.mk build" make[2]: *** [configure] Error 1 make[2]: Leaving directory `/root/firefox/mozilla-central' make[1]: *** [obj-x86_64-unknown-linux-gnu/Makefile] Error 2 make[1]: Leaving directory `/root/firefox/mozilla-central' make: *** [build] Error 2
dpkg -l also told me the same thing. The installed version of yasm was 0.8.0-1:
root@bt:~/firefox/mozilla-central# dpkg -l | grep yasm ii yasm 0.8.0-1 modular assembler with multiple
I didn’t find a newer version of yasm in the BackTrack repository. So I went to Debian Packages and downloaded the current release of yasm for Debian Testing, which was 1.1.0-1 at the time. Since I am running BackTrack 5 64bit, I needed to get the amd64 version.
root@bt:~# wget http://ftp.us.debian.org/debian/pool/main/y/yasm/yasm_1.1.0-1_amd64.deb
A .deb package can be installed with dpkg –install. It replaces a currently installed version:
root@bt:~# dpkg --install yasm_1.1.0-1_amd64.deb (Reading database ... 214367 files and directories currently installed.) Preparing to replace yasm 0.8.0-1 (using yasm_1.1.0-1_amd64.deb) ... Unpacking replacement yasm ... Setting up yasm (1.1.0-1) ... Processing triggers for man-db ...
After trying to build again, it complained about the missing libIDL2-0:
checking for libIDL-2.0 >= 0.8.0... Package libIDL-2.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `libIDL-2.0.pc' to the PKG_CONFIG_PATH environment variable No package 'libIDL-2.0' found configure: error: Library requirements (libIDL-2.0 >= 0.8.0) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them. *** Fix above errors and then restart with "make -f client.mk build" make[2]: *** [configure] Error 1 make[2]: Leaving directory `/root/firefox/mozilla-central' make[1]: *** [obj-x86_64-unknown-linux-gnu/Makefile] Error 2 make[1]: Leaving directory `/root/firefox/mozilla-central' make: *** [build] Error 2
We can find the name of the missing package with the help of apt-cache.
root@bt:~/firefox/mozilla-central# apt-cache search libidl libidl0 - library for parsing CORBA IDL files libidl-dev - development files for programs that use libIDL
Usually when compiling stuff, we need the -dev version of a package, which contains header files and linkable libraries required for a build. Therefore we can assume that libidl-dev is the missing package. We can install it with apt-get since it is in the BackTrack repository this time:
root@bt:~/firefox/mozilla-central# apt-get install libidl-dev
A Monster Is Born
All dependencies should be fulfilled now, and it should compile without further complaints. Once the build has finished, you can find the executable at
obj-x86_64-unknown-linux-gnu/dist/bin/firefox
I suggest, that you compile the source on a strong machine. I was doing it inside a VirtualBox VM, which was not such a good idea. The built took about three hours. The VM even kept crashing on me while building libxul.so. I had to give the VM 2 gigs of RAM (initially 1GB) to make it work.
Debug Build
Since I wanted to find out something about the internal workings of Firefox, it would be handy if I could run Firefox inside a debugger like ddd. It’s reasonable to compile Firefox with debug symbols for that reason. That can be accomplished by specifying special compile setting within a file named .mozconfig in the root folder of the Firefox source tree:
root@bt:~/firefox/mozilla-central# echo "ac_add_options --enable-debug-symbols" > .mozconfig
You can find out more about configuring the build at Configuring Build Options and Building Firefox with Debug Symbols.