2011-03-04  Benjamin Kosnik  <bkoz@chula>

	    PR libstdc++/47145
	    * acinclude.m4 (GLIBCXX_CONFIGURE_DOCBOOK): Define.
	    * configure.ac: Use it.
	    * doc/Makefile.am (XSL_STYLE_DIR): Set at configure time.
	    * configure: Regenerate.
	    * doc/Makefile.in: Regenerate.


Index: configure.ac
===================================================================
--- configure.ac	(revision 170762)
+++ configure.ac	(working copy)
@@ -344,12 +344,8 @@
 # Check for docbook
 AC_CHECK_PROG([XSLTPROC], xsltproc, yes, no)
 AC_CHECK_PROG([XMLLINT], xmllint, yes, no)
+GLIBCXX_CONFIGURE_DOCBOOK
 
-glibcxx_stylesheets=no
-if test -f /usr/share/sgml/docbook/xsl-ns-stylesheets/VERSION; then
-  glibcxx_stylesheets=yes
-fi
-
 # Check for xml/html dependencies.
 AM_CONDITIONAL(BUILD_XML,
 	       test $ac_cv_prog_DOXYGEN = "yes" &&
@@ -378,7 +374,7 @@
 	       test $ac_cv_prog_PDFLATEX = "yes")
 
 AC_CHECK_PROG([RUBY], ruby, yes, no)
-AC_CHECK_PROG([DBTOEPUB], dbtoepubm, yes, no)
+AC_CHECK_PROG([DBTOEPUB], dbtoepub, yes, no)
 AM_CONDITIONAL(BUILD_EPUB,
 	       test $ac_cv_prog_RUBY = "yes" &&
 	       test $ac_cv_prog_DBTOEPUB = "yes")
Index: acinclude.m4
===================================================================
--- acinclude.m4	(revision 170762)
+++ acinclude.m4	(working copy)
@@ -622,5 +621,48 @@
 
 
+dnl
+dnl Does any necessary configuration of the documentation directory.
+dnl
+dnl XSLTPROC must be set before this
+dnl
+dnl Sets:
+dnl  glibcxx_stylesheets
+dnl Substs:
+dnl  XSL_STYLE_DIR
+dnl
+AC_DEFUN([GLIBCXX_CONFIGURE_DOCBOOK], [
+
+AC_MSG_CHECKING([for stylesheets used in generation of documentation])
+glibcxx_stylesheets=no
+if test x${XSLTPROC} = xyes && echo '<title/>' | xsltproc --noout --nonet --xinclude http://docbook.sourceforge.net/release/xsl-ns/current/xhtml-1_1/docbook.xsl - 2>/dev/null; then
+  glibcxx_stylesheets=yes
+fi
+AC_MSG_RESULT($glibcxx_stylesheets)
+
+AC_MSG_CHECKING([for local stylesheet directory])
+glibcxx_local_stylesheets=no
+if test x"$glibcxx_stylesheets" = x"yes"; then
+  if test -d /usr/share/sgml/docbook/xsl-ns-stylesheets; then
+    glibcxx_local_stylesheets=yes
+    XSL_STYLE_DIR=/usr/share/sgml/docbook/xsl-ns-stylesheets
+  fi
+  if test -d /usr/share/xml/docbook/stylesheet/docbook-xsl-ns; then
+    glibcxx_local_stylesheets=yes
+    XSL_STYLE_DIR=/usr/share/xml/docbook/stylesheet/docbook-xsl-ns
+  fi
+fi
+AC_MSG_RESULT($glibcxx_local_stylesheets)
+
+if test x"$glibcxx_local_stylesheets" = x"yes"; then
+  AC_SUBST(XSL_STYLE_DIR)
+  AC_MSG_NOTICE($XSL_STYLE_DIR)
+else
+  glibcxx_stylesheets=no
+fi
+])
+
+
+dnl
 dnl Set up *_INCLUDES variables for all sundry Makefile.am's.
 dnl
 dnl Substs:
Index: doc/Makefile.am
===================================================================
--- doc/Makefile.am	(revision 170762)
+++ doc/Makefile.am	(working copy)
@@ -368,12 +368,9 @@
 
 XSLTPROC       = xsltproc
 XSLTPROC_FLAGS = --nonet --xinclude
-#XSL_STYLE_DIR = /usr/share/sgml/docbook/xsl-stylesheets
-XSL_STYLE_DIR = /usr/share/sgml/docbook/xsl-ns-stylesheets
+#XSL_STYLE_DIR = /usr/share/xml/docbook/stylesheet/docbook-xsl-ns
+#XSL_STYLE_DIR = /usr/share/sgml/docbook/xsl-ns-stylesheets
 XSL_FO_STYLE = $(XSL_STYLE_DIR)/fo/docbook.xsl
-#XSL_HTML_STYLE = $(XSL_STYLE_DIR)/xhtml/chunk.xsl
-#XSL_HTML_SINGLE_STYLE = $(XSL_STYLE_DIR)/xhtml/onechunk.xsl
-#XSL_HTML_SINGLE_STYLE = $(XSL_STYLE_DIR)/xhtml/docbook.xsl
 XSL_HTML_STYLE = $(XSL_STYLE_DIR)/xhtml-1_1/chunk.xsl
 XSL_HTML_SINGLE_STYLE = $(XSL_STYLE_DIR)/xhtml-1_1/docbook.xsl
 XSL_EPUB_STYLE = $(XSL_STYLE_DIR)/epub/docbook.xsl
@@ -398,13 +395,11 @@
 
 # Validate existing XML structure.
 XMLLINT = xmllint
-#LINT_FLAGS = --debug --xinclude --nsclean --postvalid --nowarning --nonet
-#LINT_FLAGS = --xinclude --postvalid --noent --noblanks --noout
-LINT_FLAGS = --debug --xinclude --noent --noblanks  --nonet --noout
-#SCHEMA_FLAGS = --relaxng /usr/share/xml/docbook5/schema/rng/5.0/docbookxi.rng
-SCHEMA_FLAGS = --dtdvalid /usr/share/xml/docbook5/schema/dtd/5.0/docbook.dtd
+LINT_FLAGS = --debug --xinclude --noent --noblanks --noout
+SCHEMA_FLAGS = http://www.docbook.org/xml/5.0/dtd/docbook.dtd
+#SCHEMA_FLAGS = --nonet /usr/share/xml/docbook5/schema/dtd/5.0/docbook.dtd
+XMLLINT_VALID_FLAGS = $(LINT_FLAGS) --dtdvalid $(SCHEMA_FLAGS)
 XMLLINT_FLAGS = --xinclude --nsclean --c14n --noent --noblanks --nocdata
-XMLLINT_VALID_FLAGS = $(LINT_FLAGS) $(SCHEMA_FLAGS)
 doc-xml-validate-docbook: $(xml_sources)
 	@echo "Generating XML validation log..."
 	$(XMLLINT) $(XMLLINT_VALID_FLAGS) ${top_srcdir}/doc/xml/spine.xml
