Index: BOOK/Makefile
===================================================================
--- BOOK/Makefile	(revision 48846354b7bafcb5e09e84a47400d1f9fb537298)
+++ BOOK/Makefile	(revision 122ebf0f6dbcbf06f1bf7e0dc6d5a09df43f51ce)
@@ -2,6 +2,7 @@
 DUMPDIR		:= ~/cross-lfs-embedded-commands
 DLLISTDIR	:= ~/cross-lfs-embedded-dllist
+RENDERTMP       := $(HOME)/tmp
 CHUNK_QUIET	:= 1
-XSLROOTDIR	:= /usr/share/xml/docbook/xsl-stylesheets-1.69.1
+ROOT_ID         :=
 
 S		:= -
@@ -12,5 +13,4 @@
 ARCHS_NOCHUNKS	:= $(ARCHS:%=%$(S)nochunks)
 ARCHS_PDF	:= $(ARCHS:%=%$(S)pdf)
-ARCHS_TEXT	:= $(ARCHS:%=%$(S)text)
 ARCHS_VALIDATE	:= $(ARCHS:%=%$(S)validate)
 ARCHS_TROUBLE	:= $(ARCHS:%=%$(S)trouble)
@@ -18,20 +18,34 @@
 ARCHS_DLLIST	:= $(ARCHS:%=%$(S)dllist)
 
-.PHONY: lfs tidy render titlepage $(ARCHS_HTML) nochunks $(ARCHS_NOCHUNKS) pdf $(ARCHS_PDF) text $(ARCHS_TEXT) validate $(ARCHS_VALIDATE) trouble $(ARCHS_TROUBLE) dump-commands $(ARCHS_DUMP) download-list $(ARCHS_DLLIST)
+ifdef V
+  Q =
+else
+  Q = @
+endif
 
-lfs: render tidy
+.PHONY: lfs tidy render titlepage $(ARCHS_HTML) nochunks $(ARCHS_NOCHUNKS) pdf \
+	$(ARCHS_PDF) validate $(ARCHS_VALIDATE) trouble $(ARCHS_TROUBLE) \
+	dump-commands $(ARCHS_DUMP) download-list $(ARCHS_DLLIST) tmpdir
+
+lfs: tmpdir render tidy
+
+tmpdir:
+	@echo "Creating and cleaning $(RENDERTMP)"
+	$(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
+	$(Q)rm -f $(RENDERTMP)/*-{full,html,pdf}.xml
+	$(Q)rm -f $(RENDERTMP)/*-pdf.fo
 
 ifeq ($(shell which tidy >/dev/null 2>&1 && echo yes),yes)
 tidy:
-	@echo Running tidy on the created HTML
-	@for filename in `find $(BASEDIR) -name "*.html"`; do \
-	  tidy -config tidy.conf $$filename; \
+	@echo "Running tidy on the created HTML"
+	$(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
+	  tidy -config $(PWD)/tidy.conf $$filename; \
 	  true; \
-	  sh obfuscate.sh $$filename; \
+	  sh $(PWD)/obfuscate.sh $$filename; \
 	  sed -i -e "s@text/html@application/xhtml+xml@g" $$filename; \
 	done;
 else
 tidy:
-	@echo Tidy is not installed on this system
+	@echo "Tidy is not installed on this system"
 endif
 
@@ -39,43 +53,80 @@
 
 titlepage:
-	@xsltproc --nonet --output $(BASEDIR)/index.html $(PWD)/stylesheets/top-index.xsl $(PWD)/index.xml
+	$(Q)xsltproc --nonet --output $(BASEDIR)/index.html \
+	  $(PWD)/stylesheets/top-index.xsl $(PWD)/index.xml
 
 $(ARCHS_HTML): override html_arch = $(@:%$(S)html=%)
 $(ARCHS_HTML):
-	@echo "Rendering HTML of $(html_arch)..."
-	@xsltproc --xinclude --nonet -stringparam profile.condition html -stringparam chunk.quietly $(CHUNK_QUIET) -stringparam base.dir $(BASEDIR)/$(html_arch)/ $(PWD)/stylesheets/lfs-chunked.xsl $(PWD)/$(html_arch)-index.xml
-	@mkdir -p $(BASEDIR)/$(html_arch)/stylesheets
-	@cp $(PWD)/stylesheets/*.css $(BASEDIR)/$(html_arch)/stylesheets
-	@sed -i -e "s@../stylesheets@stylesheets@g" $(BASEDIR)/$(html_arch)/*.html
-	@mkdir -p $(BASEDIR)/$(html_arch)/images
-	@cp $(XSLROOTDIR)/images/*.png $(BASEDIR)/$(html_arch)/images
-	@sed -i -e "s@../images@images@g" $(BASEDIR)/$(html_arch)/*.html
+	@echo "Validating $(html_arch) book..."
+	$(Q)xmllint --nonet --noent --xinclude --postvalid \
+	  -o $(RENDERTMP)/$(html_arch)-full.xml $(PWD)/$(html_arch)-index.xml
 
-nochunks: $(ARCHS_NOCHUNKS) tidy
+	@echo "Generating profiled $(html_arch) book for XHTML..."
+	$(Q)xsltproc --nonet --stringparam profile.condition html \
+	  --output $(RENDERTMP)/$(html_arch)-html.xml \
+	  $(PWD)/stylesheets/lfs-xsl/profile.xsl $(RENDERTMP)/$(html_arch)-full.xml
+
+	@echo "Rendering chunked XHTML of $(html_arch)..."
+	$(Q)xsltproc --nonet -stringparam chunk.quietly $(CHUNK_QUIET) \
+	  -stringparam rootid "$(ROOT_ID)" \
+	  -stringparam base.dir $(BASEDIR)/$(html_arch)/ \
+	  $(PWD)/stylesheets/clfs-chunked.xsl $(RENDERTMP)/$(html_arch)-html.xml
+
+	@echo "Copying CSS code and images..."
+	$(Q)mkdir -p $(BASEDIR)/$(html_arch)/stylesheets
+	$(Q)cp $(PWD)/stylesheets/lfs-xsl/*.css $(BASEDIR)/$(html_arch)/stylesheets
+	$(Q)sed -i -e "s@../stylesheets@stylesheets@g" $(BASEDIR)/$(html_arch)/*.html
+	$(Q)mkdir -p $(BASEDIR)/$(html_arch)/images
+	$(Q)cp $(PWD)/images/*.png $(BASEDIR)/$(html_arch)/images
+	$(Q)sed -i -e "s@../images@images@g" $(BASEDIR)/$(html_arch)/*.html
+
+nochunks: tmpdir $(ARCHS_NOCHUNKS) tidy
 
 $(ARCHS_NOCHUNKS): override nochunk_arch = $(@:%$(S)nochunks=%)
 $(ARCHS_NOCHUNKS):
+	@echo "Validating $(nochunk_arch) book..."
+	$(Q)xmllint --nonet --noent --xinclude --postvalid \
+	  -o $(RENDERTMP)/$(nochunk_arch)-full.xml $(PWD)/$(nochunk_arch)-index.xml
+
+	@echo "Generating profiled $(nochunk_arch) book for XHTML..."
+	$(Q)xsltproc --nonet --stringparam profile.condition html \
+	  --output $(RENDERTMP)/$(nochunk_arch)-html.xml \
+	  $(PWD)/stylesheets/lfs-xsl/profile.xsl \
+	  $(RENDERTMP)/$(nochunk_arch)-full.xml
+
 	@echo "Rendering Single File HTML of $(nochunk_arch)..."
-	@xsltproc --xinclude --nonet -stringparam profile.condition html --output $(BASEDIR)/CLFS-BOOK-$(nochunk_arch).html $(PWD)/stylesheets/lfs-nochunks.xsl $(nochunk_arch)-index.xml
+	$(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
+	  --output $(BASEDIR)/CLFS-EMBEDDED-$(nochunk_arch).html \
+	  $(PWD)/stylesheets/clfs-nochunks.xsl $(RENDERTMP)/$(nochunk_arch)-html.xml
 
-pdf: $(ARCHS_PDF)
+	@echo "Running Tidy..."
+	$(Q)tidy -config $(PWD)/tidy.conf $(BASEDIR)/CLFS-EMBEDDED-$(nochunk_arch).html || true
+	@echo "Running obfuscate.sh..."
+	$(Q)sh $(PWD)/obfuscate.sh $(BASEDIR)/CLFS-EMBEDDED-$(nochunk_arch).html
+	$(Q)sed -i -e "s@text/html@application/xhtml+xml@g"  \
+	  $(BASEDIR)/CLFS-EMBEDDED-$(nochunk_arch).html
+
+pdf: tmpdir $(ARCHS_PDF)
 
 $(ARCHS_PDF): override pdf_arch =  $(@:%$(S)pdf=%)
 $(ARCHS_PDF):
+	@echo "Validating $(pdf_arch) book..."
+	$(Q)xmllint --nonet --noent --xinclude --postvalid \
+	  -o $(RENDERTMP)/$(pdf_arch)-full.xml $(PWD)/$(pdf_arch)-index.xml
+
+	@echo "Generating profiled $(pdf_arch) book for PDF..."
+	$(Q)xsltproc --nonet --stringparam profile.condition pdf \
+	  --output $(RENDERTMP)/$(pdf_arch)-pdf.xml \
+	  $(PWD)/stylesheets/lfs-xsl/profile.xsl \
+	  $(RENDERTMP)/$(pdf_arch)-full.xml
+
+	@echo "Generating FO file of $(pdf_arch)..."
+	$(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
+	  --output $(RENDERTMP)/$(pdf_arch).fo $(PWD)/stylesheets/clfs-pdf.xsl \
+	  $(RENDERTMP)/$(pdf_arch)-pdf.xml
+	$(Q)sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/$(pdf_arch).fo
+
 	@echo "Rendering PDF of $(pdf_arch)..."
-	@xsltproc --xinclude --nonet --output $(BASEDIR)/clfs-$(pdf_arch)-pdf.fo $(PWD)/stylesheets/lfs-pdf.xsl $(pdf_arch)-index.xml
-	@sed -i -e "s/inherit/all/" $(BASEDIR)/clfs-$(pdf_arch)-pdf.fo
-	@fop.sh -q -fo $(BASEDIR)/clfs-$(pdf_arch)-pdf.fo -pdf $(BASEDIR)/CLFS-BOOK-$(pdf_arch).pdf
-	@rm $(BASEDIR)/clfs-$(pdf_arch)-pdf.fo
-
-text: $(ARCHS_TEXT)
-
-$(ARCHS_TEXT): override text_arch =  $(@:%$(S)text=%)
-$(ARCHS_TEXT):
-	@echo "Rendering Text of $(text_arch)..."
-	@xsltproc --xinclude --nonet --output $(BASEDIR)/clfs-$(text_arch)-text.fo $(PWD)/stylesheets/lfs-pdf.xsl $(text_arch)-index.xml
-	@sed -i -e "s/inherit/all/" $(BASEDIR)/clfs-$(text_arch)-text.fo ; \
-	@fop.sh -q -fo $(BASEDIR)/clfs-$(text_arch)-text.fo -txt $(BASEDIR)/CLFS-BOOK-$(text_arch).txt ; \
-	@rm $(BASEDIR)/clfs-$(text_arch)-text.fo
+	$(Q)fop $(RENDERTMP)/$(pdf_arch).fo $(BASEDIR)/CLFS-EMBEDDED-$(pdf_arch).pdf
 
 validate: $(ARCHS_VALIDATE)
@@ -84,5 +135,5 @@
 $(ARCHS_VALIDATE):
 	@echo "Validating $(validate_arch)..."
-	@xmllint --xinclude --noout --nonet --postvalid $(PWD)/$(validate_arch)-index.xml
+	$(Q)xmllint --xinclude --noout --nonet --postvalid $(PWD)/$(validate_arch)-index.xml
 
 trouble: $(ARCHS_TROUBLE)
@@ -91,7 +142,8 @@
 $(ARCHS_TROUBLE):
 	@echo "Troubleshooting $(trouble_arch)..."
-	@xmllint --xinclude --nonet --postvalid $(PWD)/$(trouble_arch)-index.xml > /tmp/dump-$(trouble_arch)
-	@xmllint --xinclude --noout --nonet --valid /tmp/dump-$(trouble_arch)
-	@echo "You can now look at /tmp/dump-$(trouble_arch) to see the errors"
+	$(Q)xmllint --xinclude --nonet --postvalid \
+	  -o $(RENDERTMP)/dump-$(trouble_arch) $(PWD)/$(trouble_arch)-index.xml
+	$(Q)xmllint --xinclude --noout --nonet --valid $(RENDERTMP)/dump-$(trouble_arch)
+	@echo "You can now look at $(RENDERTMP)/dump-$(trouble_arch) to see the errors"
 
 dump-commands: $(ARCHS_DUMP)
@@ -100,5 +152,6 @@
 $(ARCHS_DUMP):
 	@echo "Extracting commands from $(dump_arch)..."
-	@xsltproc --xinclude --nonet --output $(DUMPDIR)/$(dump_arch)/ $(PWD)/stylesheets/dump-commands.xsl $(dump_arch)-index.xml
+	$(Q)xsltproc --xinclude --nonet --output $(DUMPDIR)/$(dump_arch)/ \
+	  $(PWD)/stylesheets/dump-commands.xsl $(PWD)/$(dump_arch)-index.xml
 
 download-list: $(ARCHS_DLLIST)
@@ -107,5 +160,6 @@
 $(ARCHS_DLLIST):
 	@echo "Creating download list for $(dllist_arch)..."
-	@xsltproc --xinclude --nonet --output $(DLLISTDIR)/$(dllist_arch).dl.list $(PWD)/stylesheets/wget.xsl $(dllist_arch)-index.xml
+	$(Q)xsltproc --xinclude --nonet --output $(DLLISTDIR)/$(dllist_arch).dl.list \
+	  $(PWD)/stylesheets/wget.xsl $(PWD)/$(dllist_arch)-index.xml
 
 help:
@@ -118,7 +172,4 @@
 	@echo "PDF Targets"
 	@echo -e "  \e[0;32mpdf \e[0;34m$(ARCHS_PDF)\e[0;0m"
-	@echo
-	@echo "Text Targets"
-	@echo -e "  \e[0;32mtext \e[0;34m$(ARCHS_TEXT)\e[0;0m"
 	@echo
 	@echo "Validate Targets"
