Hack 93. Make Firefox Software![]() ![]() 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 MacintoshHere's a brief overview for Windows and Macintosh. 9.4.1.1 Getting oriented under WindowsThe 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/win32l. For one person's Firefox-on-Windows compile steps (using the free MinGW compiler), look to http://gemal.dk/mozilla/buildl.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. 9.4.1.2 Getting oriented under MacintoshEven 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/macl. 9.4.2. Getting Ready for Linux CompilationThese 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. 9.4.2.1 Checking your compile baselineIf 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/unixl. These commands will yield the version information you need: ls /lib/libc*These are the equivalent RPM packages for rpm -q package-name: glibc gcc perl make cvs gtk+ gtk2 libIDL zipDon'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. h5You also need to match the runtime requirements once the compile is finished. Minimum requirements are documented at http://www.mozilla.org/products/firefox/system-requirementsl. To test for the required versions, try these commands: dmesg | grep -i 'linux version' 9.4.2.3 Grabbing a source baselineThe 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: mkdir /local/myfirefoxAll source code tarballs are located at http://ftp.mozilla.org/pub/mozilla.org/. The most recent source code tarball is in this subdirectory:Section 9.4.3, later in this hack]. 9.4.2.4 Updating the sourceUpdate the tarball source from CVS to the latest version using the following shell script: #!/bin/bashIf 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 FirefoxThe following instructions are accurate at the time of writing (February 2005). Compare CVS changes between then and now if you think the build process might have been modified or updated.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/bashThe 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:Common environment flags noted in mozilla/config/config.mkCommon command-line switches reported by running mozilla/configure --help 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: . $topsrcdir/browser/config/mozconfiguse this one: . $topsrcdir/mail/config/mozconfigTo put the generated files somewhere separate from Firefox's, also change this line: mk_add_options MOZ_OBJDIR=/mnt/disk2/thunderbirdYou can then run the compilation as before: make -f client.mk build 9.4.4. Running Your Own FirefoxIf 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 InstallerFollowing from the previous steps, here's how to make the install bundles that the Mozilla Foundation makes: #!/bin/bashIf you want to install Firefox, rather than make an installer, then run these commands instead: cd /local/myfirefox/mozilla |