Merge "Docs: Additional updates to build environment instructions 1. Add configuration instructions for ccache on Mac OS. 2. Move ccache instructions to new section, since setup applies to build environments on both Linux and Mac OS. 3. Make Mac OS references consistent. 4. Format branch tags, system paths and commands with <code> tag."
diff --git a/README b/README
index 08a3bdf..77a76b8 100644
--- a/README
+++ b/README
@@ -58,7 +58,7 @@
 
 3. Edit the Javadoc file(s) and save your changes.
 
-4. If a page was added or removed, update the corresponding *.toc.cs file to
+4. If a page was added or removed, update the corresponding _toc.cs file to
 reflect the change.
 
 5. Run the following make command from the root of the project parent directory:
diff --git a/src/source/building-running.jd b/src/source/building-running.jd
index ed8c4b7..239ebe6 100644
--- a/src/source/building-running.jd
+++ b/src/source/building-running.jd
@@ -24,14 +24,14 @@
   </div>
 </div>
 
-The following instructions to build the Android source tree apply to all branches, including master. 
+The following instructions to build the Android source tree apply to all branches, including <code>master</code>.
 
 <h2 id="choosing-a-branch">Choosing a Branch</h2>
 <p>Some of the requirements for your build environment are determined by which
 version of the source code you plan to compile. See
 <a href="build-numbers.html">Codenames, Tags, and Build Numbers</a> for a full listing of branches you may
 choose from. You may also choose to download and build the latest source code
-(called "master"), in which case you will simply omit the branch specification
+(called <code>master</code>), in which case you will simply omit the branch specification
 when you initialize the repository.</p>
 <p>Once you have selected a branch, follow the appropriate instructions below to
 set up your build environment.</p>
@@ -40,7 +40,7 @@
 <p>The basic sequence of build commands is as follows:</p>
 <h2 id="initialize">Initialize</h2>
 <p>Initialize the environment with the <code>envsetup.sh</code> script. Note
-that replacing "source" with a single dot saves a few characters,
+that replacing <code>source</code> with <code>.</code> (a single dot) saves a few characters,
 and the short form is more commonly used in documentation.</p>
 <pre><code>$ source build/envsetup.sh
 </code></pre>
@@ -49,12 +49,12 @@
 </code></pre>
 <h2 id="choose-a-target">Choose a Target</h2>
 <p>Choose which target to build with <code>lunch</code>.  The exact configuration can be passed as
-an argument, e.g. </p>
+an argument. For example, the following command:</p>
 <pre><code>$ lunch aosp_arm-eng
 </code></pre>
-<p>The example above refers to a complete build for the emulator, with all debugging enabled.</p>
+<p>refers to a complete build for the emulator, with all debugging enabled.</p>
 <p>If run with no arguments <code>lunch</code> will prompt you to choose a target from the menu. </p>
-<p>All build targets take the form BUILD-BUILDTYPE, where the BUILD is a codename
+<p>All build targets take the form <code>BUILD-BUILDTYPE</code>, where the <code>BUILD</code> is a codename
 referring to the particular feature combination. Here's a partial list:</p>
 <table>
 <thead>
@@ -111,7 +111,7 @@
 <p>Build everything with <code>make</code>. GNU make can handle parallel
 tasks with a <code>-jN</code> argument, and it's common to use a number of
 tasks N that's between 1 and 2 times the number of hardware
-threads on the computer being used for the build. E.g. on a
+threads on the computer being used for the build. For example, on a
 dual-E5520 machine (2 CPUs, 4 cores per CPU, 2 threads per core),
 the fastest builds are made with commands between <code>make -j16</code> and
 <code>make -j32</code>.</p>
@@ -126,7 +126,7 @@
 <p>Once the device is in fastboot mode, run </p>
 <pre><code>$ fastboot flashall -w
 </code></pre>
-<p>The <code>-w</code> option wipes the <code>/data</code> partition on the device; this is useful for your first time flashing a particular device, but is otherwise unnecessary.</p>
+<p>The <code>-w</code> option wipes the <code>/data</code> partition on the device; this is useful for your first time flashing a particular device but is otherwise unnecessary.</p>
 <p>For more information about building for and running on actual hardware, see
 <a href="building-devices.html">Building for Devices.</a></p>
 <h3 id="emulate-an-android-device">Emulate an Android Device</h3>
@@ -141,10 +141,10 @@
 $ prebuilts/misc/linux-x86/ccache/ccache -M 50G
 </code></pre>
 <p>The suggested cache size is 50-100G.</p>
-<p>You can watch ccache being used by doing the following:</p>
+<p>On Linux, you can watch ccache being used by doing the following:</p>
 <pre><code>$ watch -n1 -d prebuilts/misc/linux-x86/ccache/ccache -s
 </code></pre>
-<p>On OSX, you should replace <code>linux-x86</code> with <code>darwin-x86</code>.</p>
+<p>On Mac OS, you should replace <code>linux-x86</code> with <code>darwin-x86</code>.</p>
 <p>When using Ice Cream Sandwich (4.0.x) or older, you should replace
 <code>prebuilts/misc</code> with <code>prebuilt</code>.</p>
 <h2 id="troubleshooting-common-build-errors">Troubleshooting Common Build Errors</h2>
@@ -176,7 +176,7 @@
 <pre><code>$ apt-get install python
 </code></pre>
 <h3 id="case-insensitive-filesystem">Case Insensitive Filesystem</h3>
-<p>If you are building on an HFS filesystem on Mac OS X, you may encounter an error such as</p>
+<p>If you are building on an HFS filesystem on Mac OS, you may encounter an error such as</p>
 <pre><code>************************************************************
 You are building on a case-insensitive filesystem.
 Please move your source tree to a case-sensitive filesystem.
diff --git a/src/source/building.jd b/src/source/building.jd
index a0c3985..408ddb1 100644
--- a/src/source/building.jd
+++ b/src/source/building.jd
@@ -25,7 +25,7 @@
 
 <ul>
 
-  <li>A Linux or Mac system. It is also possible
+  <li>A Linux or Mac OS system. It is also possible
   to build Android in a virtual machine on unsupported systems such as Windows.
   If you are running Linux in a virtual machine, you need at
   least 16GB of RAM/swap and 50GB or more of disk space in order to
diff --git a/src/source/initializing.jd b/src/source/initializing.jd
index 371e8e3..829a975 100644
--- a/src/source/initializing.jd
+++ b/src/source/initializing.jd
@@ -34,17 +34,17 @@
 version of the source code you plan to compile. See
 <a href="build-numbers.html">Build Numbers</a> for a full listing of branches you may
 choose from. You may also choose to download and build the latest source code
-(called "master"), in which case you will simply omit the branch specification
+(called <code>master</code>), in which case you will simply omit the branch specification
 when you initialize the repository.</p>
 <p>Once you have selected a branch, follow the appropriate instructions below to
 set up your build environment.</p>
 <h2 id="setting-up-a-linux-build-environment">Setting up a Linux build environment</h2>
-<p>These instructions apply to all branches, including master.</p>
+<p>These instructions apply to all branches, including <code>master</code>.</p>
 <p>The Android build is routinely tested in house on recent versions of
 Ubuntu LTS (14.04), but most distributions should have the required
 build tools available. Reports of successes or failures on other
 distributions are welcome.</p>
-<p>For Gingerbread (2.3.x) and newer versions, including the master
+<p>For Gingerbread (2.3.x) and newer versions, including the <code>master</code>
 branch, a 64-bit environment is required. Older versions can be
 compiled on 32-bit systems.</p>
 <p><strong>Note</strong>: See the <a href="building.html">Downloading and
@@ -52,7 +52,7 @@
 follow the detailed instructions for Ubuntu and Mac OS below.</p>
 
 <h3 id="installing-the-jdk">Installing the JDK</h3>
-<p>The master branch of Android in the <a
+<p>The <code>master</code> branch of Android in the <a
 href="https://android.googlesource.com/">Android Open Source Project (AOSP)</a>
 requires Java 7. On Ubuntu, use <a href="http://openjdk.java.net/install/">OpenJDK</a>.</p>
 <p>Java 7: For the latest version of Android</p>
@@ -107,7 +107,7 @@
 <pre><code>$ sudo apt-get install libx11-dev:i386
 </code></pre>
 <h3 id="configuring-usb-access">Configuring USB Access</h3>
-<p>Under GNU/linux systems (and specifically under Ubuntu systems),
+<p>Under GNU/Linux systems (and specifically under Ubuntu systems),
 regular users can't directly access USB devices by default. The
 system needs to be configured to allow such access.</p>
 <p>The recommended approach is to create a file
@@ -155,33 +155,9 @@
 back into the computer.</p>
 <p>This is known to work on both Ubuntu Hardy Heron (8.04.x LTS) and
 Lucid Lynx (10.04.x LTS). Other versions of Ubuntu or other
-variants of GNU/linux might require different configurations.</p>
-<p><a name="ccache"></a></p>
-<h3 id="setting-up-ccache">Setting up ccache</h3>
-<p>You can optionally tell the build to use the ccache compilation tool.
-Ccache acts as a compiler cache that can be used to speed-up rebuilds.
-This works very well if you do "make clean" often, or if you frequently
-switch between different build products.</p>
-<p>Put the following in your .bashrc or equivalent.</p>
-<pre><code>export USE_CCACHE=1
-</code></pre>
-<p>By default the cache will be stored in ~/.ccache.
-If your home directory is on NFS or some other non-local filesystem,
-you will want to specify the directory in your .bashrc as well.</p>
-<pre><code>export CCACHE_DIR=&lt;path-to-your-cache-directory&gt;
-</code></pre>
-<p>The suggested cache size is 50-100GB.
-You will need to run the following command once you have downloaded
-the source code:</p>
-<pre><code>prebuilts/misc/linux-x86/ccache/ccache -M 50G
-</code></pre>
-<p>When building Ice Cream Sandwich (4.0.x) or older, ccache is in
-a different location:</p>
-<pre><code>prebuilt/linux-x86/ccache/ccache -M 50G
-</code></pre>
-<p>This setting is stored in the CCACHE_DIR and is persistent.</p>
+variants of GNU/Linux might require different configurations.</p>
 <h3 id="using-a-separate-output-directory">Using a separate output directory</h3>
-<p>By default, the output of each build is stored in the out/
+<p>By default, the output of each build is stored in the <code>out/</code>
 subdirectory of the matching source tree.</p>
 <p>On some machines with multiple storage devices, builds are
 faster when storing the source files and the output on
@@ -205,37 +181,50 @@
 as those would end up sharing an output directory, with
 unpredictable results.</p>
 <p>This is only supported on Jelly Bean (4.1) and newer,
-including the master branch.</p>
+including the <code>master</code> branch.</p>
 <h2 id="setting-up-a-mac-os-x-build-environment">Setting up a Mac OS build environment</h2>
 <p>In a default installation, Mac OS runs on a case-preserving but case-insensitive
 filesystem. This type of filesystem is not supported by git and will cause some
-git commands (such as "git status") to behave abnormally. Because of this, we
+git commands (such as <code>git status</code>) to behave abnormally. Because of this, we
 recommend that you always work with the AOSP source files on a case-sensitive
 filesystem. This can be done fairly easily using a disk image, discussed below.</p>
-<p>Once the proper filesystem is available, building the master branch in a modern
+<p>Once the proper filesystem is available, building the <code>master</code> branch in a modern
 Mac OS environment is very straightforward. Earlier branches, including ICS,
 require some additional tools and SDKs.</p>
 <h3 id="creating-a-case-sensitive-disk-image">Creating a case-sensitive disk image</h3>
 <p>You can create a case-sensitive filesystem within your existing Mac OS environment
 using a disk image. To create the image, launch Disk
 Utility and select "New Image".  A size of 25GB is the minimum to
-complete the build, larger numbers are more future-proof. Using sparse images
+complete the build; larger numbers are more future-proof. Using sparse images
 saves space while allowing to grow later as the need arises. Be sure to select
 "case sensitive, journaled" as the volume format.</p>
 <p>You can also create it from a shell with the following command:</p>
 <pre><code># hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 40g ~/android.dmg
 </code></pre>
-<p>This will create a .dmg (or possibly a .dmg.sparsefile) file which, once mounted, acts as a drive with the required formatting for Android development. For a disk image named "android.dmg" stored in your home directory, you can add the following to your <code>~/.bash_profile</code> to mount the image when you execute "mountAndroid":</p>
+<p>This will create a <code>.dmg</code> (or possibly a <code>.dmg.sparsefile</code>) file which, once mounted, acts as a drive with the required formatting for Android development. 
+<p>If you need a larger volume later, you can also resize the sparse image with the following command:</p>
+<pre><code># hdiutil resize -size &lt;new-size-you-want&gt;g ~/android.dmg.sparseimage
+</code></pre>
+For a disk image named <code>android.dmg</code> stored in your home directory, you can add helper functions to your <code>~/.bash_profile</code>:
+<ul>
+<li>
+To mount the image when you execute <code>mountAndroid</code>:</p>
 <pre><code># mount the android file image
 function mountAndroid { hdiutil attach ~/android.dmg -mountpoint /Volumes/android; }
 </code></pre>
-
-<p><strong>Note</strong>: If your system created a .dmg.sparsefile file, replace <code>~/android.dmg</code> with <code>~/android.dmg.sparsefile</code>.</p>
-
-<p>Once you've mounted, the <code>android</code> volume, you'll do all your work there. You can eject it (unmount it) just like you would with an external drive.</p>
+<p><strong>Note</strong>: If your system created a <code>.dmg.sparsefile</code> file, replace <code>~/android.dmg</code> with <code>~/android.dmg.sparsefile</code>.</p>
+</li>
+<li>
+<p>To unmount it when you execute <code>umountAndroid</code>:</p>
+<pre><code># unmount the android file image
+function umountAndroid() { hdiutil detach /Volumes/android; }
+</code></pre>
+</li>
+</ul>
+<p>Once you've mounted the <code>android</code> volume, you'll do all your work there. You can eject it (unmount it) just like you would with an external drive.</p>
 
 <h3 id="installing-the-mac-jdk">Installing the JDK</h3>
-<p>The master and 5.0.x branches of Android in the <a
+<p>The <code>master</code> and <code>5.0.x</code> branches of Android in the <a
 href="https://android.googlesource.com/">Android Open Source Project (AOSP)</a>
 require Java 7. On Mac OS, use <a
 href="https://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jdk-7u71-oth-JPR">jdk-7u71-macosx-x64.dmg</a>.</p>
@@ -246,17 +235,17 @@
 
 <h3 id="master-branch">Master branch</h3>
 <p>To build the latest source in a Mac OS environment, you will need an Intel/x86
-machine running MacOS 10.8 (Mountain Lion) or later, along with Xcode
+machine running Mac OS X v10.8 (Mountain Lion) or later, along with Xcode
 4.5.2 or later including the Command Line Tools.</p>
 
 <h3 id="branch-50x-and-all-earlier-branches">Branch 5.0.x and earlier branches</h3>
 <p>To build 5.0.x and earlier source in a Mac OS environment, you will need an Intel/x86
-machine running MacOS 10.8 (Mountain Lion), along with Xcode
+machine running Mac OS X v10.8 (Mountain Lion), along with Xcode
 4.5.2 and Command Line Tools.</p>
 
 <h3 id="branch-44x-and-all-earlier-branches">Branch 4.4.x and earlier branches</h3>
 <p>To build 4.2.x and earlier source in a Mac OS environment, you will need an Intel/x86
-machine running MacOS 10.6 (Snow Leopard) or MacOS 10.7 (Lion), along with Xcode
+machine running Mac OS X v10.6 (Snow Leopard) or Mac OS X v10.7 (Lion), along with Xcode
 4.2 (Apple's Developer Tools). Although Lion does not come with a JDK, it should
 install automatically when you attempt to build the source.</p>
 <p>The remaining sections for Mac OS apply only to those who wish to build
@@ -264,13 +253,13 @@
 
 <h3 id="branch-40x-and-all-earlier-branches">Branch 4.0.x and all earlier branches</h3>
 <p>To build android-4.0.x and earlier branches in a Mac OS environment, you need an
-Intel/x86 machine running MacOS 10.5 (Leopard) or MacOS 10.6 (Snow Leopard). You
-will need the MacOS 10.5 SDK.</p>
+Intel/x86 machine running Mac OS X v10.5 (Leopard) or Mac OS X v10.6 (Snow Leopard). You
+will need the Mac OS X v10.5 SDK.</p>
 <h4 id="installing-required-packages">Installing required packages</h4>
 <ul>
 <li>
 <p>Install Xcode from <a href="http://developer.apple.com/">the Apple developer site</a>.
-We recommend version 3.1.4 or newer, i.e. gcc 4.2.
+We recommend version 3.1.4 or newer (e.g., gcc 4.2).
 Version 4.x could cause difficulties.
 If you are not already registered as an Apple developer, you will have to
 create an Apple ID in order to download.</p>
@@ -289,7 +278,7 @@
 <p>Get make, git, and GPG packages from MacPorts: </p>
 <pre><code>$ POSIXLY_CORRECT=1 sudo port install gmake libsdl git gnupg
 </code></pre>
-<p>If using Mac OS 10.4, also install bison:</p>
+<p>If using Mac OS X v10.4, also install bison:</p>
 <pre><code>$ POSIXLY_CORRECT=1 sudo port install bison
 </code></pre>
 </li>
@@ -322,11 +311,39 @@
 </li>
 </ul>
 <h4 id="setting-a-file-descriptor-limit">Setting a file descriptor limit</h4>
-<p>On MacOS the default limit on the number of simultaneous file descriptors open is too low and a highly parallel build process may exceed this limit.<br />
+<p>On Mac OS, the default limit on the number of simultaneous file descriptors open is too low and a highly parallel build process may exceed this limit.<br />
 </p>
 <p>To increase the cap, add the following lines to your <code>~/.bash_profile</code>: </p>
 <pre><code># set the number of open files to be 1024
 ulimit -S -n 1024
 </code></pre>
+<h2 id="optimizing-a-build-environment">Optimizing a build environment (optional)</h2>
+<p><a name="ccache"></a></p>
+<h3 id="setting-up-ccache">Setting up ccache</h3>
+<p>You can optionally tell the build to use the ccache compilation tool.
+Ccache acts as a compiler cache that can be used to speed up rebuilds.
+This works very well if you use <code>make clean</code> often, or if you frequently
+switch between different build products.</p>
+<p>Put the following in your <code>.bashrc</code> (or equivalent):</p>
+<pre><code>export USE_CCACHE=1
+</code></pre>
+<p>By default the cache will be stored in <code>~/.ccache</code>.
+If your home directory is on NFS or some other non-local filesystem,
+you will want to specify the directory in your <code>.bashrc</code> file as well:</p>
+<pre><code>export CCACHE_DIR=&lt;path-to-your-cache-directory&gt;
+</code></pre>
+<p>The suggested cache size is 50-100GB.
+You will need to run the following command once you have downloaded
+the source code:</p>
+<pre><code>prebuilts/misc/linux-x86/ccache/ccache -M 50G
+</code></pre>
+<p>On Mac OS, you should replace <code>linux-x86</code> with <code>darwin-x86</code>:</p>
+<pre><code>prebuilts/misc/darwin-x86/ccache/ccache -M 50G
+</code></pre>
+<p>When building Ice Cream Sandwich (4.0.x) or older, ccache is in
+a different location:</p>
+<pre><code>prebuilt/linux-x86/ccache/ccache -M 50G
+</code></pre>
+<p>This setting is stored in the CCACHE_DIR and is persistent.</p>
 <h2 id="next-download-the-source">Next: Download the source</h2>
 <p>Your build environment is good to go! Proceed to <a href="downloading.html">downloading the source</a>.</p>