Difference between revisions of "Real World Mozilla Makefile Lab"

From CDOT Wiki
Jump to: navigation, search
 
(Resources)
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Dive into Mozilla]] > [[Dive into Mozilla Day 2]] > Makefile Lab
+
[[Real World Mozilla]] > [[Real World Mozilla Day 2]] > Makefile Lab
  
 
== Overview ==
 
== Overview ==
Line 5: Line 5:
 
This lab is designed to give you first-hand experience creating a simple Makefile and using Make to build software.  While the Mozilla build system is much more complex than this example, the ideas learned here will get you started understanding how Mozilla is built.
 
This lab is designed to give you first-hand experience creating a simple Makefile and using Make to build software.  While the Mozilla build system is much more complex than this example, the ideas learned here will get you started understanding how Mozilla is built.
  
 
+
For nostalgic reasons we will work with the source code to Evan Weaver's nled editor, written in C.
  
 
== Instructions ==
 
== Instructions ==
Line 11: Line 11:
 
The lab machines have already been set-up to use MSVC 8 and MozillaBuild RC1.  You only need to run '''Mozilla-Build MSVC 8.bat''' (there is a link on the desktop) to begin (i.e., you shouldn't need to install anything).
 
The lab machines have already been set-up to use MSVC 8 and MozillaBuild RC1.  You only need to run '''Mozilla-Build MSVC 8.bat''' (there is a link on the desktop) to begin (i.e., you shouldn't need to install anything).
  
# Create a directory called '''C:\ff''' to hold the source
+
# Download and extract the nled [http://cs.senecac.on.ca/~david.humphrey/nled-2.52-src.zip source code]
# Make sure the tree is '''not red''' on [http://tinderbox.mozilla.org/showbuilds.cgi?tree=Firefox tinderbox]
+
# Start Mozilla-Build MSVC8.bat to get a proper build environment
# Check-out the Firefox code from '''CVS''' into C:\ff ([http://developer.mozilla.org/en/docs/Mozilla_Source_Code_%28CVS%29 instructions are here]). You can use either of the following CVSROOT values:
+
# Move to the directory where you extracted the source
#* :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
+
# Using a text editor, create a file in this directory named '''Makefile'''
#* :pserver:anonymous@hera.senecac.on.ca:/cvsroot
+
# Examine all the .c files to determine dependencies with the .h files
# Create a '''.mozconfig''' file ([http://developer.mozilla.org/en/docs/Configuring_Build_Options instructions are here]) in '''C:\ff\mozilla''' with the following:
+
# Write targets and rules for each of the object files and the final executable
#* Use an Object Directory (OBJDIR) named '''objdir'''
+
# Write a '''clean''' target in order to delete all .obj and .exe files
#* '''Disable''' Optimization
+
# You will know you are done when the following commands result in nled.exe being produced:
#* '''Enable''' Debugging
+
 
#* Use '''Shared''' libraries instead of Static
+
$ make
# Build the source ([http://developer.mozilla.org/en/docs/Build_and_Install instructions are here])
+
$ make clean
# wait, wait, wait...NOTE: the build process (a debug build) takes approximately '''1 hour''' to complete in the lab.
+
 
# Test your new browser:
+
 
## Set the following environment variables to turn-off assertion dialogs and allow for multiple versions of the browser to be run simultaneously:
+
or, if you want to combine this into one line:
##* export XPCOM_DEBUG_BREAK=warn
+
 
##* export MOZ_NO_REMOTE=1
+
$ make && make clean
## Run the browser as follows:<code>C:\ff\mozilla\objdir\dist\bin\firefox -Profilemanager</code>
+
 
## When prompted, create a new profile called '''development'''
+
== Hints ==
## In the address bar, enter the following URI and note the build information: '''about:'''
+
* [http://msdn2.microsoft.com/en-us/library/8we9bhf4(VS.80).aspx CL -c option]
 +
* [http://msdn2.microsoft.com/en-us/library/yb8e9b8y(VS.80).aspx CL -Fo option]
 +
* The default extension for object files on win32 is '''.obj''' vs. .o on Unix
 +
* To create the executable (nled.exe) you must link all .obj files ''and'' '''user32.lib'''
 +
* Running make with the '''-n''' option will show you all the commands make is going to run, which is helpful when debugging makefiles:
 +
 
 +
$ make -n
  
 
== Resources ==
 
== Resources ==
 
* [http://benjamin.smedbergs.us/blog/2007-01-12/mozillabuild-rc1/ MozillaBuild RC1 for Win32]
 
* [http://benjamin.smedbergs.us/blog/2007-01-12/mozillabuild-rc1/ MozillaBuild RC1 for Win32]
* [http://webtools.mozilla.org/build/config.cgi MOZCONFIG Build Configurator]
+
* [http://www.gnu.org/software/make/manual/ GNU Make Manual]
 +
* [http://www.eng.hawaii.edu/Tutor/Make/ Make Tutorial]
 +
* [[Makefile.in Template for In-Tree Extensions]]

Latest revision as of 13:05, 1 April 2008

Real World Mozilla > Real World Mozilla Day 2 > Makefile Lab

Overview

This lab is designed to give you first-hand experience creating a simple Makefile and using Make to build software. While the Mozilla build system is much more complex than this example, the ideas learned here will get you started understanding how Mozilla is built.

For nostalgic reasons we will work with the source code to Evan Weaver's nled editor, written in C.

Instructions

The lab machines have already been set-up to use MSVC 8 and MozillaBuild RC1. You only need to run Mozilla-Build MSVC 8.bat (there is a link on the desktop) to begin (i.e., you shouldn't need to install anything).

  1. Download and extract the nled source code
  2. Start Mozilla-Build MSVC8.bat to get a proper build environment
  3. Move to the directory where you extracted the source
  4. Using a text editor, create a file in this directory named Makefile
  5. Examine all the .c files to determine dependencies with the .h files
  6. Write targets and rules for each of the object files and the final executable
  7. Write a clean target in order to delete all .obj and .exe files
  8. You will know you are done when the following commands result in nled.exe being produced:
$ make
$ make clean


or, if you want to combine this into one line:

$ make && make clean

Hints

  • CL -c option
  • CL -Fo option
  • The default extension for object files on win32 is .obj vs. .o on Unix
  • To create the executable (nled.exe) you must link all .obj files and user32.lib
  • Running make with the -n option will show you all the commands make is going to run, which is helpful when debugging makefiles:
$ make -n

Resources