diff --git a/lib/spack/docs/Makefile b/lib/spack/docs/Makefile
index 00203b5b61c5368183b30ba7789217ae552865fd..302ffd4c97979c48031b4c3af55b7f529a8821fe 100644
--- a/lib/spack/docs/Makefile
+++ b/lib/spack/docs/Makefile
@@ -21,24 +21,6 @@ I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
 
 all: html
 
-#
-# This autogenerates a package list.
-#
-package_list:
-	spack package-list > package_list.rst
-
-#
-# Generate a command index
-#
-command_index:
-	cp command_index.in command_index.rst
-	echo >> command_index.rst
-	grep -ho '.. _spack-.*:' *rst \
-	| perl -pe 's/.. _([^:]*):/   * :ref:`\1`/' \
-	| sort >> command_index.rst
-
-custom_targets: package_list command_index
-
 #
 # This creates a git repository and commits generated html docs.
 # It them pushes the new branch into THIS repository as gh-pages.
@@ -92,7 +74,7 @@ clean:
 	-rm -f package_list.rst command_index.rst
 	-rm -rf $(BUILDDIR)/* $(APIDOC_FILES)
 
-html: apidoc custom_targets
+html: apidoc
 	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
 	@echo
 	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
diff --git a/lib/spack/docs/basic_usage.rst b/lib/spack/docs/basic_usage.rst
index a5478d10c2f19c6b0deabb7bc42f60743e6d63d0..342c93d609334e5167bc8dfac1d4a51fb65e6fc6 100644
--- a/lib/spack/docs/basic_usage.rst
+++ b/lib/spack/docs/basic_usage.rst
@@ -779,7 +779,7 @@ use the triplet form of platform, operating system and processor.
 Users on non-Cray systems won't have to worry about specifying the architecture.
 Spack will autodetect what kind of operating system is on your machine as well
 as the processor. For more information on how the architecture can be
-used on Cray machines, check here :ref:`spack-cray`
+used on Cray machines, check here :ref:`cray-support`
 
 
 .. _sec-virtual-dependencies:
@@ -1798,7 +1798,7 @@ This issue typically manifests with the error below:
 A nicer error message is TBD in future versions of Spack.
 
 
-.. _spack-cray:
+.. _cray-support:
 
 Spack on Cray
 -----------------------------
diff --git a/lib/spack/docs/conf.py b/lib/spack/docs/conf.py
index f3cb268177afd06164e0ceaedce4bc222972e1bd..1416074356b2f3e290a78ffe52b7b177d9f6234a 100644
--- a/lib/spack/docs/conf.py
+++ b/lib/spack/docs/conf.py
@@ -37,7 +37,10 @@
 
 import sys
 import os
+import re
+import shutil
 import subprocess
+from glob import glob
 
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
@@ -50,10 +53,36 @@
 os.environ['SPACK_ROOT'] = spack_root
 os.environ['PATH'] += os.pathsep + '$SPACK_ROOT/bin'
 
+# Get the spack version for use in the docs
 spack_version =  subprocess.Popen(
     [spack_root + '/bin/spack', '-V'],
     stderr=subprocess.PIPE).communicate()[1].strip().split('.')
 
+#
+# Generate package list using spack command
+#
+with open('package_list.rst', 'w') as plist_file:
+    subprocess.Popen(
+        [spack_root + '/bin/spack', 'package-list'], stdout=plist_file)
+
+#
+# Find all the `spack-*` references and add them to a command index
+#
+command_names = []
+for filename in glob('*rst'):
+    with open(filename) as f:
+        for line in f:
+            match = re.match(r'.. _(spack-[^:]*)', line)
+            if match:
+                command_names.append(match.group(1).strip())
+
+shutil.copy('command_index.in', 'command_index.rst')
+with open('command_index.rst', 'a') as index:
+    index.write('\n')
+    for cmd in command_names:
+        index.write('   * :ref:`%s`\n' % cmd)
+
+
 # Set an environment variable so that colify will print output like it would to
 # a terminal.
 os.environ['COLIFY_SIZE'] = '25x80'