Building llmozlib2 on MacOS

== Building llmozlib2 on MacOS ==
This page explains step-by-step procedure to build llmozlib2 from the scratch on MacOS.
General information on building llmozlib2 is available on LLMozLib2. The contents of this page is primarily taken from README-mac.txt included in the llmozlib2 build files and Mac OS X Build Prerequisites available on mozilla developer center.
== Preparation ==
The preparation steps install additional development tools (other than those supplied in Xcode suit) into your Macintosh. You need to perform the following steps only once when you start llmozlib2 development.
Do the steps as the order written here, since lower ones may depend upper ones. For example, installation steps for libIDL assumes you have installed MacPorts already. 
=== MacPorts ===
# Visit the MacPorts project web site.
# Go to the Installing MacPorts page, and download an appropriate dmg disk image file for your MacOS version. The links should be on the very top of the page.
# Run the MacPorts installer in the dmg file and follow the guided steps.
Note that the MacPorts' command is called "port" (without "s"), although the project is called "MacPorts" (with "s").
=== libIDL ===
Open Terminal, and use the following commands to download and install libIDL. (sudo command may ask you a MacOS password.)
 $ sudo port sync
 $ sudo port install libidl
You will need several minutes to complete this step.
=== Subversion ===
Subversion is included in Xcode 3.0 (for MacOS X 10.5.) If you are on MacOS X 10.4, you need to install one by yourself.
Open Terminal (if not yet), and use the following commands to download and install Subversion.
 $ sudo port install subversion
You will need several minutes to complete this step.
== Getting llmozlib2 build files ==
Open Terminal and use the following command to get the llmozlib2 build files from LL SVN repository.
 $ svn co http://svn.secondlife.com/svn/llmozlib/trunk/llmozlib2
This command will create a directory of name "llmozlib2" in the current directory and places all extracted files below it. The above command always gets the latest files. If you want to get a particular revision, you can specify -r option. Consult a Subversion documentation for details.
Read the llmozlib2/README-mac.txt file before continue. If it says something different from this page, the instraction should take priority.
== Building mozilla from scratch ==
=== Compiling mozilla files ===
cd to the directory "llmozlib2/build_mozilla", and run the "mac-checkout_patch_build.sh" as:
 $ sh mac-checkout_patch_build.sh
Be aware of the mixture of a hyphen and underlines when typing...
This will access to the Mozilla CVS, download the full mozilla source files, patch it to adjust with SL, then build the mozilla.
This step needs several hours.
=== Extracting necessary files ===
cd to the directory "llmozlib2", and run the "copy_products_mac.sh" as:
 $ sh copy_products_mac.sh
This step takes no long time.
You will get a lot of files under the directory "llmozlib2/library/", that are to replace those files under "linden/libraries" directory distributed as a part of the SL viewer library bundle for MacOS.
You will also get a file "mozilla-universal-darwin-original.tgz" in the directory llmozlib2. This file is the major input to the next step #Building llmozlib2.
=== Removing mozilla files (optinal) ===
You can remove following file and two directories at this timing if you don't plan modifying mozilla files in a future.
* llmozlib2/build_mozilla/cvsco.log
* llmozlib2/build_mozilla/mozilla
* llmozlib2/build_mozilla/objdir-mozilla-universal
It is recommended that just delay the removal for a while, and go to #Building llmozlib2 if this is your first time to build llmozlib2. In case something went wrong and you needed to retry, you may need these files, and rebuilding them again takes another several hours...
== Building llmozlib2 ==
=== Compiling the llmozlib2 classes ===
Start the Xcode IDE. Follow the steps to get llmozlib2.
# Open the Xcode project file "llmozlib2/llmozlib2.xcodeproj" with the IDE.
# Select "llmozlib2" as Active Target and "Release" as Active Build Configuration.
# Click on Build icon.
# You will see a lot of errors. (Approx. 400.) Don't interrupt the build process in a middle. Wait for the build process to terminate automatically.
# Close the Xcode project by choosing "File > Close Project" from the menu.
# Open the "llmozlib2/llmozlib2.xcodeproj" again.
# Click on Build icon.
# You should see no errors this time.
This step takes just a minute or two.
=== Packaging files and copying ===
Open Terminal, and cd to the "llmozlib2" directory. Run the following command:
 $ sh repackage_runtime.sh $(VIEWER_DIRECTORY)
where $(VIEWER_DIRECTORY) is a (full) path name to the top directory of SL viewer build files. For example, if you place the top directory "linden" of the viewer files as "/Users/alissa/sl/1.19.1.2/linden", you should type as follows:
 $ sh repackage_runtime.sh /Users/alissa/sl/1.19.1.2/linden
This script extracts files from "mozilla-universal-darwin-original.tgz", removing and adding several files there, putting them into a new file "mozilla-universal-darwin.tgz". The tgz file contains all runtime files that are parts of llmozlib2, i.e., libllmozlib2.dylib itself, all required mozilla .dylib files, other dependent .dylib files, and required resource files.
Then, the script copies all necessary files for SL viewer development into appropriate locations below the directory specified by the argument to the repackage_runtime.sh script.
This step takes no long time.
Category:Compiling viewer