Compile Firefox by yourself and add the Thunderbird Method

Source: Internet
Author: User
Compile Firefox by yourself and add the Thunderbird Method

Last year, I introduced Mozilla's two open-source software Firefox and Thunderbird compilation methods on the Windows platform in blog "compile Mozilla Firefox and Thunderbird by yourself", but since the end of last year, to simplify compilation, Mozilla integrates all the tools for compiling Firefox and Thunderbird into a unified tool mozilla-build and replaces cygwin with mingw32, compiling Firefox and Thunderbird is much easier, but there are still some unexpected situations to handle during the compilation process. This is a brief introduction to the new compilation method. The Mozilla-build version I used is 1.2, the compiler uses Visual Studio 2005 (Visual C ++ 8.0), Firefox's source code version is 3.0.1, and Thunderbird's source code version is 2.0.0.16, using Visual Studio 2008 may be different and will be mentioned later.

First, let's take a look at Firefox compilation. First, install mozilla-build. There is no installation option. You only need to select the installation path. We strongly recommend that you install it on the Mozilla website to the default location, that is, "C:/Mozilla-build". We recommend that you install it in "C:/Mozilla-build ". Then, prepare the source code. You can download the solidified version of the source code package from the Mozilla website, or use mercurial, a source code management tool recommended by Mozilla, to obtain real-time source code from the server, the source code package of the fixed version is used. Take Firefox as an example to unbind the source code to "C:/Mozilla", which is also recommended by Mozilla. After the source code is unlocked, copy the. Configure config file from the C:/Mozilla/Browser/config directory to the C:/Mozilla directory. The content of this file is as follows:

# This file specifies the build flags for Firefox. You can use it by adding:
. $ Topsrcdir/mail/config/configure config
Mk_add_options pai_co_project = Browser
Ac_add_options -- enable-application = Browser

Modify the file with the editing software and add some options. The modified content is as follows:

Mk_add_options export _objdir = @ topsrcdir @/Firefox-release
Mk_add_options pai_co_project = Browser
Ac_add_options -- enable-extensions = "Default inspector"
Ac_add_options -- enable-Inspector-APIs
Ac_add_options -- disable-Installer
Ac_add_options -- disable-Debug
Ac_add_options -- enable-application = Browser
Ac_add_options -- disable-static -- enable-shared
Ac_add_options -- disable-Tests
Ac_add_options -- disable-mochitest
Ac_add_options -- disable-Vista-SDK-Requirements
Ac_add_options -- enable-optimize =-O2-G7-arch: sse2
# Ac_add_options -- enable-optimize

Now, Let's explain how to use the pai_objdir option to specify the location where the compilation result is stored. In this example, the final compilation result is stored in the "C:/Mozilla/Firefox-release/Dist/bin" directory. If Firefox is compiled for use, we recommend that you use the "-- disable-Debug" option and enable the "-- enable-optimize" option (using the default optimization method) or "-- enable-optimize =-O2" (specify the specific optimization method ). Disable the test options, that is, "-- disable-tests" and "-- disable-mochitest ". Use the "-- disable-installer" option to disable setup, which can save some Compilation Time. After Vista was launched, Mozilla added a compilation option to determine whether to use the new features of Vista. Therefore, we need to install Windows Platform SDK for Vista. If this SDK is not installed, you need to add the "-- disable-Vista-SDK-Requirements" option to disable the use of new Vista features. In this way, you can compile firefox without installing Windows Platform SDK for Vista. To further improve the performance of firefox after compilation, you can also enable the optimization options for CPU instruction sets. Currently, mainstream CPUs support sse2 instruction sets, so you can enable this optimization option: "-- enable-optimize =-O2-G7-arch: sse2 ".

You need to mention that you can directly create a file in windows. the specified config file is not allowed, but can be created in. modify the config file, which is why the file needs to be copied from the C:/Mozilla/Browser/config directory. the reason for setting the config file. In addition, if Visual Studio 2005 is used, you must modify wabtags in the VC platform directory. the hfile may be a unicode problem. Some code is mistakenly identified by the compiler as a comment Generation Code. Use a Unicode-supported compiler to modify wabtags. the H file is enough. You can also download the modified wabtags. h file from my resources.

After the preparation is complete, you can compile the file. First, go to the "C:/Mozilla-build" directory and start the corresponding batch files. These batch files will prepare the compilation environment, for Visual Studio 2005, you need to start start-msvc8.bat, and if you are using Visual Studio 2008, you need to start start-msvc9.bat ". After startup, Run "CD/C/Mozilla" in shell to switch to the Mozilla code directory, and then run "make-F client. MK build "starts compilation. It takes about 40 minutes to get the result.

Now let's take a look at the compilation of Thunderbird. We have already introduced the installation of Mozilla-build before. Here we will not talk nonsense. The source code of Thunderbird will also be resolved to "C:/Mozilla". If Firefox has been compiled before, clear the Firefox file. First, copy the. Configure config file from the C:/Mozilla/mail/config directory to the C:/Mozilla directory and modify it to the following content:

Mk_add_options pai_objdir = @ topsrcdir @/tbird-release
Mk_add_options pai_co_project = Mail
# Ac_add_options -- enable-extensions = "Default inspector"
# Ac_add_options -- enable-Inspector-APIs
Ac_add_options -- disable-Debug
Ac_add_options -- enable-optimize
Ac_add_options -- enable-optimize =-O2-G7-arch: sse2
Ac_add_options -- disable-static -- enable-shared
Ac_add_options -- disable-Tests
Ac_add_options -- disable-Installer
Ac_add_options -- disable-mochitest
Ac_add_options -- disable-Vista-SDK-Requirements

The meaning of each option has been described earlier. If Visual Studio 2005 is used, modify wabtags. I have discussed the issue of hware before, but there is another file to be modified, that is, wabdefs. h file, a compilation error occurs during compilation, mainly wchar type definition and WinNT. the definition in H is repeated and the prototype is different. The description of this problem is also seen on msdn, but wabdefs is modified. the H file can solve this problem, so we found this file from Visual Studio 2008 and modified the wabdefs of Visual Studio 2005 according to the gourd painting. the H file is mainly about the definition of wchar. If you don't want to bother, you can download the modified wabdefs from my resources. h file. You need to create a new name named "xpt_link.exe" in the "C:/Mozilla/tbird-release/Dist/bind" directory. manifest "manifest file (this directory does not exist before compilation and needs to be created manually). The content is as follows:

<? XML version = '1. 0' encoding = 'utf-8' standalone = 'Yes'?>
<Assembly xmlns = 'urn: Schemas-Microsoft-com: ASM. V1 'manifestversion = '1. 0'>
<Dependency>
<Dependentassembly>
<Assemblyidentity type = 'win32 'name = 'Microsoft. vc80.crt' version = '8. 0.50608.0 'processorarchitecture = 'x86' publickeytoken = '1fc8b3b9a1e18e3b '/>
</Dependentassembly>
</Dependency>
</Assembly>

If the compiler is Visual Studio 2008, you need to modify the name and version attributes as follows: Name = 'Microsoft. vc90.crt 'version = '9. 0.210228.8'

After the preparation is complete, you can compile the file. First, go to the "C:/Mozilla-build" directory and start the corresponding batch files. These batch files will prepare the compilation environment, for Visual Studio 2005, you need to start start-msvc8.bat, and if you are using Visual Studio 2008, you need to start start-msvc9.bat ". After startup, Run "CD/C/Mozilla" in shell to switch to the Mozilla code directory, and then run "make-F client. MK build "starts compilation. It takes about 40 minutes to get the result.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.