# Building Mozilla on the Macintosh PPC platform

## Daniel Nunes, `leaf@netscape.com`

v 1.1, 1998-9-29
updated for the Pro4 IDE

How to build Mozilla on a Macintosh PPC System.

## 1. Introduction

## 2. Building Mozilla

- 2.1 Get the Code
- 2.2 Requirements
- 2.3 Set up the Build Environment
- 2.4 Build the Lizard

## 3. Common Problems

## 4. Credits

## 1. Introduction

What this document is: A guide to building the Mozilla application. This includes:

1. A listing of the development tools you will need to build Mozilla.
2. A list of environment variables you will need to set before building.

If you're looking for documentation on developing features or fixing bugs, the Mozilla Technical Documents or Library are probably what you're looking for.

## 2. Building Mozilla

- Each of the following subsections describes, or gives references to descriptions of, the steps necessary to build Mozilla.

  ## 2.1 Get the Code

  - There are two principal ways of getting the code, ftp and CVS. CVS will provide the most current code for building, but is slower than ftp. Ftp drops are generally produced once per month, and are known to compile.

  ## 2.2 Requirements

  The following need to be installed:

  - CodeWarrior (CW) Pro4 - obtainable from Metrowerks. See Common Sticking Points if you have a different version. Mozilla will no longer build with anything earlier.
  - PowerPlant - obtainable from the CodeWarrior CD.
  - MSL - the Metrowerks Standard Library, obtainable from the CodeWarrior CD
  - WASTE 1.3
  - CWASTE 1.6.2
  - Menu Sharing Toolkit (from UserLand)
  - Internet Config 1.4 SDK
  - AEGizmos 1.4.2
  - MacPerl 5 MPW Tool
  - MacPerl 5 Application
  - The module Mac:AppleEvents:Simple, which should be stored in your Perl library folder under :Mac:AppleEvents:Simple.pm, may be downloaded here.
  - The module Mac:Apps:Launch, which should be stored in your Perl library folder under :Mac:Apps:Launch.pm, may be downloaded here.
  - MakeStub - MPW (installed with CodeWarrior Heaven option). If you choose not to install MPW, it is located on the MacOS Tools CD in "CW Pro 4 Tools:CodeWarrior MPW:MPW:Tools"
  - RunTSScript - in Mozilla source distribution (mozilla:build:mac:RunTSScript), needs to be installed by hand
  - ToolServer - or in the CW distribution (CW Pro 4 Tools:Apple Development Tools:ToolServer 3.4.1.sit). We recommend pulling it off the CD because it comes with configuration files for CodeWarrior which you would have to create manually were you to pull it off the net.
  - patch 2.1

  Hardware/OS

  - To build Navigator, you need a fast PPC Mac. The faster the better.
  - You will need about 96 MB of physical RAM to "fast link" the app. You can still fast link if you give your machine 96 MB of virtual memory, but then the VM hit is large enough to counteract any improvement. One of our beta testers had a machine with only 64MB of physical RAM (VM was off) and it ran out of memory trying to link. Turning VM on got it to link, but build time increased greatly.
  - Reports from the net indicate that the optimized version (MozillaPPC) take much less RAM to build than the 96MB we suggest. If you are running out of memory, try building that instead of the debug version (the debug symbols require a lot of RAM come link time).
  - You should be ok with a 400MB disk partition, even when fully built. This does not include tools like the IDE, just source.
  - On an HFS+ volume, a full build takes about 110MB. HFS+ is good, but utilities are sparse.

  ## 2.3 Setup the Build Environment

  1. Install CodeWarrior from the CD. While it is large, installing the "CodeWarrior Heaven" option will guarantee that you have everything you need. This will give you PowerPlant, MSL, and MPW. If you choose to install less, proceed at your own risk.
  2. In the Finder, increase the memory partition of the IDE to 15MB (you can get by with 12, if need be).
  3. Uncompress the StuffIt Archive for ToolServer. The goal is to let ToolServer and MPW share the same Tools directory so you don't need to have multiple versions of tools. Do the following:
     1. Open ToolServer's Tools folder. There is one file called "RMetrowerks".
     2. Move RMetrowerks to Tools folder of MPW. MPW folder must be at "Metrowerks:Codewarrior MPW:MPW" if you installed Codewarrior Heaven.
     3. Remove ToolServer's Tools folder.
     4. Now create an alias of Tools folder in "CodeWarrior MPW" and move it to your ToolServer folder. Rename the alias (probably called "Tools alias") to "Tools"
     5. IMPORTANT: Make sure you only have one instance of ToolServer on your machine. If the build script finds the wrong one, the correct tools will not be found and strange things will happen.
  4. After installing the MacPerl MPW Tool distribution (run the InstallerVISE application), in the "MacPerl ƒ" folder, there will be an MPW tool named "perl". Install this in MPW's tools folder.
  5. Install the MacPerl Application (run the InstallerVISE application). You can install this anywhere, but it is recommended that you install it inside of your CodeWarrior folder for easy reference. After installation, you will need to set a preference to enable double-click launch of the perl scripts. This preference is set by going under the Edit Menu to Preferences. Click on the "Script" button and hit the radio button "Run Scripts opened from Finder"
  6. Install the "patch" and "MakeStub" Tools in the tools folder. Note that "MakeStub" is automatically installed by the "CodeWarrior Heaven" install option.
  7. Install RunTSScript (found in the Mozilla source distribution) in the compilers folder in your build environment ("Metrowerks:Metrowerks Codewarrior:Codewarrior Plugins:Compilers")
  8. Next, after downloading all the 3rd party software components, drag WASTE, CWASTE, Menu Sharing, Internet Config, and the AEGizmo folders (just as they are) into the "MacOS Support" folder in your build environment.
  9. Create a folder inside the PowerPlant folder (Metrowerks:Metrowerks CodeWarrior:MacOS Support:PowerPlant) called "_Will Be Obsolete" Make sure you include the leading underscore.
  10. Unstuff the obsolete LGA classes (located on the Reference CD in "CodeWarrior Examples:MacOS Examples:PowerPlant Examples:Obsolete PP Items:Old GA Classes.sit) and place the resulting folder into the "_Will Be Obsolete" folder you created in the previous step.
  11. Start ToolServer from within CodeWarrior (or use MPW if you are brave enough). We're about to patch some files. Make sure the ToolServer menu is in the CodeWarrior menu bar by turning on the preference under the "Extras" panel in the IDE Preferences (not the project preferences!). The menu bar should look like this:

      Choose "Start ToolServer" from the ToolServer menu (this is the icon menu between "Window" and "Help" in the menubar above). You will now see a window with no close box. This is your ToolServer Worksheet where you will type (or cut & paste) the commands for the following steps.

      In case you have never used MPW/ToolServer before, the following is very important. Pressing "return" does not execute commands like you might think. It just inserts a newline into the worksheet like a normal text editor. To actually get ToolServer to execute the command, you must press "Enter" (lower right of numeric keypad). This executes the line that the cursor is on, and only that line. If you want to execute multiple lines at once, select them all and hit Enter.

  12. Set the shell variables {IDE} and {Source} to the correct paths for your build environment. {IDE} is where your CodeWarrior IDE is located. {Source} is the folder containing the toplevel "ns" folder of the Mozilla source. Mine look like this (don't forget to keep the quotes if your path includes spaces), yours will almost certainly be different (to punctuate this, the things you need to change are in red).

          Set IDE "Develop:CW Pro 4:Metrowerks CodeWarrior:"
          Set Source "Source:FreeSource:"

  13. Execute the following lines to patch menusharing.c to allow it to compile with the new Universal Headers. It references an obsolete header file (GestaltEqu.h).

          directory "{IDE}MacOS Support:Menu Sharing Toolkit 4.1:"
          patch menusharing.c "{Source}mozilla:lib:mac:patches:menusharing.patch"

  14. You need to patch stat.mac.h to fix a problem in MSL where lines were omitted.

          directory "{IDE}Metrowerks Standard Library:MSL C:MSL Mac:Public Includes"
          patch stat.mac.h "{Source}mozilla:lib:mac:patches:stat.mac.h.patch"

  15. Congratulations! Now you are ready to build. Once these steps are done, you don't have to repeat these setups the next time!

  ## 2.4 Run the build

  - In the folder mozilla:build:mac:, there are several Perl scripts with names of the form BuildMozillaXXX.pl, where XXX is "Optimized", "Debug", "Tinderbox", et al. Each script builds the corresponding version of Mozilla. If you configured the MacPerl application to execute scripts that are opened from the finder, all you have to do is double click on the appropriate one; otherwise, launch MacPerl, and run the appropriate script from the "Run Script..." menu item.

    These `configured build' scripts are simple, and you might want to make your own to force your build to StopForErrors(), or alternatively DontStopForErrors(), et al. You can set up certain build-script variables and (soon) compile-time flags. Compare the supplied scripts to figure out what you might want. Note that CodeWarriorLib, Moz.pm, and BuildList.pm, are AppleScript libraries and Perl modules meant to be used by a `configured build'. Use your favorite POD viewer (Shuck comes with MacPerl) to view the documentation in the Perl scripts.

    If there were any errors in any of the projects along the way, the script will stop at that point and the IDE will tell you the errors. You can fix them and make sure they current project builds, but to continue the automation, you have to start from the beginning by double-clicking the script again. This isn't quite as bad as it sounds because the previous projects are already built (unless you changed some major header file). Please note that stopping the script once it has started is difficult. We are working to address this issue.

    After the build is complete, you can find aliases to the built libraries and the final Mozilla application. Debug builds are built to Mozilla:dist:client_debug, while optimized builds are built to Mozilla:dist:client.

    Don't worry too much about the numerous warnings generated during the build. We try our best to get the XP teams to use real compilers, but alas, they continue to write warning-laden code. There is also some generated code (Java is one example) that has a lot of warnings that we can't help either. If you write any new code, please help us in our quest to get zero warnings.

## 3. Common Sticking Points

- I only have CodeWarrior Pro3 or Pro2. How do i build with it?
  - Currently, the answer is, "You don't." We make use of several classes in PowerPlant which recently appeared in Pro4. Time to upgrade, I'm afraid. Don't even try opening the projects with Pro2 because you will get data loss and have to throw the project away (it won't even prompt you!)
- I'm having problems building. MacPerl tells me it can't fine MemAllocatorStubs
  - It sounds like your ToolServer environment is not setup correctly. Make sure you follow the directions to the letter. You could also be seeing this if you have multiple versions of ToolServer on your computer and the Finder lauches the wrong one. This is very common, as the Carbon Dater app from Apple DTS contains a copy of ToolServer. Either remove all the other versions of ToolServer or make sure you launch the appropriate version before you start building.
- The IDE runs out of memory building jsinterp.c. What do I do?
  - We have seen this every now and then, and it only appears to show up when building optimized (non-debug) builds. You can normally get around this by building that file by itself (select it and choose "Compile") and then continuing the make. We're not sure why this is happening, so if you have any answers or solutions, please let us know!

## 4. Credits

- The majority of this document is taken from the build document included in the Mozilla source distribution at README:mozilla:macbuild.htm written by Mike Pinkerton, pinkerton@netscape.com.