Mac OS X Build Prerequisites
From MDC
Mozilla builds for Mac OS X are Mach-O builds, built with gcc and Makefiles. Doing builds on Mac OS X is therefore very similar to doing Unix/Linux builds. You should be comfortable using the Terminal app (in /Applications/Utilities). Additional instructions are available for building Mozilla as a universal binary.
The CodeWarrior-based CFM build system is obsolete, and has not worked since Mozilla 1.3alpha.
If you run into problems, see the Mozilla Build Frequently Asked Questions or the rest of the Mozilla build documentation.
Contents |
[edit] Firefox Quick Start
It only takes a few steps to get Mozilla building for most people, for most purposes. The other sections on this page go into more detail on complete build requirements for various Mozilla projects. These steps will get the most recent (trunk) version of Firefox built on Mac OS X 10.5.
1. Install Xcode Tools. This is on your Mac OS X install DVD: open the "Optional Installs" folder, then open the "Xcode Tools" folder, then open XcodeTools.mpkg.
2. Install MacPorts. Go to their install page, download the .dmg for your platform, and install it.
3. Install libIDL. This is needed by Mozilla and is easily installed with MacPorts and other things that are also needed, such as glib, will be installed along with libIDL. Open up a terminal and run the following:
$ sudo port install libidl (you may be asked to enter your OS X password to create a shell with elevated privileges)
4. Get the Mozilla source with CVS. Open a terminal, and run the following (from a subdirectory, if you wish):
$ cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/client.mk $ cd mozilla $ make -f client.mk checkout MOZ_CO_PROJECT=browser
5. Configure the build you want. You can do this by creating a .mozconfig file in the mozilla directory created above, or by adding options to the checked-out mozilla/browser/config/mozconfig file, or with a .mozconfig in your home directory. A .mozconfig must have this as its first line:
. $topsrcdir/browser/config/mozconfig
And then other options can be added, such as:
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-ff ac_add_options --enable-debug ac_add_options --enable-testing
For other options, see Configuring Build Options
6. Configure and build the browser.
$ cd mozilla $ ./configure --enable-application=browser $ make
[edit] Hardware Requirements
There are no specific hardware requirements, provided that the hardware accommodates all of the software required to build Mozilla. Mozilla can take a very long time to build, so recommended development systems are listed alongside the minimum requirements.
- Processor: PowerPC G3 or later, PowerPC G5 or Intel CPUs recommended. Mozilla can now be built for either type of processor, or as a universal binary for both types (see Mac OS X Universal Binaries).
- Memory: 256MB RAM minimum, 1GB recommended.
- Disk Space: At least 1GB of free disk space for non-debug builds; development/debug builds require at least 2.5GB of free disk space.
[edit] Software Requirements
- Operating System: Mac OS X 10.4.11 or later. It is advisable to upgrade to the latest “point” release (currently 10.4.11 and 10.5.2) by running Software Update, found in the Apple menu. Beginning with Mozilla 1.9 (the current trunk), Mac OS X 10.4 is both a build- and run-time requirement. Mozilla’s 1.8.0 and 1.8.1 branches will run on Mac OS X 10.2 (“Jaguar”), but the build requires a minimum of 10.3 (“Panther”). No recent version of Mozilla will build or run on 10.1 (“Puma”). For additional details, see the Mac compatibility matrix.
To install the following software requirements, you may need administrative privileges on the system.
- Development Environment: Xcode Tools 2.1 or later. Earlier versions of Xcode and Developer Tools are no longer supported (Xcode 1.5 is still supported on the Mozilla 1.8 and 1.8.0 branches). Xcode 2.0 is not recommended, but Xcode 2.1 and later work properly. Tested Xcode configurations are listed in the Mac compatibility matrix. Installing the cross-development environments (SDKs) is required; consult the Mac compatibility matrix to find the specific SDKs required for the branch(es) and product(s) you are building. These are selected by clicking the “Customize” button in the Xcode installer. There are two ways to obtain or upgrade Xcode:
- Download: Download Xcode from Apple. This ensures that you’ll install the latest version of the tools available for your computer. You’ll need a (free) Apple Developer Connection membership. Note that Xcode updates are not installed by Software Update at this time.
- DVD or CD: Most Macs and retail versions of Mac OS X include an Xcode installer on the installation discs. Check your discs for Xcode or Developer Tools.
- Package Management: A package management system is not strictly required, but simplifies the installation of additional build dependencies. There are two package management systems that are compatible with the Mozilla build system, Fink and MacPorts (formerly DarwinPorts). Note that package installation may be a time-consuming but automated process using either tool.
- MacPorts, formerly DarwinPorts. You may download the MacPorts installer corresponding to your operating system release. MacPorts installs in
/opt/localby default. After running the MacPorts installer, the changes that it makes to the shell environment will be available in any new Terminal window. - Fink. You may download the most recent version of Fink that is compatible with your operating system release. Fink installs in
/swby default. The installer should configure the Fink environment for you, making it available in any new Terminal window. If you perform a major operating system upgrade on your computer, such as an upgrade from Tiger to Leopard, you should remove the/swdirectory and re-install Fink and the packages below. Note: fink doesn't seem to be as well maintained (in terms of available packages) as macports, so it is strongly suggested that you use macports instead of fink. - libIDL and GLib, libraries used by Mozilla’s IDL (interface definition language) file parser. These may be installed using a package manager. Administrative privileges are required, provide your password to the
sudocommand if requested.- Using Fink. libIDL is included in the ORBit installation.
$ sudo apt-get update $ sudo apt-get install orbit orbit-dev glib
- Using MacPorts (DarwinPorts). Installing libIDL also installs GLib.
$ sudo port sync $ sudo port install libidl
- Using Fink. libIDL is included in the ORBit installation.
- autoconf version 2.13 is only needed if you plan on making changes to the Mozilla configure.in files. Newer versions of autoconf, including those that are included with Xcode and installed in
/usr/bin, are incompatible with Mozilla (bug 104642). - Using Fink. autoconf is installed at
/sw/bin/autoconf. Do not install theautoconf2.5orautoconf2.54packages.$ sudo apt-get install autoconf
- Using MacPorts (DarwinPorts). autoconf is installed at
/opt/local/bin/autoconf213. You will need to typeautoconf213to run it when other documentation might instruct you to runautoconf. Do not install theautoconfpackage without the213suffix.$ sudo port install autoconf213
- If building from one of the Mercurial repositories rather than CVS, it is useful to make the program available as
autoconf-2.13:$ cd /opt/local/bin $ sudo sh -c 'for f in *213; do ln -s $f ${f%213}-2.13; done'
[edit] .mozconfig Options and Other Tunables
These options are specific to Mozilla builds for Mac OS X. For a more general overview of build options and the .mozconfig file, see Configuring Build Options. For specific information on configuring to build a universal binary, see Mac OS X Universal Binaries.
- Compiler: If you are using Mac OS X 10.4 (“Tiger”) or later on PowerPC and are working on the 1.8 branch or earlier, you should change the system default compiler to gcc 3.3, the compiler used to produce official PowerPC builds. Use the following command:
$ sudo gcc_select 3.3
As an alternative to changing the system default compiler, you may specify the compiler to use for a Mozilla build at configure time by setting the
CCandCXXenvironment variables to select your desired C and C++ compilers. You can enter these commands in the Terminal before starting a Mozilla build, or you can place them in your.mozconfigfile:export CC=gcc-3.3 export CXX=g++-3.3
Mozilla will build with gcc 4.0 (provided that Xcode 2.1 or later is installed), and some developers prefer this newer compiler. Applications built using gcc 4.0 will only run on Mac OS X 10.3.9 and later. Official Intel builds are produced with gcc 4.0. Intel builds must be produced with gcc 4.0 (Apple's gcc 3.3 cannot produce Intel binaries), but you can use gcc 3.3 on an Intel Mac to cross-compile for PPC. The current trunk (Mozilla 1.9) requires gcc 4.0 to build.
Be aware that the gcc 3.3 compiler for Mac OS X at optimization level-O3is unable to build Mozilla, and that any compiler with the-fastoptimization mode selected on PowerPC will result in a build failure.
The following options, specified with ac_add_options, are lines that are intended to be added to your .mozconfig file.
- Mac OS X SDK: This selects the version of the system headers and libraries to build against, ensuring that the product you build will be able to run on older systems with less complete APIs available. Selecting an SDK with this option overrides the default headers and libraries in
/usr/include,/usr/lib, and/System/Library. Mac OS X SDKs are installed in/Developer/SDKsduring the Xcode installation by selecting the Cross Development category in the installer’s Customize screen.ac_add_options --with-macos-sdk=/path/to/SDK
Official trunk builds use
/Developer/SDKs/MacOSX10.4u.sdk. On the 1.8.0 and 1.8.1 branches, official PowerPC builds use/Developer/SDKs/MacOSX10.2.8.sdk, while official Intel builds use/Developer/SDKs/MacOSX10.4u.sdk.Note that some frameworks (notably AppKit) behave differently at runtime depending on which SDK was used at build time. This may be the source of bugs that only appear on certain platforms or in certain builds.
You will not be able to build Mozilla using the 10.2.8 SDK included in the Xcode 2.4 installer. Upgrade to Xcode 2.4.1 or newer.
Use of an SDK is highly recommended, especially when building on Mac OS X 10.3 with Xcode 1.5. - Deployment Target: This option selects the minimum OS version that the resulting application will run on. Proper use of this option requires additional support in the code.
ac_add_options --enable-macos-target=version
This option is not recommended. The default for the trunk on all platforms is10.4. The default for PowerPC builds on the 1.8.0 and 1.8.1 branches is10.3, while the default for Intel builds on those branches is10.4. Official builds use these defaults. - Prebinding: The Mozilla build system allows you to build an application and libraries that are prebound. This improves application launch time on Mac OS X 10.3.3 and earlier.
ac_add_options --enable-prebinding
The default is to not prebind. Official PowerPC builds are prebound. Official Intel builds are not prebound, as no Intel build will run on any release earlier than 10.4. - Sample
.mozconfig: This.mozconfigfile is suitable to build an Intel version of Minefield (equivalent to Firefox), which will only run on Intel-based Macs running Mac OS X 10.4 or newer:. $topsrcdir/browser/config/mozconfig ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.4u.sdk ac_add_options --disable-tests
This
.mozconfigfile is suitable to build a PowerPC version of Minefield (equivalent to Firefox) from the Mozilla 1.8 and 1.8.0 branches able to run on the widest possible range of computers. This may be used on any PowerPC Mac meeting the software requirements:export CC=gcc-3.3 export CXX=g++-3.3 . $topsrcdir/browser/config/mozconfig ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.3.9.sdk ac_add_options --enable-prebinding ac_add_options --disable-tests
[edit] Build Defines
For Mac OS X builds, defines are set up as follows:
-
XP_MACOSXis defined -
XP_UNIXis defined -
XP_MACis not defined.XP_MACis obsolete and is slowly being removed from the source tree (see bug 281889). It was used for CFM (non-Mach-O) builds for the classic (pre-X) Mac OS.
This requires care when writing code for Unix platforms that exclude Mac:
#if defined(XP_UNIX) && !defined(XP_MACOSX)
[edit] Troubleshooting
- After installing Xcode 2.4, the build fails in
nsLookAndFeel.cppwith:error: `kThemeBrushAlternatePrimaryHighlightColor' undeclared (first use this function).The 10.2.8 SDK included in Xcode 2.4 (build 8K1079) contains a bug that prevents Mozilla from building with that SDK. Apple has been notified of this bug, which is being tracked as Radar 4671592. This bug has been fixed as of Xcode 2.4.1.
- After installing QuickTime 7.0.4 on Mac OS X 10.3.9, the build fails in
libwidget_mac.dylibwith:ld: /usr/lib/gcc/darwin/3.3/libstdc++.a(eh_personality.o) illegal reference to symbol: ___cxa_begin_catch defined in indirectly referenced dynamic library /usr/lib/libstdc++.6.dylib.To work around this conflict, you will need to use an SDK. Select the
MacOSX10.2.8.sdk(recommended), or, if you must, you can also useMacOSX10.3.0.sdk. See the section on .mozconfig Options and Other Tunables for detailed instructions on using an SDK.Apple linked the QuickTime 7.0.4 framework against the shared libstdc++.6 library available in Mac OS X 10.3.9 and later, but the compiler (gcc 3.3) and build tools used on these systems do not expect to link against this library. gcc 3.3 expects to use its own statically-linked libstdc++. The QuickTime stub frameworks in the SDKs do not share this problem.
- QuickTime SDK Update: If you install or update QuickTime 7, you may also need to install an updated QuickTime SDK, available from “Software Update” in the Apple menu. This update is only needed if Software Update indicates that it is available to you. You will need this update if your build fails because it is unable to find
Sound.r. - Using Fink, you get
apt-get: command not found.apt-getis not in your$PATH. Close and reopen Terminal and try again. If the error persists, Fink was unable to fully configure itself in your environment. Take these steps:- If you use the
bashshell, the default since Mac OS X 10.3, edit your~/.bashrcfile, adding the following line. Don’t neglect the leading period and space.. /sw/bin/init.sh
- If you use the
tcshshell, edit your~/.tcshrcfile, adding the following line:source /sw/bin/init.csh
After modifying the appropriate file, close and reopen Terminal and try again.
- If you use the
port: command not found.
port is not in your $PATH. Close and reopen Terminal and try again. If the error persists, DarwinPorts was unable to fully configure itself in your environment. Take these steps:
- If you use the
bashshell, the default since Mac OS X 10.3, edit your~/.profilefile, adding the following line:export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
- If you use the
tcshshell, edit your~/.tcshrcfile, adding the following line:setenv PATH "/opt/local/bin:/opt/local/sbin:$PATH"
After modifying the appropriate file, close and reopen Terminal and try again.
/sw. If you have Virex installed, you will need to upgrade to at least version 7.2.1, as described in the Fink News (2003-04-16).libwidget.rsrc in widget/src/mac
Delete, or rename ~/Library/Preferences/.GlobalPreferences.plist. We're not quite sure what setting in that file is causing this problem. Note that if you remove this file, system preferences such as preferred locales and recent programs will also disappear.
apt-get, and that you edited your .bashrc to source the /sw/bin/init.sh file or your .tcshrc file to source the /sw/bin/init.csh file.dlfcn.h with error nsTraceRefcnt.cpp:68: dlfcn.h: No such file or directory
Make sure you have the libdl.dylib from Fink. If you install bash from Apple, it will provide a copy of libdl.dylib which will not come with the headers (eg. dlfcn.h) needed to compile new programs that use the library, such as Mozilla. The solution is to remove the bash from Apple and install the bash from Fink. (Thanks to Alex Stewart for helping us track this down.)