Hack 93. Make Firefox Software
Turn Firefox source code into an executable program.
The Firefox product is open source, so you can make it yourself from the original code. This hack provides one pathway that gets you through this task on Linux. It provides a few pointers only for Windows and Macintosh. If you step off the narrow path described here, then you're on your own. Compiling a large product such as Firefox with custom code can be heinously complex.
9.4.1. Pointers for Windows and Macintosh
Here's a brief overview for Windows and Macintosh.
188.8.131.52 Getting oriented under Windows
The standard install is compiled with Microsoft Visual C++ (msvc); that's recommended as a starting point. The compile is not driven by a project definition file, and it does not use .NET (the /CLR option). The compilation process drives msvc entirely from the command line. You can get a free and fully functional command-line version of the compiler at http://msdn.microsoft.com/visualc/vctoolkit2003/.
The Firefox compilation system also requires free Cygwin tools (http://www.cygwin.com). This set of tools provides a rich, Unix-like environment, somewhat similar to Microsoft's free Microsoft Windows Services for Unix. Cygwin is ideal for the large, automated task that is Firefox compilation. Because this toolset is used as a starting point, automated compilation is not done in a traditional Microsoft-oriented way. For more details, try the official page at http://www.mozilla.org/build/win32.html. For one person's Firefox-on-Windows compile steps (using the free MinGW compiler), look to http://gemal.dk/mozilla/build.html.
Although it isn't officially supported, Firefox will compile and run under Windows 95, as well as more recent versions. Firefox does not deliver any of Windows's own DLLs in its install.
184.108.40.206 Getting oriented under Macintosh
Even more briefly, Firefox is supported only on Mac OS X. For best results, Mac OS X 10.3 or higher is recommended. The Firefox compile is a Mach-O compile, so your Mac OS X development box requires that Unix Services be present. Read all the gory details at http://www.mozilla.org/build/mac.html.
9.4.2. Getting Ready for Linux Compilation
These steps assume you have 2 GB of free disk space. That's a safe amount for one compilation of Firefox. For several separate experiments, have 10 GB free.
220.127.116.11 Checking your compile baseline
If you are going to compile Firefox, you don't want your development environment to be a moving target. Turn off all automated product/patch/package update mechanisms so that tool versions on your box are stable. Next, check that your box meets the build requirements documented at http://www.mozilla.org/build/unix.html. These commands will yield the version information you need:
ls /lib/libc* gcc --version perl --version gmake --version cvs --version gtk-config --version gtk ls /usr/lib/libIDL* zip -v
These are the equivalent RPM packages for rpm -q package-name:
glibc gcc perl make cvs gtk+ gtk2 libIDL zip
Don't radically update gcc just because it's possible. You can make a mess out of your box's standard headers and libraries if you're not careful. Work with what you have to start with.
18.104.22.168 Checking your runtime baseline
You also need to match the runtime requirements once the compile is finished. Minimum requirements are documented at http://www.mozilla.org/products/firefox/system-requirements.html. To test for the required versions, try these commands:
dmesg | grep -i 'linux version' xdpyinfo | grep -i version fc-cache -V ls /usr/lib/libstdc*
22.214.171.124 Grabbing a source baseline
The Firefox source is hosted in a CVS source code repository on the Internet at http://cvs.mozilla.org. Large portions of the repository are available via anonymous CVS login, including all source required for Firefox. To pull all the source files from the repository one by one is bandwidth-intensive, so the usual way to start is to pull a source code bundle (about 40 MB compressed) and then update that baseline to include the latest changes as a separate step. If you have lots of bandwidth, you can pull everything directly from the CVS server, as described next.
Of the required source, 90% is generic to Mozilla; only a small amount is Firefox-specific. Make a directory for each test compilation:
All source code tarballs are located at http://ftp.mozilla.org/pub/mozilla.org/. The most recent source code tarball is in this subdirectory:
The tarball for the official 1.0 release (from the defunct AVIARY_1_0_20040515 branch) is in this subdirectory:
Either way, once you've acquired the tarball, unpack it. Assuming you download to /tmp/source-archive.tar.bz2 and want to maintain the source in /local, run these commands:
mkdir -p /local/myfirefox cd /local/myfirefox tar --bzip -xvf /tmp/source-archive.tar.bz2
This creates a mozilla directory inside your myfirefox directory. Keep the top-level directory for your logs, notes, and other junk. Don't put junk inside the mozilla directory. Don't rename the mozilla directory either. You can use this setup to configure and compile one product at a time. You can't compile everything in one big hit without adding extra scripts. You can, however, compile Firefox, Thunderbird and other products in turn from the same mozilla directory. To do so, modify your mozconfig file after each product compiles [Section 9.4.3, later in this hack].
126.96.36.199 Updating the source
#!/bin/bash # interactively login with password 'anonymous' export CVSROOT=:pserver:email@example.com:/cvsroot cvs login # Get the Makefile that drives everything, including 'cvs' cvs co mozilla/client.mk # We're building Firefox specifically, get its app config file. cvs co mozilla/browser/config # Update to the latest source by asking 'make' to call 'cvs update' cd mozilla make -f client.mk checkout
If you're working with the old aviary branch, add -r AVIARY_1_0_20040515 to all cvs co commands. Don't ever use cvs update directly or by hand; always use make to call cvs indirectly via client.mk.
9.4.3. Compiling Firefox
To build Firefox, create one file called .mozconfig with your options in it and then set the compile running. Here's a script to automate that the process:
#!/bin/bash cd /local/myfirefox/mozilla # provide multi-build support for the ~/.mozilla/firefox profile. export MOZILLA_OFFICIAL=1 # build options for .mozconfig cat <<-'EOF' > .mozconfig . $topsrcdir/browser/config/mozconfig ac_add_options --enable-optimize ac_add_options --disable-debug mk_add_options MOZ_OBJDIR=/mnt/disk2/firefox EOF # set the compile running. make -f client.mk build
The magic MOZILLA_OFFICIAL variable allows Firefox to share existing profiles, without triggering complaints about versions and patches. The first line of the sample .mozconfig points the make system at the default options for Firefox. The next two lines are illustrative only and match the defaults. The last option tells Firefox to put all compiled stuff in /mnt/disk2/firefox. That last line keeps the source code tree free of compiled junk. If you ever compile directly in the source code tree (which works fine), this option won't work afterward. In that case, delete /local/myfirefox/mozilla and start again. Here's what you can put in .mozconfig:
To compile Thunderbird after the Firefox compile is finished, you must modify the .mozconfig file so that the compile is driven by Thunderbird's requirements, not Firefox's. Instead of this config line:
use this one:
To put the generated files somewhere separate from Firefox's, also change this line:
You can then run the compilation as before:
make -f client.mk build
9.4.4. Running Your Own Firefox
If the compile finishes without error, look for goodies in /mnt/disk2/firefox/dist/bin (in this example). Move to that directory and run ./firefox. Or set the MOZILLA_FIVE_HOME variable to that directory, update and export $PATH, and run Firefox from anywhere.
9.4.5. Creating a New Installer
#!/bin/bash cd /mnt/disk2/firefox/xpinstall/packager/unix make installer cd ../../../installer ls -l sea
cd /local/myfirefox/mozilla su root make install