diff --git a/Makefile.am b/Makefile.am
index 3eba4ea63764ac02c8460429e42ff529437dcb04..639e54bda068d4c9cb6828339f41df6194f3ff00 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -612,10 +612,16 @@ if !MANPAGES_IN_DOC
 	  exit 1; \
 	fi
 endif
+## Sphinx provides little control over what content should be included. Some
+## mechanisms exist, but they all have drawbacks or actual issues. Since we
+## build two different versions of the documentation--once without man pages and
+## once, if enabled, with them--some control is necessary. xmpp-wrapper provides
+## us with this, but requires running in a temporary directory. It moves the
+## correct files into place depending on environment variables.
 	dir=$(dir $@) && \
 	@mkdir_p@ $$dir && \
-	PYTHONPATH=. ENABLE_MANPAGES=$(ENABLE_MANPAGES) \
-	$(RUN_IN_TEMPDIR) bash autotools/sphinx-wrapper $(SPHINX) -q -W -b html \
+	PYTHONPATH=. ENABLE_MANPAGES=$(ENABLE_MANPAGES) COPY_DOC=1 \
+	$(RUN_IN_TEMPDIR) autotools/sphinx-wrapper $(SPHINX) -q -W -b html \
 	    -d . \
 	    -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
 	    -D release="$(PACKAGE_VERSION)" \
diff --git a/autotools/run-in-tempdir b/autotools/run-in-tempdir
index 6622d406553cc3036f8522d6812cb089ee57e3b2..3c1a79ba5b6bf3ff64d1b7ee3b213a741d2a6740 100755
--- a/autotools/run-in-tempdir
+++ b/autotools/run-in-tempdir
@@ -9,10 +9,15 @@ tmpdir=$(mktemp -d -t gntbuild.XXXXXXXX)
 trap "rm -rf $tmpdir" EXIT
 
 # fully copy items
-cp -r doc autotools daemons scripts lib tools qa $tmpdir
-
-#mkdir $tmpdir/doc
-#ln -s $PWD/doc/examples $tmpdir/doc
+cp -r autotools daemons scripts lib tools qa $tmpdir
+
+if [[ -z "$COPY_DOC" ]]; then
+  mkdir $tmpdir/doc
+  ln -s $PWD/doc/examples $tmpdir/doc
+else
+  # Building documentation requires all files
+  cp -r doc $tmpdir
+fi
 
 mkdir $tmpdir/test/
 cp -r test/py $tmpdir/test/py