Docs: Update sphinx targets with the build directory

Because Makefile.sphinx looks like a standard makefile from the sphinx
project, it probably shouldn't be updated without good reason. This
change lets us update the output directory and tell the Makefile.sphinx
where we want the output.

Also fix the spacing on PDFLATEX to match the new SPHINXDIR variable.

Signed-off-by: Martin Roth <gaumless@gmail.com>
Change-Id: Iab111e8feea8ec02260f39636e7c17fd1cae7c30
Reviewed-on: https://review.coreboot.org/c/coreboot/+/75499
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de>
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 17aec29..19b1f80 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -4,7 +4,8 @@
 # hacked together by Stefan Reinauer <stepan@openbios.org>
 #
 
-PDFLATEX=pdflatex -t a4
+PDFLATEX  = pdflatex -t a4
+SPHINXDIR = _build
 
 FIGS=codeflow.pdf hypertransport.pdf
 
@@ -32,6 +33,9 @@
 	convert $< $@
 endif
 
+$(SPHINXDIR):
+	mkdir -p $(SPHINXDIR)
+
 corebootPortingGuide.toc: $(FIGS) corebootBuildingGuide.tex
 	# 2 times to make sure we have a current toc.
 	$(PDFLATEX) corebootBuildingGuide.tex
@@ -40,11 +44,11 @@
 corebootPortingGuide.pdf: $(FIGS) corebootBuildingGuide.tex corebootPortingGuide.toc
 	$(PDFLATEX) corebootBuildingGuide.tex
 
-sphinx:
-	$(MAKE) -f Makefile.sphinx html
+sphinx: $(SPHINXDIR)
+	$(MAKE) -f Makefile.sphinx html BUILDDIR="$(SPHINXDIR)""
 
 clean-sphinx:
-	$(MAKE) -f Makefile.sphinx clean
+	$(MAKE) -f Makefile.sphinx clean BUILDDIR="$(SPHINXDIR)"
 
 clean: clean-sphinx
 	rm -f *.aux *.idx *.log *.toc *.out $(FIGS)
@@ -52,8 +56,8 @@
 distclean: clean
 	rm -f corebootPortingGuide.pdf
 
-livesphinx:
-	$(MAKE) -f Makefile.sphinx livehtml SPHINXOPTS="$(SPHINXOPTS)"
+livesphinx: $(SPHINXDIR)
+	$(MAKE) -f Makefile.sphinx livehtml SPHINXOPTS="$(SPHINXOPTS)" BUILDDIR="$(SPHINXDIR)"
 
 test:
 	@echo "Test for logging purposes - Failing tests will not fail the build"