Tuesday, September 18, 2007

Building Firefox in Windows

I don't know if I was doing anything wrong or maybe if I had chosen the wrong set of build options, but building Firefox from source code does take pretty long on my pc. The whole build process took about 90 minutes of my life and 1.2GBs of hard drive space. I never thought that the files would be so large, so I had to start deleting stuff while it was compiling. Well, here is what I did to get it built. I was able to do this with cygwin and msys.

**NOTE: You will need about 2GBs of HD space before you begin. 250MBs for the cvs source, about 100MB for the tools (could be less but I had cygwin pre-installed), and 1.2GBs for the code?


STEP 1.
Download and install Visual Studios 2005 (referred to as VC8 on Mozilla sites).
Seneca students should be able to download and install this from our ACS site.
Click here for ACS
Then download and install the Mozilla Build Package 1.1
Download Mozilla Build Package 1.1
The package should install everything into c:\mozilla-build directory by default.
Once these two things are done, run the start-msvc8.bat in the c:\mozilla-build directory which will open up an application window with MINGW32 (referred to as MSYS).

STEP 2.
Now that the MSYS window is open (it will look something like command prompt), navigate your way back to the root c:\ - by default the application root for me was somewhere in my c:\document and settings\user\ which isn't allowed for the build procedure because of the spaces between the directory name.
Once you are in c:\ do the following in the MSYS console:

Make a new directory called proj.

mkdir proj


Navigate into proj directory.
cd proj


Open a connection with mozilla cvs server.
cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/client.mk


Navigate into the new mozilla directory that was created by the cvs.
cd mozilla


Download the source code from CVS. This might take a little while so be patient. It took me about 5-10 minutes.
make -f client.mk checkout MOZ_CO_PROJECT=browser


*** You can easily change the MOZ_CO_PROJECT tag to download different projects or versions. Check out the mozilla dev site for more info or Click Here


STEP 3.
Once all the source code is downloaded. Create a ".mozconfig" file in the c:\proj\mozilla directory and fill it with your build options. Mine looked something like this:

# Options for client.mk.
mk_add_options MOZ_CO_PROJECT=browser
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-@CONFIG_GUESS@

# Options for 'configure' (same as command-line options).
ac_add_options --enable-application=browser
ac_add_options --enable-debug
ac_add_options --disable-static
ac_add_options --disable-optimize


Once that is done type:
make -f client.mk build MOZ_CO_PROJECT=browser
This will build the source code. I would suggest you go do something else unless you have one of them top of the line PCs - this process took my about 90mins.

STEP 5.
Once the source code is built, hopefully with no errors, you should have a directory called "obj-i686-pc-mingw32" or something similar. Make sure any Firefox browsers are closed before continuing.
To run Minefield (Firefox 2 or 3?), run firefox located in c:\proj\mozilla\obj-i686-pc-mingw32\dist\bin

After a minute or two you should have a working build of Minefield.



If you would like to make an installer, you can type make installer in the c:\proj\mozilla\obj-i686-pc-mingw32 directory.

**NOTE: If Firefox is already running on your desktop running Minefield will only open a new window, so please close Firefox before running the application.

You are now COMPLETE!

13 comments:

Simon said...

For those of you who are encountering some problems with the build you might want to check out Vincent Lam's experience with Firefox build.

vijeyb said...

There are some good tips in this post and very well detailed. Good Job Simon.

ikari said...

I still can't get it working... I'm getting a LOT of sh.exe crashes like

0 [main] sh 44540 open_stackdumpfile: Dumping stack trace to sh.exe.stack
./config.status: line 2262: 44524 Done sed -e "$ac_comsub

I mean a LOT of it ;P What's wrong?

Angelina_ny said...

How to create ".mozconfig" file in windows? It is invalid file name.

Sean said...

To create the .mozconfig file:

1) Create an empty text file (let's call it "test.txt")
2) Open cmd.exe and go to the directory where test.txt is located
3) Type in: rename test.txt .mozconfig

Windows won't let you create a file called '.mozconfig', but the command prompt will.

Markitox said...

Hi everyone,
How do I add a default extension to my Firefox build? Is there a specific folder where I should drop my extension so that command "make installer" will automatically add it?

Thanks in advance. :)

Doug said...

The MSYS console started fine for me. But when the build starts, it cannot find the cl.exe command. Probably becasue of the damn spaces in the path to VC9. Could you help me with this please? Thanks

$ make -f client.mk build MOZ_CO_PROJECT=browser
Adding client.mk options from /c/workspace/mozilla/.mozconfig:
MOZ_CO_PROJECT=browser
MOZ_OBJDIR=$(TOPSRCDIR)/obj-$(CONFIG_GUESS)
make[1]: Entering directory `/c/workspace/mozilla'
cd /c/workspace/mozilla/obj-i686-pc-mingw32
/c/workspace/mozilla/configure
Adding configure options from /c/workspace/mozilla/.mozconfig:
--enable-application=browser
--enable-debug
--disable-static
--disable-optimize
loading cache ./config.cache
checking host system type... i686-pc-mingw32
checking target system type... i686-pc-mingw32
checking build system type... i686-pc-mingw32
checking for gawk... gawk
checking for gcc... cl
checking whether the C compiler (cl ) works... no
configure: error: installation or configuration problem: C compiler cannot creat
e executables.
*** Fix above errors and then restart with "make -f client.mk buil
d"
make[1]: *** [configure] Error 1
make[1]: Leaving directory `/c/workspace/mozilla'
make: *** [/c/workspace/mozilla/obj-i686-pc-mingw32/Makefile] Error 2

Satyajeet said...

i have installed visual studio 8 (2005), platform sdk,and mozilla build 1.3
im still not able to start the msvc8 batch file.it just appears and then closes. plz help coz i need to build firefox as soon as possible....
i even have visual studio 6...
plzz help...

jbacon said...

I'm having the same problems as ikari. It's really annoying. Seems every time it invokes cl, it crashes.

Razz said...

@Doug
I was getting that error too at first but I found out that I hadn't installed Windows Vista SDK. It is required even if you're not building FF on XP or any other non-Vista OS.

Razz said...

Apologies. I meant you need the Vista SDK even if you are building on XP

Mani said...

Windows won't allow to create .mozconfig file. Instead of that you can create "mozconfig" without prefixing ".", it will work.

Scott Munday said...

From the MSYS console, try using the "touch" command as so:

>touch .mozconfig

See if you can get a file that way.