Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

火狐浏览器编译简介

你可以在命令行下,编译一个最新的,开发版的火狐浏览器。更完整的编译信息,请参见编译文档(英)。

安装编译工具

如果你的系统没有以下列表中的工具, 请参见编译先决条件页面(英)。

Ubuntu Linux:
sudo apt-get build-dep firefox
sudo apt-get install mercurial libasound2-dev libcurl4-openssl-dev libnotify-dev libxt-dev libiw-dev mesa-common-dev autoconf2.13 yasm
Fedora Linux:
sudo yum groupinstall 'Development Tools' 'Development Libraries' 'GNOME Software Development'
sudo yum install mercurial autoconf213 glibc-static
Mac:
  • Install Xcode Tools. Insert "Mac OS X Install Disc 2", then open XcodeTools.mpkg.
    (For some Mac OS X versions, you will find it in a directory called "Optional Installs".)
  • Install MacPorts.
  • Run these commands to install the other build tools:
    sudo port sync
    sudo port install mercurial libidl autoconf213 yasm
    

Problems? See Mac OS X build prerequisites.

Windows:
  • 如果你使用的是Windows XP操作系统, 你必须安装Windows XP Service Pack 2 补丁包和.NET Framework 2.0
  • 安装 Visual C++ 2005 or 2008. 它们的professional edition版本和express edition 都可以正常工作。
  • 你可能需要安装一个或者多个Windows SDK。详见Windows SDK versions的快速向导页。
  • 安装MozillaBuild,一个附加的编译工具包。(如果你得到一个信息说这个应用程序不能被合适的安装,那么你应该看见一
    个对话框窗口让你设置选项以便用正确的设置重新安装。之后,所有都应该是好用的。)
  • 运行打开一个windows shell:c:\mozilla-build\start-msvcX.bat (当vs2005时,X是8,vs2009for VS 2005, and 9 for VS 2008).即使你是在64位windwos下, 不要用以-x64.bat结尾的批处理。

问题?参见 在windows下编译的先决条件(英)。

编译火狐浏览器

编译火狐浏览器需要至少1GB的硬盘空间,500MB的内存和很多可用的交换分区空间。

# 得到源码
hg clone https://hg.mozilla.org/mozilla-central/
cd mozilla-central

# 准备一个基础的mozconfig文件
echo '. $topsrcdir/browser/config/mozconfig' > mozconfig                      # 让我们编译火狐浏览器...
echo 'mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir-ff-release' >> mozconfig   # ...在这个目录下...

# 并行编译是个很不错的加速方式
# 如果不在Windows下使用这个方式!  由于 BUG 524149,在Windows下,
# 并行编译目前是不可靠的。
echo 'mk_add_options MOZ_MAKE_FLAGS="-j4"' >> mozconfig

# 编译
make -f client.mk
  • 在Windows下, shell可能默认使用带有空格在路径中的目录(例如 "Documents and Settings")。这可能影响一些操作。确信你的clone不是在这样的目录之下。例如,首先做"cd /c" 以便clone到目录C:\mozilla-central中。
  • OS X 10.6 ("Snow Leopard") users will need extra options in their mozconfig, see the OS X Build Prerequisites page for details.
  • 建立一个Debug版本,你需要不同的配置参数在你的mozconfig文件Debug版需要更多的硬盘空间,大约2.5 GB。
    . $topsrcdir/browser/config/mozconfig
    mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir-ff-debug
    ac_add_options --enable-debug
    ac_add_options --disable-optimize
    
  • 火狐浏览器的执行文件位于"objdir-ff-release/dist/bin/"路径下 (on Mac, objdir-ff-release/dist/Minefield.app/Contents/MacOS/)。

此后,怎样再次编译?

在你的mozilla-central目录,运行这些命令:

# 得到最新版本的源代码
hg pull -r default
hg update

然后仅仅重新运行"make -f client.mk"命令。make将仅仅重新编译那些改动的文件,但是它仍然是一个长时间的过程。一个增量编译(英)可以更快。

 

文档标签和贡献者

 此页面的贡献者: ted423, ziyunfei, mozstudy
 最后编辑者: ted423,