根据 Mozilla 官方网站上的编译步骤操作总会遇到各种各样的错误提示,以下是在虚拟机环境下验证通过的编译步骤。
1、准备工作
1) 依次安装 Visual C++ 6, Visual C++ Service Pack 5, Visual C++ Processor Pack。
2) 安装 cygwin 至 C 盘根目录,选择 DOS 风格(默认为 UNIX 风格)。除默认组件外,还应选择以下组件:
# ash -- UNIX-like command line interpreter shell
# autoconf -- Wrapper scripts for autoconf2.1 and autoconf2.5
# coreutils -- GNU core utilities (includes fileutils, sh-utils, and textutils)
# cvs -- Concurrent Version System
# diffutils -- file comparison utility
# findutils -- Utilities for finding files--find, xargs, locate, updatedb
# gawk -- pattern matching language (Devel category)
# gcc -- C compiler upgrade helper
# grep -- text search tool
# make -- dependency analyzer for software builds (Devel category)
# patchutils -- a small collection of programs that operate on patch files
# perl -- a scripting language used to control parts of the build (Interpreters category)
# sed -- a search and replace language
# unzip -- zip file extraction (Archive category)
# zip -- zip file creation (Archive category)
3) 下载并解压 firefox-1.0.7-source.tar.bz2 至 C 盘根目录,解压后生成 c:\mozilla 目录。
4) 下载并解压 Netscape's wintools,在 buildtools 目录编写以下 BAT 文件,运行后生成 moztools 目录:
-------------- moztools.bat --------------
set MOZ_TOOLS=c:\mozilla\moztools
md %MOZ_TOOLS%
cd windows
install.bat
------------------ end -------------------
5) 编写 .mozconfig 文件保存至 c:\mozilla 目录:
--------------- .mozconfig ---------------
. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/ff
ac_add_options --enable-optimize
ac_add_options --disable-debug
ac_add_options --disable-tests
ac_add_options --enable-static
ac_add_options --disable-shared
ac_add_options --enable-official-branding
------------------ end -------------------
6) 编写 mozbuild.bat 文件保存至 c:\mozilla 目录:
-------------- mozbuild.bat --------------
@echo off
set MOZ_TOOLS=c:\mozilla\moztools
set PATH=%PATH%;"C:\Program Files\Microsoft Visual Studio\VC98\Bin";c:\cygwin\bin;%MOZ_TOOLS%\bin
call VCVARS32.BAT
c:\cygwin\bin\make.exe -f client.mk build
------------------ end -------------------
7) 重命名 cygwin\bin\link.exe
2、编译
启动 cygwin 后运行以下命令
Administrator@win2kpro ~
$ cd c:
Administrator@win2kpro /cygdrive/c
$ cd mozilla/
Administrator@win2kpro /cygdrive/c/mozilla
$ ./mozbuild.bat
以下为编译时的部分输出结果:
Setting environment for using Microsoft Visual C++ tools.
Adding client.mk options from /cygdrive/c/mozilla/.mozconfig:
MOZ_PHOENIX=1
MOZ_OBJDIR=$(TOPSRCDIR)/ff
cd /cygdrive/c/mozilla/ff
/cygdrive/c/mozilla/configure
Adding configure options from /cygdrive/c/mozilla/.mozconfig:
--disable-ldap
--disable-mailnews
--enable-extensions=cookie,xml-rpc,xmlextras,pref,transformiix,universalchardet,webservices,inspector,gnomevfs,negotiateauth
--enable-crypto
--disable-composer
--enable-single-profile
--disable-profilesharing
--enable-optimize
--disable-debug
--disable-tests
--enable-static
--disable-shared
--enable-official-branding
--enable-ui-locale=zh-CN
loading cache ./config.cache
checking host system type... i686-pc-cygwin
checking target system type... i686-pc-cygwin
checking build system type... i686-pc-cygwin
checking for gcc... (cached) cl
checking whether the C compiler (cl ) works... yes
checking whether the C compiler (cl ) is a cross-compiler... no
checking whether we are using GNU C... (cached) no
checking whether cl accepts -g... (cached) no
checking for c++... (cached) cl
checking whether the C++ compiler (cl ) works... yes
checking whether the C++ compiler (cl ) is a cross-compiler... no
checking whether we are using GNU C++... (cached) no
checking whether cl accepts -g... (cached) no
checking for ranlib... (cached) ranlib
checking for ml... (cached) /cygdrive/c/PROGRA~1/MICROS~2/VC98/BIN/ml
checking for ar... (cached) ar
checking for ld... (cached) link
checking for strip... (cached) strip
checking for windres... (cached) windres
checking for gawk... (cached) gawk
checking for midl... (cached) midl
checking for midl flags... none needed
checking how to run the C preprocessor... cl
checking for mmintrin.h... (cached) no
checking how to run the C preprocessor... cl
checking how to run the C++ preprocessor... (cached) /lib/cpp
checking for a BSD compatible install... (cached) /usr/bin/install -c
checking whether ln -s works... (cached) yes
checking for perl5... (cached) /usr/bin/perl
checking for minimum required perl version >= 5.004... 5.008007
checking for full perl installation... yes
checking for doxygen... (cached) :
checking for whoami... (cached) /usr/bin/whoami
checking for autoconf... (cached) /usr/bin/autoconf
checking for unzip... (cached) /usr/bin/unzip
checking for zip... (cached) /usr/bin/zip
checking for makedepend... no
checking for xargs... (cached) /usr/bin/xargs
checking for make... (cached) /usr/bin/make
checking for X... (cached) no
checking for 64-bit OS... no
checking for valid optimization flags... yes
creating ./config.status
creating config/autoconf.mk
creating config/doxygen.cfg
creating xpfe/global/buildconfig.html
creating toolkit/content/buildconfig.html
creating toolkit/components/passwordmgr/resources/content/contents.rdf
creating toolkit/mozapps/contents-content.rdf
creating gfx/gfx-config.h
gfx/gfx-config.h is unchanged
creating netwerk/necko-config.h
netwerk/necko-config.h is unchanged
creating xpcom/xpcom-config.h
xpcom/xpcom-config.h is unchanged
creating xpcom/xpcom-private.h
xpcom/xpcom-private.h is unchanged
configuring in nsprpub
running /bin/sh /cygdrive/c/mozilla/nsprpub/configure --disable-ldap --disable-mailnews --enable-extensions=cookie,xml-rpc,xmlextras,pref,transformiix,universalchardet,webservices,inspector,gnomevfs,negotiateauth --enable-crypto --disable-composer --enable-single-profile --disable-profilesharing --enable-optimize --disable-debug --disable-tests --enable-static --disable-shared --enable-official-branding --enable-ui-locale=zh-CN --with-dist-prefix=c:/mozilla/ff/dist --with-mozilla --cache-file=.././config.cache --srcdir=/cygdrive/c/mozilla/nsprpub
loading cache .././config.cache
checking host system type... i686-pc-cygwin
checking target system type... i686-pc-cygwin
checking build system type... i686-pc-cygwin
checking for cl... (cached) cl
creating ./config.status
creating Makefile
creating config/Makefile
creating config/autoconf.mk
creating config/nsprincl.mk
creating config/nsprincl.sh
creating config/nspr-config
creating lib/Makefile
creating lib/ds/Makefile
creating lib/libc/Makefile
creating lib/libc/include/Makefile
creating lib/libc/src/Makefile
creating lib/tests/Makefile
creating pkg/Makefile
creating pkg/linux/Makefile
creating pkg/solaris/Makefile
creating pkg/solaris/SUNWpr/Makefile
creating pkg/solaris/SUNWprx/Makefile
creating pr/Makefile
creating pr/include/Makefile
creating pr/include/md/Makefile
creating pr/include/obsolete/Makefile
creating pr/include/private/Makefile
creating pr/src/Makefile
creating pr/src/io/Makefile
creating pr/src/linking/Makefile
creating pr/src/malloc/Makefile
creating pr/src/md/Makefile
creating pr/src/md/windows/Makefile
creating pr/src/memory/Makefile
creating pr/src/misc/Makefile
creating pr/src/threads/Makefile
creating pr/tests/Makefile
creating pr/tests/dll/Makefile
creating pr/src/threads/combined/Makefile
configure: warning: Recreating autoconf.mk with updated nspr-config output
/usr/bin/make -C /cygdrive/c/mozilla/ff
make[1]: Entering directory `/cygdrive/c/mozilla/ff'
rm -f -rf ./dist/sdk
/usr/bin/make -C config export
make[2]: Entering directory `/cygdrive/c/mozilla/ff/config'
make[3]: Entering directory `/cygdrive/c/mozilla/ff/config/mkdepend'
make[3]: Nothing to be done for `export'.
make[3]: Leaving directory `/cygdrive/c/mozilla/ff/config/mkdepend'
/usr/bin/perl -I/cygdrive/c/mozilla/config /cygdrive/c/mozilla/config/bdate.pl build_number
......
IBM T42 笔记本,在分配了 256M 内存的 WIN2K PRO 虚拟机下第一次编译需要一个多小时。
3、相关链接:
Mozilla 官方网站上的编译说明:http://developer.mozilla.org/en/docs/Windows_Build_Prerequisites
firefox-1.0.7-source.tar.bz2 下载地址:http: //ftp.mozilla.org/pub/mozilla.org/firefox/releases/1.0.7/source/firefox-1.0.7-source.tar.bz2
Cygwin 安装程序下载地址:http://www.cygwin.com/setup.exe
Visual C++ Service Pack 5 下载地址:http://msdn.microsoft.com/vstudio/downloads/updates/sp/vs6/sp5/default.aspx
Visual C++ Processor Pack 下载地址:http://msdn.microsoft.com/vstudio/downloads/tools/ppack/download.asp
Netscape's wintools 下载地址:http://ftp.mozilla.org/pub/mozilla.org/mozilla/source/wintools.zip