User:RichardChu/Assignment 01: Building Firefox
This article details my experience with building Mozilla Firefox. This article outlines the build environment that was used, the prerequisite software that was installed, and the steps that were followed to successfully build Mozilla Firefox 3.0 (Minefield). This article also details the problems that were encountered, how the problems were solved, as well as the resources that were referenced.
The environment used to build Mozilla Firefox 3.0 (Minefield) contains the following relevant hardware:
- Pentium D CPU @ 3.00 GHz
- 250GB Hard Drive (208GB of free space)
- 2.0GB RAM
and relevant software:
- Microsoft Windows XP w/ Service Pack 2
- Microsoft Visual Studio 2005
- Visual C++ version 8
According to the Windows Build Prerequisites, the build environment used obviously met the recommended hardware requirements. However, the build system did not meet the software requirements.
The software required to build Firefox include:
- The platform SDK (which is included in Visual Studio version 7 and later)
- Compiler and linker (Visual C++ version 8; also included in Visual Studio)
- Cygwin (GNU tools for Microsoft Windows)
- CVS (included in Cygwin)
- moztools (package of binaries and libraries required to build Mozilla Firefox)
The build environment already had Microsoft Visual Studio 2005 installed. However, it did not have Cygwin, or the moztools package installed. Thus, before attempting to build Firefox, the tools were downloaded and installed.
- Cygwin was downloaded from http://www.cygwin.com. Once downloaded, the setup icon was double-clicked to start the installation process.
- The first screen is the Cygwin Setup screen. If you are really bored, you may read the contents of the screen. Otherwise, click Next.
- The next screen is the Choose Installation Type screen. In this screen, you may select an installation type, with the default being Install from Internet. Keep it as the default and click Next.
- The next screen is the Choose Installation Directory screen. In this screen, you may change where you want to install Cygwin. it is recommended to keep the default settings (as noted by the uppercase RECOMMENDED text in the screen). If you have trouble falling asleep, click on the Read more about file modes... link and read it. If you are still awake, click Next to proceed.
- The next screen is the Select Local Package Directory screen. This screen allows you to indicate where to store the installation files that it downloads. Keep it as the default or select another directory. Either way, click Next to proceed.
- The next screen is the Select Connection Type screen. The options are via direct connection, using IE5 settings, or via HTTP/FTP proxy. I suspect that for the majority of users, the Direct Connection option should be selected. Once the proper connection type is selected, Click Next.
- The next screen is the Choose Download Site(s) screen. From the list of available download sites, select one or more. Then click Next.
- The next screen is the Select Packages screen. This is the most important screen. This screen allows you to select the packages to install. I was tempted to select all of the packages to install but I was able to restrain myself and only select the packages required to build Mozilla, and then click Next. The required packages are:
- make 3.80 (only version 3.81 is listed so version 3.80 will have to be downloaded and installed separately)
- The next screen may be the Resolve Dependencies screen. In this screen, you may see a list of packages that depend on other packages that were not selected for installation. If it is not already checked, check the Install these packages to meet dependencies (RECOMMENDED) checkbox. Then click Next.
- The next screen is the Cygwin Setup screen where you can watch some progress meters as the packages are downloaded and installed. Watching the progress meters may be as fun as watching paint dry so you may want to do something else in the meantime.
- Once the packages have been downloaded and installed, the Create Icons screen appears. In this screen, you may check or uncheck some options to create icons on your desktop and start menu. Once done, click Finish.
Installing GNU Make 3.80
According to the Windows Build Prerequisites page, the version of GNU Make that Cygwin offers (3.81) is incompatible with the current Mozilla build system. Therefore, after Cygwin was installed, GNU Make 3.80 was downloaded and installed.
Since the file was a bzip2-compressed tar file, it is not recognized by Windows native zip utility. Thus, to uncompress and unpack the file, a Cygwin shell prompt was started and the present working directory (pwd) was changed to the location of the tar file. Once there, this command was issued at the prompt:
tar -xjf make-3.80-1.tar.bz2
Once uncompressed and unpacked, one should see a folder hierarchy similar to this:
usr/ |-bin/ |-info/ |-man/ |-man1/ |-share/ |-locale/
The make.exe file located in the usr/bin directory was copied to the C:\cygwin\bin directory and the usr folder along with all of its subdirectories were then moved to the C:\cygwin directory.
moztools is a package of binaries and libraries necessary to build Mozilla. Before downloading the moztools, the C:\proj directory was created. Then, the moztools package was downloaded and unzipped to the C:\proj directory.
Before Mozilla may be built, environment variables referencing the location of the platform SDK, location of where Cygwin is installed, and location of where the moztools package is installed needs to be set up. Therefore, this batch script was copied and pasted into a text editor. The MOZ_TOOLS environment variable was modified from C:\moztools to C:\proj\moztools. The batch script was saved as ConfigEnv.bat to C:\proj. The resulting batch script is:
rem --- Set HOME so that cvs and ssh work correctly rem --- cvs uses HOME to locate your .cvspass file, and ssh to locate your .ssh file rem --- if you are using ssh, your HOME should match the home directory specified in /etc/passwd. rem --- See http://www.cygwin.com/faq/faq0.html. set HOME=C:\home rem --- Set VCVARS to wherever the MSVC vcvars.bat file is found set VCVARS=C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat rem --- Set MSSDK to wherever the MS SDK is installed rem --- Only required for MSVC7 or the Free MSVC editions that don't come with an SDK set MSSDK=C:\Program Files\Microsoft Platform SDK rem --- Set MOZ_TOOLS to wherever you have the moztools packaged installed set MOZ_TOOLS=C:\proj\moztools rem --- Set CYGWINBASE to wherever cygwin is installed rem --- Do not use CYGWIN or else cygserver, cygrunsrv, and Cygwin services will not function properly rem --- Variable CYGWIN is also used to modify Cygwin's behaviour a little bit. set CYGWINBASE=C:\cygwin rem --- Make sure Cygwin does not print out a DOS style path warning set CYGWIN=nodosfilewarning rem --- Prepend Cygwin path rem --- This is necessary so that cygwin find is ahead of windows find.exe in the PATH, but cgywin link is after MSVC link.exe. set PATH=%CYGWINBASE%\bin;%PATH% rem --- Set MSVC environment vars call "%VCVARS%" rem --- Prepend SDK paths rem --- Only required for MSVC7 or the Free MSVC editions that don't come with an SDK set PATH=%MSSDK%\bin;%PATH% set INCLUDE=%MSSDK%\include;%INCLUDE% set LIB=%MSSDK%\lib;%LIB% rem --- moztools comes last set PATH=%PATH%;%MOZ_TOOLS%\bin rem --- Now the PATH variable contains: rem MS-SDK; MSVC; Cygwin; Windows; glib/libIDL; Moztools rem --- Typically the last thing the script does is launch a cygwin shell rem --- watch for your ~/.profile and /etc/profile which may overwrite your carefully setup PATH! bash --login -i
A command prompt was opened (Start -> Run... -> cmd) and the present working directory was changed to C:\proj using this command:
The batch script was executed to ensure that there were no errors in it. If there were no errors, you should see the Cygwin shell prompt.
Next, the file link.exe located in C:\cygwin\bin was renamed to _link.exe based on the recommendation that if you don't, you may get a configure error regarding the linker version being different.
Going back to the cygwin shell prompt, the present working directory was changed to C:\proj using the same command as above. Once we are in the correct directory, it is time to checkout the makefile that will be used to checkout the rest of the source files in the tree. To do this, the following command was executed:
cvs -d :pserver:anonymous:firstname.lastname@example.org:/cvsroot co mozilla/client.mk
Next, a .mozconfig configuration file was created based on the information located at the Configuring Build Options page. The resulting .mozconfig configuration file contains the following configuration options:
# Include default Firefox configuration file . $topsrcdir/browser/config/mozconfig # Build with Objdir mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-@CONFIG_GUESS@ # Optimizations ac_add_options --disable-optimize ac_add_options --enable-debug # Static Build ac_add_options --disable-static --enable-shared # Disable Installer ac_add_options --disable-installer
The file was saved as .mozconfig to the C:\proj\mozilla directory. Then, from the C:\proj directory, the following command was executed to checkout Firefox's default .mozconfig file:
cvs -d :pserver:anonymous:email@example.com:/cvsroot co mozilla/browser/config/mozconfig
The present working directory was changed to C:\proj\mozilla and the following command was executed to checkout the branch:
make -f client.mk checkout
Now that the source has been checked out, it is time to build Firefox. To do this, the following command was executed:
make -f client.mk build
If the build environment was set up properly, the build should proceed without interruption until completed. If this is the case, then just sit back, relax, and watch the scroll thumb slowly decrease in size for approximately an hour.
Problems Encountered and Solutions
During the build process, only one error occurred. The error message outputted was:
configure: error: To build the installer makensis is required in your path. To build without the installer reconfigure using --disable-installer.
The error message was clear and concise. After some self-deliberation, I decided to follow the latter option of building without the installer. Therefore, the error was solved by adding the following option to the .mozconfig file:
If I had read the MDC: Windows Build Prerequisites document more carefully, the error could have been avoided as NSIS would have been downloaded and installed or the above configuration option would have been added earlier.
- MDC: Build Documentation
- MDC: Windows Build Prerequisites
- MDC: Mozilla Source Code Via CVS
- MDC: Configuring Build Options
- MDC: Build and Install
Screenshot of Mozilla Firefox 3.0 (Minefield) Help > About window:
As long as you can carefully read, understand, and follow the build documentation, one should have minimal problems with building Mozilla Firefox 3.0 (Minefield).