[gcc(refs/users/marxin/heads/sphinx-v4)] Build system: support Sphinx

Martin Liska marxin@gcc.gnu.org
Mon Jun 28 11:45:34 GMT 2021


https://gcc.gnu.org/g:3f5b1e901c7020227d7d9208a586402ac6a09452

commit 3f5b1e901c7020227d7d9208a586402ac6a09452
Author: Martin Liska <mliska@suse.cz>
Date:   Thu Jun 17 21:55:32 2021 +0200

    Build system: support Sphinx
    
    config/ChangeLog:
    
            * acx.m4: Do not wrap REPORT_BUGS_TO.
    
    ChangeLog:
    
            * configure: Regenerate.
            * configure.ac: Support Sphinx based documentation.
    
    gcc/ChangeLog:
    
            * Makefile.in: Support Sphinx based documentation.
            * configure: Regenerate.
            * configure.ac: Support Sphinx based documentation.
            * genhooks.c (struct s_hook): Emit tm.rst.in file.
    
    gcc/cp/ChangeLog:
    
            * Make-lang.in: Support Sphinx based documentation.
    
    gcc/d/ChangeLog:
    
            * Make-lang.in: Support Sphinx based documentation.
    
    gcc/fortran/ChangeLog:
    
            * Make-lang.in: Support Sphinx based documentation.
    
    gcc/go/ChangeLog:
    
            * Make-lang.in: Support Sphinx based documentation.
    
    libgomp/ChangeLog:
    
            * Makefile.in: Support Sphinx based documentation.
    
    libiberty/ChangeLog:
    
            * Makefile.in: Support Sphinx based documentation.
    
    libitm/ChangeLog:
    
            * Makefile.in: Support Sphinx based documentation.
    
    libquadmath/ChangeLog:
    
            * Makefile.in: Support Sphinx based documentation.

Diff:
---
 config/acx.m4            |   2 +-
 configure                |   1 -
 configure.ac             |   1 -
 gcc/Makefile.in          | 369 +++++++++++++++++++----------------------------
 gcc/configure            |  28 +++-
 gcc/configure.ac         |  15 ++
 gcc/cp/Make-lang.in      |   2 +-
 gcc/d/Make-lang.in       |  60 ++++----
 gcc/fortran/Make-lang.in |  94 ++++--------
 gcc/genhooks.c           | 232 ++++++-----------------------
 gcc/go/Make-lang.in      |  65 ++++-----
 libgomp/Makefile.in      | 149 ++++---------------
 libiberty/Makefile.in    |  39 ++---
 libitm/Makefile.in       | 111 +++-----------
 libquadmath/Makefile.in  | 105 ++------------
 15 files changed, 390 insertions(+), 883 deletions(-)

diff --git a/config/acx.m4 b/config/acx.m4
index 87c1b5e2932..65a7f4bc446 100644
--- a/config/acx.m4
+++ b/config/acx.m4
@@ -615,7 +615,7 @@ AC_DEFUN([ACX_BUGURL],[
     REPORT_BUGS_TEXI=
     ;;
   *)
-    REPORT_BUGS_TO="<$BUGURL>"
+    REPORT_BUGS_TO="$BUGURL"
     REPORT_BUGS_TEXI=@uref{`echo "$BUGURL" | sed 's/@/@@/g'`}
     ;;
   esac;
diff --git a/configure b/configure
index 1224fc4039e..e58cbb65158 100755
--- a/configure
+++ b/configure
@@ -10458,7 +10458,6 @@ case " $configdirs " in
     ;;
 esac
 
-
 # Host tools.
 ncn_tool_prefix=
 test -n "$host_alias" && ncn_tool_prefix=$host_alias-
diff --git a/configure.ac b/configure.ac
index 66d637d70dc..68c209852e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3454,7 +3454,6 @@ case " $configdirs " in
     ;;
 esac
 
-
 # Host tools.
 NCN_STRICT_CHECK_TOOLS(AR, ar)
 NCN_STRICT_CHECK_TOOLS(AS, as)
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 3d8c2b94d70..b6e06d168ef 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -113,14 +113,6 @@ target_objdir := $(toplevel_builddir)/$(target_subdir)
 # Directory where sources are, from where we are.
 VPATH = @srcdir@
 
-# We define a vpath for the sources of the .texi files here because they
-# are split between multiple directories and we would rather use one implicit
-# pattern rule for everything.
-# This vpath could be extended within the Make-lang fragments.
-
-vpath %.texi $(gcc_docdir)
-vpath %.texi $(gcc_docdir)/include
-
 # --------
 # UNSORTED
 # --------
@@ -318,13 +310,6 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_SCRIPT = @INSTALL@
 install_sh = $(SHELL) $(srcdir)/../install-sh
 INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
-MAKEINFO = @MAKEINFO@
-MAKEINFOFLAGS = --no-split
-TEXI2DVI = texi2dvi
-TEXI2PDF = texi2pdf
-TEXI2HTML = $(MAKEINFO) --html
-TEXI2POD = perl $(srcdir)/../contrib/texi2pod.pl
-POD2MAN = pod2man --center="GNU" --release="gcc-$(version)" --date=$(shell sed 's/\(....\)\(..\)\(..\)/\1-\2-\3/' <$(DATESTAMP))
 # Some versions of `touch' (such as the version on Solaris 2.8)
 # do not correctly set the timestamp due to buggy versions of `utime'
 # in the kernel.  So, we use `echo' instead.
@@ -771,11 +756,8 @@ LIBCONVERT =
 # Control whether header files are installed.
 INSTALL_HEADERS=install-headers install-mkheaders
 
-# Control whether Info documentation is built and installed.
-BUILD_INFO = @BUILD_INFO@
-
-# Control whether manpages generated by texi2pod.pl can be rebuilt.
-GENERATED_MANPAGES = @GENERATED_MANPAGES@
+# Control whether manpages generated by sphinx-build can be rebuilt.
+SPHINX_BUILD = @SPHINX_BUILD@
 
 # Additional directories of header files to run fixincludes on.
 # These should be directories searched automatically by default
@@ -906,7 +888,6 @@ PKGVERSION_s:= "\"@PKGVERSION@\""
 BUGURL_s    := "\"@REPORT_BUGS_TO@\""
 
 PKGVERSION  := @PKGVERSION@
-BUGURL_TEXI := @REPORT_BUGS_TEXI@
 
 ifdef REVISION_c
 REVISION_s  := \
@@ -1188,8 +1169,6 @@ FLAGS_TO_PASS = \
 	"LN=$(LN)" \
 	"LN_S=$(LN_S)" \
 	"RANLIB_FOR_TARGET=$(RANLIB_FOR_TARGET)" \
-	"MAKEINFO=$(MAKEINFO)" \
-	"MAKEINFOFLAGS=$(MAKEINFOFLAGS)" \
 	"MAKEOVERRIDES=" \
 	"SHELL=$(SHELL)" \
 	"exeext=$(exeext)" \
@@ -2544,8 +2523,6 @@ s-cfn-operators: build/gencfn-macros$(build_exeext)
 cfn-operators.pd: s-cfn-operators; @true
 
 target-hooks-def.h: s-target-hooks-def-h; @true
-# make sure that when we build info files, the used tm.texi is up to date.
-$(srcdir)/doc/tm.texi: s-tm-texi; @true
 
 s-target-hooks-def-h: build/genhooks$(build_exeext)
 	$(RUN_GEN) build/genhooks$(build_exeext) "Target Hook" \
@@ -2581,38 +2558,20 @@ s-d-target-hooks-def-h: build/genhooks$(build_exeext)
 					     d/d-target-hooks-def.h
 	$(STAMP) s-d-target-hooks-def-h
 
-# check if someone mistakenly only changed tm.texi.
-# We use a different pathname here to avoid a circular dependency.
-s-tm-texi: $(srcdir)/doc/../doc/tm.texi
-
-# The tm.texi we want to compare against / check into svn should have
+# The tm.rst.in we want to compare against / check into svn should have
 # unix-style line endings.  To make this work on MinGW, remove \r.
 # \r is not portable to Solaris tr, therefore we have a special
 # case for ASCII.  We use \r for other encodings like EBCDIC.
-s-tm-texi: build/genhooks$(build_exeext) $(srcdir)/doc/tm.texi.in
-	$(RUN_GEN) build/genhooks$(build_exeext) -d \
-			$(srcdir)/doc/tm.texi.in > tmp-tm.texi
-	case `echo X|tr X '\101'` in \
-	  A) tr -d '\015' < tmp-tm.texi > tmp2-tm.texi ;; \
-	  *) tr -d '\r' < tmp-tm.texi > tmp2-tm.texi ;; \
-	esac
-	mv tmp2-tm.texi tmp-tm.texi
-	$(SHELL) $(srcdir)/../move-if-change tmp-tm.texi tm.texi
-	@if cmp -s $(srcdir)/doc/tm.texi tm.texi; then \
+s-tm-rst-in: build/genhooks$(build_exeext)
+	$(RUN_GEN) build/genhooks$(build_exeext) > tmp-tm.rst.in
+	$(SHELL) $(srcdir)/../move-if-change tmp-tm.rst.in tm.rst.in
+
+	@if cmp -s $(srcdir)/doc/gccint/target-macros/tm.rst.in tm.rst.in; then \
 	  $(STAMP) $@; \
-	elif test $(srcdir)/doc/tm.texi -nt $(srcdir)/doc/tm.texi.in \
-	  && ( test $(srcdir)/doc/tm.texi -nt $(srcdir)/target.def \
-	    || test $(srcdir)/doc/tm.texi -nt $(srcdir)/c-family/c-target.def \
-	    || test $(srcdir)/doc/tm.texi -nt $(srcdir)/common/common-target.def \
-	    || test $(srcdir)/doc/tm.texi -nt $(srcdir)/d/d-target.def \
-	  ); then \
-	  echo >&2 ; \
-	  echo You should edit $(srcdir)/doc/tm.texi.in rather than $(srcdir)/doc/tm.texi . >&2 ; \
-	  false; \
 	else \
 	  echo >&2 ; \
 	  echo Verify that you have permission to grant a GFDL license for all >&2 ; \
-	  echo new text in $(objdir)/tm.texi, then copy it to $(srcdir)/doc/tm.texi. >&2 ; \
+	  echo new text in $(objdir)/tm.rst.in, then copy it to $(srcdir)/doc/gccint/target-macros/tm.rst.in. >&2 ; \
 	  false; \
 	fi
 
@@ -3284,119 +3243,38 @@ install-no-fixedincludes:
 
 # Remake the info files.
 
-doc: $(BUILD_INFO) $(GENERATED_MANPAGES)
+doc: $(SPHINX_BUILD)
 
-INFOFILES = doc/cpp.info doc/gcc.info doc/gccint.info \
-            doc/gccinstall.info doc/cppinternals.info
+INFOFILES = doc/gcc/info/texinfo/gcc.info \
+	    doc/gccint/info/texinfo/gccint.info \
+	    doc/cpp/info/texinfo/cpp.info \
+	    doc/cppinternals/info/texinfo/cppinternals.info \
+	    doc/install/info/texinfo/install.info
 
 info: $(INFOFILES) lang.info @GENINSRC@ srcinfo lang.srcinfo
 
 srcinfo: $(INFOFILES)
 	-cp -p $^ $(srcdir)/doc
 
-TEXI_CPP_FILES = cpp.texi fdl.texi cppenv.texi cppopts.texi		\
-	 gcc-common.texi gcc-vers.texi
-
-TEXI_GCC_FILES = gcc.texi gcc-common.texi gcc-vers.texi frontends.texi	\
-	 standards.texi invoke.texi extend.texi md.texi objc.texi	\
-	 gcov.texi trouble.texi bugreport.texi service.texi		\
-	 contribute.texi compat.texi funding.texi gnu.texi gpl_v3.texi	\
-	 fdl.texi contrib.texi cppenv.texi cppopts.texi avr-mmcu.texi	\
-	 implement-c.texi implement-cxx.texi gcov-tool.texi gcov-dump.texi \
-	 lto-dump.texi
-
-# we explicitly use $(srcdir)/doc/tm.texi here to avoid confusion with
-# the generated tm.texi; the latter might have a more recent timestamp,
-# but we don't want to rebuild the info files unless the contents of
-# the *.texi files have changed.
-TEXI_GCCINT_FILES = gccint.texi gcc-common.texi gcc-vers.texi		\
-	 contribute.texi makefile.texi configterms.texi options.texi	\
-	 portability.texi interface.texi passes.texi rtl.texi md.texi	\
-	 $(srcdir)/doc/tm.texi hostconfig.texi fragments.texi	\
-	 configfiles.texi collect2.texi headerdirs.texi funding.texi	\
-	 gnu.texi gpl_v3.texi fdl.texi contrib.texi languages.texi	\
-	 sourcebuild.texi gty.texi libgcc.texi cfg.texi tree-ssa.texi	\
-	 loop.texi generic.texi gimple.texi plugins.texi optinfo.texi   \
-	 match-and-simplify.texi analyzer.texi ux.texi poly-int.texi
-
-TEXI_GCCINSTALL_FILES = install.texi fdl.texi		\
-	 gcc-common.texi gcc-vers.texi
-
-TEXI_CPPINT_FILES = cppinternals.texi gcc-common.texi gcc-vers.texi
-
-# gcc-vers.texi is generated from the version files.
-gcc-vers.texi: $(BASEVER) $(DEVPHASE)
-	(echo "@set version-GCC $(BASEVER_c)"; \
-	 if [ "$(DEVPHASE_c)" = "experimental" ]; \
-	 then echo "@set DEVELOPMENT"; \
-	 else echo "@clear DEVELOPMENT"; \
-	 fi) > $@T
-	$(build_file_translate) echo @set srcdir `echo $(abs_srcdir) | sed -e 's|\\([@{}]\\)|@\\1|g'` >> $@T
-	if [ -n "$(PKGVERSION)" ]; then \
-	  echo "@set VERSION_PACKAGE $(PKGVERSION)" >> $@T; \
-	fi
-	echo "@set BUGURL $(BUGURL_TEXI)" >> $@T; \
-	mv -f $@T $@
-
-
-# The *.1, *.7, *.info, *.dvi, and *.pdf files are being generated from implicit
-# patterns.  To use them, put each of the specific targets with its
-# specific dependencies but no build commands.
+PDFFILES = doc/gcc/pdf/latex/gcc.pdf doc/gccint/pdf/latex/gccint.pdf doc/install/pdf/latex/install.pdf \
+	   doc/cpp/pdf/latex/cpp.pdf doc/cppinternals/pdf/latex/cppinternals.pdf
 
-doc/cpp.info: $(TEXI_CPP_FILES)
-doc/gcc.info: $(TEXI_GCC_FILES)
-doc/gccint.info: $(TEXI_GCCINT_FILES)
-doc/cppinternals.info: $(TEXI_CPPINT_FILES)
-
-doc/%.info: %.texi
-	if [ x$(BUILD_INFO) = xinfo ]; then \
-		$(MAKEINFO) $(MAKEINFOFLAGS) -I . -I $(gcc_docdir) \
-			-I $(gcc_docdir)/include -o $@ $<; \
-	fi
-
-# Duplicate entry to handle renaming of gccinstall.info
-doc/gccinstall.info: $(TEXI_GCCINSTALL_FILES)
-	if [ x$(BUILD_INFO) = xinfo ]; then \
-		$(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
-			-I $(gcc_docdir)/include -o $@ $<; \
-	fi
-
-doc/cpp.dvi: $(TEXI_CPP_FILES)
-doc/gcc.dvi: $(TEXI_GCC_FILES)
-doc/gccint.dvi: $(TEXI_GCCINT_FILES)
-doc/cppinternals.dvi: $(TEXI_CPPINT_FILES)
-
-doc/cpp.pdf: $(TEXI_CPP_FILES)
-doc/gcc.pdf: $(TEXI_GCC_FILES)
-doc/gccint.pdf: $(TEXI_GCCINT_FILES)
-doc/cppinternals.pdf: $(TEXI_CPPINT_FILES)
-
-$(build_htmldir)/cpp/index.html: $(TEXI_CPP_FILES)
-$(build_htmldir)/gcc/index.html: $(TEXI_GCC_FILES)
-$(build_htmldir)/gccint/index.html: $(TEXI_GCCINT_FILES)
-$(build_htmldir)/cppinternals/index.html: $(TEXI_CPPINT_FILES)
-
-dvi:: doc/gcc.dvi doc/gccint.dvi doc/gccinstall.dvi doc/cpp.dvi \
-      doc/cppinternals.dvi lang.dvi
-
-doc/%.dvi: %.texi
-	$(TEXI2DVI) -I . -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
+pdf:: $(PDFFILES) lang.pdf
 
-# Duplicate entry to handle renaming of gccinstall.dvi
-doc/gccinstall.dvi: $(TEXI_GCCINSTALL_FILES)
-	$(TEXI2DVI) -I . -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
+doc/gcc/pdf/latex/gcc.pdf: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(srcdir)/doc/gcc BUILDDIR=$(objdir)/doc/gcc/pdf
 
-PDFFILES = doc/gcc.pdf doc/gccint.pdf doc/gccinstall.pdf doc/cpp.pdf \
-           doc/cppinternals.pdf
+doc/gccint/pdf/latex/gccint.pdf: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(srcdir)/doc/gccint BUILDDIR=$(objdir)/doc/gccint/pdf
 
-pdf:: $(PDFFILES) lang.pdf
+doc/install/pdf/latex/install.pdf: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(srcdir)/doc/install BUILDDIR=$(objdir)/doc/install/pdf
 
-doc/%.pdf: %.texi
-	$(TEXI2PDF) -I . -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
+doc/cpp/pdf/latex/cpp.pdf: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(srcdir)/doc/cpp BUILDDIR=$(objdir)/doc/cpp/pdf
 
-# Duplicate entry to handle renaming of gccinstall.pdf
-doc/gccinstall.pdf: $(TEXI_GCCINSTALL_FILES)
-	$(TEXI2PDF) -I . -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
+doc/cppinternals/pdf/latex/cppinternals.pdf: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(srcdir)/doc/cppinternals BUILDDIR=$(objdir)/doc/cppinternals/pdf
 
 # List the directories or single hmtl files which are installed by
 # install-html. The lang.html file triggers language fragments to build
@@ -3406,70 +3284,78 @@ HTMLS_INSTALL=$(build_htmldir)/cpp $(build_htmldir)/gcc \
        $(build_htmldir)/cppinternals
 
 # List the html file targets.
-HTMLS_BUILD=$(build_htmldir)/cpp/index.html $(build_htmldir)/gcc/index.html \
-       $(build_htmldir)/gccinstall/index.html $(build_htmldir)/gccint/index.html \
-       $(build_htmldir)/cppinternals/index.html lang.html
+HTMLS = doc/gcc/html/html/index.html doc/gccint/html/html/index.html doc/install/html/html/index.html \
+	doc/cpp/html/html/index.html doc/cppinternals/html/html/index.html
+
+html:: $(HTMLS) lang.html
+
+doc/gcc/html/html/index.html: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(srcdir)/doc/gcc BUILDDIR=$(objdir)/doc/gcc/html
 
-html:: $(HTMLS_BUILD)
+doc/gccint/html/html/index.html: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(srcdir)/doc/gccint BUILDDIR=$(objdir)/doc/gccint/html
 
-$(build_htmldir)/%/index.html: %.texi
-	$(mkinstalldirs) $(@D)
-	rm -f $(@D)/*
-	$(TEXI2HTML) -I $(abs_docdir) -I $(abs_docdir)/include -o $(@D) $<
+doc/install/html/html/index.html: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(srcdir)/doc/install BUILDDIR=$(objdir)/doc/install/html
 
-# Duplicate entry to handle renaming of gccinstall
-$(build_htmldir)/gccinstall/index.html: $(TEXI_GCCINSTALL_FILES)
-	$(mkinstalldirs) $(@D)
-	echo rm -f $(@D)/*
-	SOURCEDIR=$(abs_docdir) \
-	DESTDIR=$(@D) \
-	$(SHELL) $(srcdir)/doc/install.texi2html
+doc/cpp/html/html/index.html: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(srcdir)/doc/cpp BUILDDIR=$(objdir)/doc/cpp/html
 
-MANFILES = doc/gcov.1 doc/cpp.1 doc/gcc.1 doc/gfdl.7 doc/gpl.7 \
-           doc/fsf-funding.7 doc/gcov-tool.1 doc/gcov-dump.1 \
-	   $(if $(filter yes,@enable_lto@),doc/lto-dump.1)
+doc/cppinternals/html/html/index.html: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(srcdir)/doc/cppinternals BUILDDIR=$(objdir)/doc/cppinternals/html
 
-generated-manpages: man
+MANFILES = doc/gcc/man/man/gcc.1 doc/cpp/man/man/cpp.1 \
+	   doc/gcc/man/man/gfdl.7 doc/gcc/man/man/gpl.7 \
+           doc/gcc/man/man/fsf-funding.7 doc/gcc/man/man/gcov-tool.1 \
+	   doc/gcc/man/man/gcov.1 doc/gcc/man/man/gcov-dump.1 \
+	   $(if $(filter yes,@enable_lto@),doc/gcc/man/man/lto-dump.1)
+
+export VERSION_PACKAGE="$(PKGVERSION)"
+export ENABLE_LTO=$(enable_lto)
+export BUGURL="$(BUGURL_s)"
 
 man: $(MANFILES) lang.man @GENINSRC@ srcman lang.srcman
 
 srcman: $(MANFILES)
 	-cp -p $^ $(srcdir)/doc
 
-doc/%.1: %.pod
-	$(STAMP) $@
-	-($(POD2MAN) --section=1 $< > $(@).T$$$$ && \
-		mv -f $(@).T$$$$ $@) || \
-		(rm -f $(@).T$$$$ && exit 1)
+sphinx-build: man info
 
-doc/%.7: %.pod
-	$(STAMP) $@
-	-($(POD2MAN) --section=7 $< > $(@).T$$$$ && \
-		mv -f $(@).T$$$$ $@) || \
-		(rm -f $(@).T$$$$ && exit 1)
+RST_FILES:=$(shell find $(srcdir) -name *.rst -or -name *.rst.in)
+SPHINX_CONFIG_FILES:=$(shell find $(srcdir)/.. -name conf.py) $(srcdir)/../doc/baseconf.py
+SPHINX_FILES:=$(RST_FILES) $(SPHINX_CONFIG_FILES)
 
-%.pod: %.texi
-	$(STAMP) $@
-	-$(TEXI2POD) -DBUGURL="$(BUGURL_TEXI)" $< > $@
+doc/gcc/man/man/gcc.1: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc man SOURCEDIR=$(srcdir)/doc/gcc BUILDDIR=$(objdir)/doc/gcc/man
 
-.INTERMEDIATE: cpp.pod gcc.pod gfdl.pod fsf-funding.pod gpl.pod
-cpp.pod: cpp.texi cppenv.texi cppopts.texi
+doc/gcc/man/man/gcov.1: doc/gcc/man/man/gcc.1
+doc/gcc/man/man/gcov-tool.1: doc/gcc/man/man/gcc.1
+doc/gcc/man/man/gcov-dump.1: doc/gcc/man/man/gcc.1
+doc/gcc/man/man/lto-dump.1: doc/gcc/man/man/gcc.1
+doc/gcc/man/man/gfdl.7: doc/gcc/man/man/gcc.1
+doc/gcc/man/man/gpl.7: doc/gcc/man/man/gcc.1
+doc/gcc/man/man/fsf-funding.7: doc/gcc/man/man/gcc.1
 
-# These next rules exist because the output name is not the same as
-# the input name, so our implicit %.pod rule will not work.
+doc/cpp/man/man/cpp.1: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc man SOURCEDIR=$(srcdir)/doc/cpp BUILDDIR=$(objdir)/doc/cpp/man
 
-gcc.pod: invoke.texi cppenv.texi cppopts.texi gcc-vers.texi
-	$(STAMP) $@
-	-$(TEXI2POD) $< > $@
-gfdl.pod: fdl.texi
-	$(STAMP) $@
-	-$(TEXI2POD) $< > $@
-fsf-funding.pod: funding.texi
-	$(STAMP) $@
-	-$(TEXI2POD) $< > $@
-gpl.pod: gpl_v3.texi
-	$(STAMP) $@
-	-$(TEXI2POD) $< > $@
+doc/gcc/info/texinfo/gcc.info: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(srcdir)/doc/gcc BUILDDIR=$(objdir)/doc/gcc/info
+
+doc/gccint/info/texinfo/gccint.info: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(srcdir)/doc/gccint BUILDDIR=$(objdir)/doc/gccint/info
+
+doc/cpp/info/texinfo/cpp.info: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(srcdir)/doc/cpp BUILDDIR=$(objdir)/doc/cpp/info
+
+doc/cppinternals/info/texinfo/cppinternals.info: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(srcdir)/doc/cppinternals BUILDDIR=$(objdir)/doc/cppinternals/info
+
+doc/install/info/texinfo/install.info: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(srcdir)/doc/install BUILDDIR=$(objdir)/doc/install/info
+
+html-gccint: s-tm-rst-in
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(srcdir)/doc/gccint BUILDDIR=$(objdir)/doc/gccint/html
 
 #
 # Deletion of files made during compilation.
@@ -3529,8 +3415,7 @@ clean: mostlyclean lang.clean
 	-rm -f config.h tconfig.h bconfig.h tm_p.h tm.h
 	-rm -f options.c options.h optionlist
 	-rm -f cs-*
-	-rm -f doc/*.dvi
-	-rm -f doc/*.pdf
+	-rm -rf doc
 # Delete the include directories.
 	-rm -rf include include-fixed
 # Delete files used by the "multilib" facility (including libgcc subdirs).
@@ -3558,7 +3443,6 @@ distclean: clean lang.distclean
 	-cd testsuite && rm -f *.out *.gcov *$(coverageexts)
 	-rm -rf ${QMTEST_DIR} stamp-qmtest
 	-rm -f .gdbinit configargs.h
-	-rm -f gcov.pod
 # Delete po/*.gmo only if we are not building in the source directory.
 	-if [ ! -f po/exgettext ]; then rm -f po/*.gmo; fi
 	-rmdir ada cp f java objc intl po testsuite plugin 2>/dev/null
@@ -3571,7 +3455,7 @@ maintainer-clean:
 	$(MAKE) lang.maintainer-clean distclean
 	-rm -f cpp.??s cpp.*aux
 	-rm -f gcc.??s gcc.*aux
-	-rm -f $(gcc_docdir)/*.info $(gcc_docdir)/*.1 $(gcc_docdir)/*.7 $(gcc_docdir)/*.dvi $(gcc_docdir)/*.pdf
+	-rm -rf doc
 #
 # Entry points `install', `install-strip', and `uninstall'.
 # Also use `install-collect2' to install collect2 when the config files don't.
@@ -3768,24 +3652,46 @@ install-info:: doc installdirs \
 	$(DESTDIR)$(infodir)/cpp.info \
 	$(DESTDIR)$(infodir)/gcc.info \
 	$(DESTDIR)$(infodir)/cppinternals.info \
-	$(DESTDIR)$(infodir)/gccinstall.info \
+	$(DESTDIR)$(infodir)/install.info \
 	$(DESTDIR)$(infodir)/gccint.info \
 	lang.install-info
 
-$(DESTDIR)$(infodir)/%.info: doc/%.info installdirs
-	rm -f $@
-	if [ -f $< ]; then \
-	  for f in $(<)*; do \
-	    realfile=`echo $$f | sed -e 's|.*/\([^/]*\)$$|\1|'`; \
-	    $(INSTALL_DATA) $$f $(DESTDIR)$(infodir)/$$realfile; \
-	    chmod a-x $(DESTDIR)$(infodir)/$$realfile; \
-	  done; \
-	else true; fi
-	-if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
-	  if [ -f $@ ]; then \
-	    install-info --dir-file=$(DESTDIR)$(infodir)/dir $@; \
-	  else true; fi; \
-	else true; fi;
+$(DESTDIR)$(infodir)/gcc.info: doc/gcc/info/texinfo/gcc.info installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+
+$(DESTDIR)$(infodir)/gccint.info: doc/gccint/info/texinfo/gccint.info installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+
+$(DESTDIR)$(infodir)/install.info: doc/install/info/texinfo/install.info installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+
+$(DESTDIR)$(infodir)/cpp.info: doc/cpp/info/texinfo/cpp.info installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+
+$(DESTDIR)$(infodir)/cppinternals.info: doc/cppinternals/info/texinfo/cppinternals.info installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+
+$(DESTDIR)$(infodir)/gcov.info: doc/gcc/info/texinfo/gcov.info installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+
+$(DESTDIR)$(infodir)/gcov-tool.info: doc/gcc/info/texinfo/gcov-tool.info installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+
+$(DESTDIR)$(infodir)/gcov-dump.info: doc/gcc/info/texinfo/gcov-dump.info installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+
+$(DESTDIR)$(infodir)/lto-dump.info: doc/gcc/info/texinfo/lto-dump.info installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+
 
 pdf__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 
@@ -3801,7 +3707,7 @@ install-pdf: $(PDFFILES) lang.install-pdf
 
 html__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 
-install-html: $(HTMLS_BUILD) lang.install-html
+install-html: $(HTMLS) lang.install-html
 	@$(NORMAL_INSTALL)
 	test -z "$(htmldir)" || $(mkinstalldirs) "$(DESTDIR)$(htmldir)"
 	@list='$(HTMLS_INSTALL)'; for p in $$list; do \
@@ -3835,32 +3741,47 @@ $(DESTDIR)$(man7dir)/%$(man7ext): doc/%.7 installdirs
 	-$(INSTALL_DATA) $< $@
 	-chmod a-x $@
 
-$(DESTDIR)$(man1dir)/$(GCC_INSTALL_NAME)$(man1ext): doc/gcc.1 installdirs
+$(DESTDIR)$(man1dir)/$(GCC_INSTALL_NAME)$(man1ext): doc/gcc/man/man/gcc.1 installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+	-chmod a-x $@
+
+$(DESTDIR)$(man1dir)/$(CPP_INSTALL_NAME)$(man1ext): doc/cpp/man/man/cpp.1 installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+	-chmod a-x $@
+
+$(DESTDIR)$(man1dir)/$(GCOV_INSTALL_NAME)$(man1ext): doc/gcc/man/man/gcov.1 installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+	-chmod a-x $@
+
+$(DESTDIR)$(man1dir)/$(GCOV_TOOL_INSTALL_NAME)$(man1ext): doc/gcc/man/man/gcov-tool.1 installdirs
 	-rm -f $@
 	-$(INSTALL_DATA) $< $@
 	-chmod a-x $@
 
-$(DESTDIR)$(man1dir)/$(CPP_INSTALL_NAME)$(man1ext): doc/cpp.1 installdirs
+$(DESTDIR)$(man1dir)/$(GCOV_DUMP_INSTALL_NAME)$(man1ext): doc/gcc/man/man/gcov-dump.1 installdirs
 	-rm -f $@
 	-$(INSTALL_DATA) $< $@
 	-chmod a-x $@
 
-$(DESTDIR)$(man1dir)/$(GCOV_INSTALL_NAME)$(man1ext): doc/gcov.1 installdirs
+$(DESTDIR)$(man1dir)/$(LTO_DUMP_INSTALL_NAME)$(man1ext): doc/gcc/man/man/lto-dump.1 installdirs
 	-rm -f $@
 	-$(INSTALL_DATA) $< $@
 	-chmod a-x $@
 
-$(DESTDIR)$(man1dir)/$(GCOV_TOOL_INSTALL_NAME)$(man1ext): doc/gcov-tool.1 installdirs
+$(DESTDIR)$(man7dir)/fsf-funding$(man7ext): doc/gcc/man/man/fsf-funding.7 installdirs
 	-rm -f $@
 	-$(INSTALL_DATA) $< $@
 	-chmod a-x $@
 
-$(DESTDIR)$(man1dir)/$(GCOV_DUMP_INSTALL_NAME)$(man1ext): doc/gcov-dump.1 installdirs
+$(DESTDIR)$(man7dir)/gfdl$(man7ext): doc/gcc/man/man/gfdl.7 installdirs
 	-rm -f $@
 	-$(INSTALL_DATA) $< $@
 	-chmod a-x $@
 
-$(DESTDIR)$(man1dir)/$(LTO_DUMP_INSTALL_NAME)$(man1ext): doc/lto-dump.1 installdirs
+$(DESTDIR)$(man7dir)/gpl$(man7ext): doc/gcc/man/man/gpl.7 installdirs
 	-rm -f $@
 	-$(INSTALL_DATA) $< $@
 	-chmod a-x $@
diff --git a/gcc/configure b/gcc/configure
index f0b2ebde3cf..ba82207748b 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -806,6 +806,7 @@ AR
 NM
 BISON
 FLEX
+SPHINX_BUILD
 GENERATED_MANPAGES
 BUILD_INFO
 MAKEINFO
@@ -7905,7 +7906,7 @@ fi
     REPORT_BUGS_TEXI=
     ;;
   *)
-    REPORT_BUGS_TO="<$BUGURL>"
+    REPORT_BUGS_TO="$BUGURL"
     REPORT_BUGS_TEXI=@uref{`echo "$BUGURL" | sed 's/@/@@/g'`}
     ;;
   esac;
@@ -8557,6 +8558,27 @@ $as_echo "no" >&6; }
 fi
 
 
+# See if sphinx-build has been installed and is modern enough
+# that we can use it.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sphinx-build" >&5
+$as_echo_n "checking for sphinx-build... " >&6; }
+if sphinx-build -j auto -h &>/dev/null ; then
+  SPHINX_BUILD=sphinx-build
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
+  *** sphinx-build is missing or too old.
+  *** Info and man pages documentation will not be built." >&5
+$as_echo "$as_me: WARNING:
+  *** sphinx-build is missing or too old.
+  *** Info and man pages documentation will not be built." >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  SPHINX_BUILD=
+fi
+
+
 MISSING="${CONFIG_SHELL-/bin/sh} $ac_aux_dir/missing"
 
 # How about lex?
@@ -19435,7 +19457,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19438 "configure"
+#line 19460 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19541,7 +19563,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19544 "configure"
+#line 19566 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 70089394429..ce12cbf18e9 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1208,6 +1208,21 @@ else
 fi
 AC_SUBST(GENERATED_MANPAGES)
 
+# See if sphinx-build has been installed and is modern enough
+# that we can use it.
+AC_MSG_CHECKING([for sphinx-build])
+if sphinx-build -j auto -h &>/dev/null ; then
+  SPHINX_BUILD=sphinx-build
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_WARN([
+  *** sphinx-build is missing or too old.
+  *** Info and man pages documentation will not be built.])
+  AC_MSG_RESULT(no)
+  SPHINX_BUILD=
+fi
+AC_SUBST(SPHINX_BUILD)
+
 MISSING="${CONFIG_SHELL-/bin/sh} $ac_aux_dir/missing"
 
 # How about lex?
diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
index 155be74efdb..6e49e3117db 100644
--- a/gcc/cp/Make-lang.in
+++ b/gcc/cp/Make-lang.in
@@ -260,7 +260,7 @@ c++.install-common: installdirs
 
 # We can't use links because not everyone supports them.  So just copy the
 # manpage.
-doc/g++.1: doc/gcc.1
+doc/g++.1: doc/gcc/man/man/gcc.1
 	cp $< doc/g++.1
 
 c++.install-man: $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in
index b3c77a08f46..3c8059919c6 100644
--- a/gcc/d/Make-lang.in
+++ b/gcc/d/Make-lang.in
@@ -174,48 +174,28 @@ d21$(exeext): $(D_ALL_OBJS) attribs.o $(BACKEND) $(LIBDEPS) $(d.prev)
 	@$(call LINK_PROGRESS,$(INDEX.d),end)
 
 # Documentation.
-
-D_TEXI_FILES = \
-	d/gdc.texi \
-	$(gcc_docdir)/include/fdl.texi \
-	$(gcc_docdir)/include/gpl_v3.texi \
-	$(gcc_docdir)/include/gcc-common.texi \
-	gcc-vers.texi
-
-doc/gdc.info: $(D_TEXI_FILES)
-	if test "x$(BUILD_INFO)" = xinfo; then \
-	  rm -f doc/gdc.info*; \
-	  $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
-		-I $(gcc_docdir)/include -o $@ $<; \
+doc/gdc/info/texinfo/gdc.info: $(SPHINX_FILES)
+	+ if [ x$(SPHINX_BUILD) = xsphinx-build ]; then \
+	  make -C $(srcdir)/../doc info SOURCEDIR=$(srcdir)/d/doc BUILDDIR=$(objdir)/doc/gdc/info; \
 	else true; fi
 
-doc/gdc.dvi: $(D_TEXI_FILES)
-	$(TEXI2DVI) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
-
 doc/gdc.pdf: $(D_TEXI_FILES)
 	$(TEXI2PDF) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
 
-$(build_htmldir)/d/index.html: $(D_TEXI_FILES)
-	$(mkinstalldirs) $(@D)
-	rm -f $(@D)/*
-	$(TEXI2HTML) -I $(gcc_docdir) -I $(gcc_docdir)/include \
-		-I $(srcdir)/d -o $(@D) $<
-
-.INTERMEDIATE: gdc.pod
-
-gdc.pod: d/gdc.texi
-	-$(TEXI2POD) -D gdc < $< > $@
-
+doc/gdc/html/html/index.html: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(srcdir)/d/doc BUILDDIR=$(objdir)/doc/gdc/html
 # Build hooks.
 
 d.all.cross: gdc-cross$(exeext)
 d.start.encap: gdc$(exeext)
 d.rest.encap:
-d.info: doc/gdc.info
-d.dvi: doc/gdc.dvi
-d.pdf: doc/gdc.pdf
-d.html: $(build_htmldir)/d/index.html
-d.srcinfo: doc/gdc.info
+d.info: doc/gdc/info/texinfo/gdc.info
+gdc.info: doc/gdc/info/texinfo/gdc.info
+d.pdf: doc/gdc/pdf/latex/gdc.pdf
+gdc.pdf: doc/gdc/pdf/latex/gdc.pdf
+d.html: doc/gdc/html/html/index.html
+gdc.html: doc/gdc/html/html/index.html
+d.srcinfo: doc/gdc/info/texinfo/gdc.info
 	-cp -p $^ $(srcdir)/doc
 d.srcextra:
 
@@ -224,10 +204,13 @@ d.tags: force
 	etags -o TAGS.sub *.c *.cc *.h dmd/*.c dmd/*.h dmd/root/*.h dmd/root/*.c; \
 	etags --include TAGS.sub --include ../TAGS.sub
 
-d.man: doc/gdc.1
-d.srcman: doc/gdc.1
+d.man: doc/gdc/man/man/gdc.1
+d.srcman: doc/gdc/man/man/gdc.1
 	-cp -p $^ $(srcdir)/doc
 
+doc/gdc/man/man/gdc.1: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc man SOURCEDIR=$(srcdir)/d/doc BUILDDIR=$(objdir)/doc/gdc/man
+
 # 'make check' in gcc/ looks for check-d, as do all toplevel D-related
 # check targets.  However, our DejaGNU framework requires 'check-gdc' as its
 # entry point.  We feed the former to the latter here.
@@ -258,6 +241,13 @@ d.install-plugin:
 
 d.install-info: $(DESTDIR)$(infodir)/gdc.info
 
+doc/gdc/pdf/latex/gdc.pdf: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(srcdir)/d/doc BUILDDIR=$(objdir)/doc/gdc/pdf
+
+$(DESTDIR)$(infodir)/gdc.info: doc/gdc/info/texinfo/gdc.info installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+
 d.install-pdf: doc/gdc.pdf
 	@$(NORMAL_INSTALL)
 	test -z "$(pdfdir)" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)/gcc"
@@ -287,7 +277,7 @@ d.install-html: $(build_htmldir)/d
 
 d.install-man: $(DESTDIR)$(man1dir)/$(D_INSTALL_NAME)$(man1ext)
 
-$(DESTDIR)$(man1dir)/$(D_INSTALL_NAME)$(man1ext): doc/gdc.1 installdirs
+$(DESTDIR)$(man1dir)/$(D_INSTALL_NAME)$(man1ext): doc/gdc/man/man/gdc.1 installdirs
 	-rm -f $@
 	-$(INSTALL_DATA) $< $@
 	-chmod a-x $@
diff --git a/gcc/fortran/Make-lang.in b/gcc/fortran/Make-lang.in
index 63195a9c7ed..1435deccb75 100644
--- a/gcc/fortran/Make-lang.in
+++ b/gcc/fortran/Make-lang.in
@@ -109,19 +109,23 @@ fortran.all.cross: gfortran-cross$(exeext)
 fortran.start.encap: gfortran$(exeext)
 fortran.rest.encap:
 
-fortran.srcinfo: doc/gfortran.info
+fortran.srcinfo: doc/fortran/info/texinfo/gfortran.info
 	-cp -p $^ $(srcdir)/fortran
 
 fortran.tags: force
 	cd $(srcdir)/fortran; etags -o TAGS.sub *.c *.h; \
 	etags --include TAGS.sub --include ../TAGS.sub
 
-fortran.info: doc/gfortran.info doc/gfc-internals.info
-fortran.dvi: doc/gfortran.dvi doc/gfc-internals.dvi
+fortran.info: doc/fortran/info/texinfo/gfortran.info doc/gfc-internals/info/texinfo/gfc-internals.info
 
-F95_HTMLFILES = $(build_htmldir)/gfortran
+doc/fortran/info/texinfo/gfortran.info: $(SPHINX_FILES)
+	+ if [ x$(SPHINX_BUILD) = xsphinx-build ]; then \
+	  make -C $(srcdir)/../doc info SOURCEDIR=$(srcdir)/fortran/doc/gfortran BUILDDIR=$(objdir)/doc/fortran/info; \
+	else true; fi
+
+F95_HTMLFILES = doc/fortran/html/html/index.html
 
-fortran.html: $(F95_HTMLFILES)/index.html
+fortran.html: $(F95_HTMLFILES) doc/gfc-internals/html/html/index.html
 
 fortran.install-html: $(F95_HTMLFILES)
 	@$(NORMAL_INSTALL)
@@ -140,9 +144,9 @@ fortran.install-html: $(F95_HTMLFILES)
 	  fi; \
 	done
 
-F95_PDFFILES = doc/gfortran.pdf
+F95_PDFFILES = doc/fortran/pdf/latex/gfortran.pdf
 
-fortran.pdf: $(F95_PDFFILES) doc/gfc-internals.pdf
+fortran.pdf: $(F95_PDFFILES) doc/gfc-internals/pdf/latex/gfc-internals.pdf
 
 fortran.install-pdf: $(F95_PDFFILES)
 	@$(NORMAL_INSTALL)
@@ -154,7 +158,10 @@ fortran.install-pdf: $(F95_PDFFILES)
 	  $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/gcc/$$f"; \
 	done
 
-F95_MANFILES = doc/gfortran.1
+F95_MANFILES = doc/fortran/man/man/gfortran.1
+
+doc/fortran/man/man/gfortran.1: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc man SOURCEDIR=$(srcdir)/fortran/doc/gfortran BUILDDIR=$(objdir)/doc/fortran/man
 
 fortran.man: $(F95_MANFILES)
 
@@ -175,60 +182,23 @@ check_gfortran_parallelize = 10000
 # No fortran-specific selftests
 selftest-fortran:
 
-# GFORTRAN documentation.
-GFORTRAN_TEXI = \
-  $(srcdir)/fortran/gfortran.texi \
-  $(srcdir)/fortran/intrinsic.texi \
-  $(srcdir)/fortran/invoke.texi \
-  $(srcdir)/doc/include/fdl.texi \
-  $(srcdir)/doc/include/gpl_v3.texi \
-  $(srcdir)/doc/include/funding.texi \
-  $(srcdir)/doc/include/gcc-common.texi \
-  gcc-vers.texi
-
-doc/gfortran.info: $(GFORTRAN_TEXI)
-	if [ x$(BUILD_INFO) = xinfo ]; then \
-	  rm -f doc/gfortran.info-*; \
-	  $(MAKEINFO) -I $(srcdir)/doc/include -I $(srcdir)/fortran \
-	    -o $@ $<; \
-	else true; fi
-
-doc/gfortran.dvi: $(GFORTRAN_TEXI)
-	$(TEXI2DVI) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $<
-
-doc/gfortran.pdf: $(GFORTRAN_TEXI)
-	$(TEXI2PDF) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $<
-
-$(build_htmldir)/gfortran/index.html: $(GFORTRAN_TEXI)
-	$(mkinstalldirs) $(@D)
-	rm -f $(@D)/*
-	$(TEXI2HTML) -I $(gcc_docdir)/include -I $(srcdir)/fortran -o $(@D) $<
+doc/fortran/pdf/latex/gfortran.pdf: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(srcdir)/fortran/doc/gfortran BUILDDIR=$(objdir)/doc/fortran/pdf
 
-.INTERMEDIATE: gfortran.pod
-
-gfortran.pod: $(GFORTRAN_TEXI)
-	-$(TEXI2POD) -DBUGURL="$(BUGURL_TEXI)" \
-	  < $(srcdir)/fortran/invoke.texi > $@
+doc/fortran/html/html/index.html: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(srcdir)/fortran/doc/gfortran BUILDDIR=$(objdir)/doc/fortran/html
 
 # GFORTRAN internals documentation.
-GFC_INTERNALS_TEXI = \
-  $(srcdir)/fortran/gfc-internals.texi \
-  $(srcdir)/doc/include/fdl.texi \
-  $(srcdir)/doc/include/gcc-common.texi \
-  gcc-vers.texi
-
-doc/gfc-internals.info: $(GFC_INTERNALS_TEXI)
-	if [ x$(BUILD_INFO) = xinfo ]; then \
-	  rm -f doc/gfc-internals.info-*; \
-	  $(MAKEINFO) -I $(srcdir)/doc/include -I $(srcdir)/fortran \
-	    -o $@ $<; \
+doc/gfc-internals/info/texinfo/gfc-internals.info: $(SPHINX_FILES)
+	+ if [ x$(SPHINX_BUILD) = xsphinx-build ]; then \
+	  make -C $(srcdir)/../doc info SOURCEDIR=$(srcdir)/fortran/doc/gfc-internals BUILDDIR=$(objdir)/doc/gfc-internals/info; \
 	else true; fi
 
-doc/gfc-internals.dvi: $(GFC_INTERNALS_TEXI)
-	$(TEXI2DVI) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $<
+doc/gfc-internals/pdf/latex/gfc-internals.pdf: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(srcdir)/fortran/doc/gfc-internals BUILDDIR=$(objdir)/doc/gfc-internals/pdf
 
-doc/gfc-internals.pdf: $(GFC_INTERNALS_TEXI)
-	$(TEXI2PDF) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $<
+doc/gfc-internals/html/html/index.html: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(srcdir)/fortran/doc/gfc-internals BUILDDIR=$(objdir)/doc/gfc-internals/html
 
 # Create or recreate the gfortran private include file directory.
 install-finclude-dir: installdirs
@@ -256,9 +226,13 @@ fortran.install-plugin:
 
 fortran.install-info: $(DESTDIR)$(infodir)/gfortran.info
 
+$(DESTDIR)$(infodir)/gfortran.info: doc/fortran/info/texinfo/gfortran.info installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+
 fortran.install-man: $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext)
 
-$(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext): doc/gfortran.1 \
+$(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext): doc/fortran/man/man/gfortran.1 \
 		installdirs
 	-rm -f $@
 	-$(INSTALL_DATA) $< $@
@@ -286,12 +260,6 @@ fortran.mostlyclean:
 fortran.clean:
 fortran.distclean:
 	-rm -f fortran/config.status fortran/Makefile
-
-fortran.extraclean:
-fortran.maintainer-clean:
-	-rm -f doc/gfortran.info* fortran/gfortran.*aux
-	-rm -f $(docobjdir)/gfortran.1
-
 #
 # Stage hooks:
 # The toplevel makefile has already created stage?/fortran at this point.
diff --git a/gcc/genhooks.c b/gcc/genhooks.c
index ebe0d0954e6..6ba6254381b 100644
--- a/gcc/genhooks.c
+++ b/gcc/genhooks.c
@@ -48,212 +48,74 @@ upstrdup (const char *in)
   return ret;
 }
 
-/* Struct for 'start hooks' which start a sequence of consecutive hooks
-   that are defined in target.def and to be documented in tm.texi.  */
-struct s_hook
-{
-  char *name;
-  int pos;
-};
-
-static hashval_t
-s_hook_hash (const void *p)
-{
-  const struct s_hook *s_hook = (const struct s_hook *)p;
-  return htab_hash_string (s_hook->name);
-}
+/* Emit shared .rst.in file that is used by the corresponding
+   .. include:: tm.rst.in
+     :start-after: [HOOK_NAME]
+     :end-before: [HOOK_NAME]
 
-static int
-s_hook_eq_p (const void *p1, const void *p2)
-{
-  return (strcmp (((const struct s_hook *) p1)->name, 
-		  ((const struct s_hook *) p2)->name) == 0);
-}
-
-/* Read the documentation file with name IN_FNAME, perform substitutions
-   to incorporate information from hook_array, and emit the result on stdout.
-   Hooks defined with DEFHOOK / DEFHOOKPOD are emitted at the place of a
-   matching @hook in the input file; if there is no matching @hook, the
-   hook is emitted after the hook that precedes it in target.def .
-   Usually, the emitted hook documentation starts with the hook
-   signature, followed by the string from the doc field.
-   The documentation is bracketed in @deftypefn / @deftypevr and a matching
-   @end.
-   While emitting the doc field, an @findex entry is added
-   to the affected paragraph.
    If the doc field starts with '*', the leading '*' is stripped, and the doc
    field is otherwise emitted unaltered; no function signature/
    @deftypefn/deftypevr/@end is emitted.
    In particular, a doc field of "*" means not to emit any ocumentation for
    this target.def / hook_array entry at all (there might be documentation
    for this hook in the file named IN_FNAME, though).
-   A doc field of 0 is used to append the hook signature after the previous
-   hook's signture, so that one description can be used for a group of hooks.
-   When the doc field is "", @deftypefn/@deftypevr and the hook signature
-   is emitted, but not the matching @end.  This allows all the free-form
+
+   This allows all the free-form
    documentation to be placed in IN_FNAME, to work around GPL/GFDL
    licensing incompatibility issues.  */
+
 static void
-emit_documentation (const char *in_fname)
+emit_documentation (void)
 {
-  int i, j;
-  char buf[1000];
-  htab_t start_hooks = htab_create (99, s_hook_hash, s_hook_eq_p, (htab_del) 0);
-  FILE *f;
-
-  /* Enter all the start hooks in start_hooks.  */
-  f = fopen (in_fname, "r");
-  if (!f)
-    {
-      perror ("");
-      fatal ("Couldn't open input file");
-    }
-  while (fscanf (f, "%*[^@]"), buf[0] = '\0',
-	 fscanf (f, "@%5[^ \n]", buf) != EOF)
-    {
-      void **p;
-      struct s_hook *shp;
-
-      if (strcmp (buf, "hook") != 0)
-	continue;
-      buf[0] = '\0';
-      fscanf (f, "%999s", buf);
-      shp = XNEW (struct s_hook);
-      shp->name = upstrdup (buf);
-      shp->pos = -1;
-      p = htab_find_slot (start_hooks, shp, INSERT);
-      if (*p != HTAB_EMPTY_ENTRY)
-	fatal ("Duplicate placement for hook %s\n", shp->name);
-      *(struct s_hook **) p = shp;
-    }
-  fclose (f);
   /* For each hook in hook_array, if it is a start hook, store its position.  */
-  for (i = 0; i < (int) (sizeof hook_array / sizeof hook_array[0]); i++)
+  for (int i = 0; i < (int) (sizeof hook_array / sizeof hook_array[0]); i++)
     {
-      struct s_hook sh, *shp;
-      void *p;
-
       if (!hook_array[i].doc || strcmp (hook_array[i].doc, "*") == 0)
 	continue;
-      sh.name = upstrdup (hook_array[i].name);
-      p = htab_find (start_hooks, &sh);
-      if (p)
-	{
-	  shp = (struct s_hook *) p;
-	  if (shp->pos >= 0)
-	    fatal ("Duplicate hook %s\n", sh.name);
-	  shp->pos = i;
-	}
+      const char *hook_name = upstrdup (hook_array[i].name);
+      printf ("[%s]\n", hook_name);
+      /* Print header.  Function-valued hooks have a parameter list,
+	 unlike POD-valued ones.  */
+      const char *deftype = hook_array[i].param ? "c:function" : "c:var";
+      printf (".. %s:: ", deftype);
+      if (strchr (hook_array[i].type, ' '))
+	printf ("%s", hook_array[i].type);
       else
-	fatal ("No place specified to document hook %s\n", sh.name);
-      free (sh.name);
-    }
-  /* Copy input file to stdout, substituting @hook directives with the
-     corresponding hook documentation sequences.  */
-  f = fopen (in_fname, "r");
-  if (!f)
-    {
-      perror ("");
-      fatal ("Couldn't open input file");
-    }
-  for (;;)
-    {
-      struct s_hook sh, *shp;
-      int c = getc (f);
-      char *name;
-
-      if (c == EOF)
-	break;
-      if (c != '@')
-	{
-	  putchar (c);
-	  continue;
-	}
-      buf[0] = '\0';
-      fscanf (f, "%5[^ \n]", buf);
-      if (strcmp (buf, "hook") != 0)
+	printf ("%s", hook_array[i].type);
+      printf (" %s", hook_name);
+      if (hook_array[i].param)
 	{
-	  printf ("@%s", buf);
-	  continue;
+	  const char *q, *e;
+	  /* Print the parameter list, with the parameter names
+	     enclosed in @var{}.  */
+	  printf (" ");
+	  for (q = hook_array[i].param; (e = strpbrk (q, " *,)"));
+	       q = e + 1)
+	    /* Type names like 'int' are followed by a space, sometimes
+	       also by '*'.  'void' should appear only in "(void)".  */
+	    if (*e == ' ' || *e == '*' || *q == '(')
+	      printf ("%.*s", (int) (e - q + 1), q);
+	    else
+	      printf ("%.*s%c", (int) (e - q), q, *e);
 	}
-      fscanf (f, "%999s", buf);
-      sh.name = name = upstrdup (buf);
-      shp = (struct s_hook *) htab_find (start_hooks, &sh);
-      if (!shp || shp->pos < 0)
-	fatal ("No documentation for hook %s\n", sh.name);
-      i = shp->pos;
-      do
+
+      printf ("\n");
+      if (hook_array[i].doc[0])
 	{
-	  const char *q, *e;
-	  const char *deftype;
 	  const char *doc, *p_end;
-
-	  /* A leading '*' means to output the documentation string without
-	     further processing.  */
-	  if (*hook_array[i].doc == '*')
-	    printf ("%s", hook_array[i].doc + 1);
-	  else
+	  printf ("\n");
+	  /* Print each documentation paragraph in turn.  */
+	  for (doc = hook_array[i].doc; *doc; doc = p_end)
 	    {
-	      if (i != shp->pos)
-		printf ("\n\n");
-
-	      /* Print header.  Function-valued hooks have a parameter list, 
-		 unlike POD-valued ones.  */
-	      deftype = hook_array[i].param ? "deftypefn" : "deftypevr";
-	      printf ("@%s {%s} ", deftype, hook_array[i].docname);
-	      if (strchr (hook_array[i].type, ' '))
-		printf ("{%s}", hook_array[i].type);
-	      else
-		printf ("%s", hook_array[i].type);
-	      printf (" %s", name);
-	      if (hook_array[i].param)
-		{
-		  /* Print the parameter list, with the parameter names
-		     enclosed in @var{}.  */
-		  printf (" ");
-		  for (q = hook_array[i].param; (e = strpbrk (q, " *,)"));
-		       q = e + 1)
-		    /* Type names like 'int' are followed by a space, sometimes
-		       also by '*'.  'void' should appear only in "(void)".  */
-		    if (*e == ' ' || *e == '*' || *q == '(')
-		      printf ("%.*s", (int) (e - q + 1), q);
-		    else
-		      printf ("@var{%.*s}%c", (int) (e - q), q, *e);
-		}
-	      /* POD-valued hooks sometimes come in groups with common
-		 documentation.*/
-	      for (j = i + 1;
-		   j < (int) (sizeof hook_array / sizeof hook_array[0])
-		   && hook_array[j].doc == 0 && hook_array[j].type; j++)
-		{
-		  char *namex = upstrdup (hook_array[j].name);
-
-		  printf ("\n@%sx {%s} {%s} %s",
-			  deftype, hook_array[j].docname,
-			  hook_array[j].type, namex);
-		}
-	      if (hook_array[i].doc[0])
-		{
-		  printf ("\n");
-		  /* Print each documentation paragraph in turn.  */
-		  for (doc = hook_array[i].doc; *doc; doc = p_end)
-		    {
-		      /* Find paragraph end.  */
-		      p_end = strstr (doc, "\n\n");
-		      p_end = (p_end ? p_end + 2 : doc + strlen (doc));
-		      printf ("%.*s", (int) (p_end - doc), doc);
-		    }
-		  printf ("\n@end %s", deftype);
-		}
+	      /* Find paragraph end.  */
+	      p_end = strstr (doc, "\n");
+	      p_end = (p_end ? p_end + 1 : doc + strlen (doc));
+	      printf ("  %.*s", (int) (p_end - doc), doc);
 	    }
-	  if (++i >= (int) (sizeof hook_array / sizeof hook_array[0])
-	      || !hook_array[i].doc)
-	    break;
-	  free (name);
-	  sh.name = name = upstrdup (hook_array[i].name);
+	  printf ("\n");
 	}
-      while (!htab_find (start_hooks, &sh));
-      free (name);
+
+      printf ("\n[%s]\n\n", hook_name);
     }
 }
 
@@ -314,8 +176,8 @@ main (int argc, char **argv)
 {
   progname = "genhooks";
 
-  if (argc >= 3)
-    emit_documentation (argv[2]);
+  if (argc == 1)
+    emit_documentation ();
   else
     emit_init_macros (argv[1]);
   return 0;
diff --git a/gcc/go/Make-lang.in b/gcc/go/Make-lang.in
index 4bdc8f6ea5a..e9a3aef9959 100644
--- a/gcc/go/Make-lang.in
+++ b/gcc/go/Make-lang.in
@@ -88,57 +88,46 @@ go1$(exeext): $(GO_OBJS) attribs.o $(BACKEND) $(LIBDEPS) $(go.prev)
 
 # Documentation.
 
-GO_TEXI_FILES = \
-	go/gccgo.texi \
-	$(gcc_docdir)/include/fdl.texi \
-	$(gcc_docdir)/include/gpl_v3.texi \
-	$(gcc_docdir)/include/gcc-common.texi \
-	gcc-vers.texi
-
-doc/gccgo.info: $(GO_TEXI_FILES)
-	if test "x$(BUILD_INFO)" = xinfo; then \
-	  rm -f doc/gccgo.info*; \
-	  $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
-		-I $(gcc_docdir)/include -o $@ $<; \
+doc/gccgo/info/texinfo/gccgo.info: $(SPHINX_FILES)
+	+ if [ x$(SPHINX_BUILD) = xsphinx-build ]; then \
+	  make -C $(srcdir)/../doc info SOURCEDIR=$(srcdir)/go/doc/ BUILDDIR=$(objdir)/doc/gccgo/info; \
 	else true; fi
 
-doc/gccgo.dvi: $(GO_TEXI_FILES)
-	$(TEXI2DVI) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
+doc/gccgo/pdf/latex/gccgo.pdf: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(srcdir)/go/doc/ BUILDDIR=$(objdir)/doc/gccgo/pdf
 
-doc/gccgo.pdf: $(GO_TEXI_FILES)
-	$(TEXI2PDF) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
-
-$(build_htmldir)/go/index.html: $(GO_TEXI_FILES)
-	$(mkinstalldirs) $(@D)
-	rm -f $(@D)/*
-	$(TEXI2HTML) -I $(gcc_docdir) -I $(gcc_docdir)/include \
-		-I $(srcdir)/go -o $(@D) $<
-
-.INTERMEDIATE: gccgo.pod
-
-gccgo.pod: go/gccgo.texi
-	-$(TEXI2POD) -D gccgo < $< > $@
+doc/gccgo/html/html/index.html: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(srcdir)/go/doc/ BUILDDIR=$(objdir)/doc/gccgo/html
 
 # Build hooks.
 
 go.all.cross: gccgo-cross$(exeext)
 go.start.encap: gccgo$(exeext)
 go.rest.encap:
-go.info: doc/gccgo.info
-go.dvi: doc/gccgo.dvi
-go.pdf: doc/gccgo.pdf
-go.html: $(build_htmldir)/go/index.html
-go.srcinfo: doc/gccgo.info
+
+go.info: doc/gccgo/info/texinfo/gccgo.info
+
+go.pdf: doc/gccgo/pdf/latex/gccgo.pdf
+
+go.html: doc/gccgo/html/html/index.html
+
+go.srcinfo: doc/gccgo/info/texinfo/gccgo.info
 	-cp -p $^ $(srcdir)/doc
+
 go.srcextra:
 go.tags: force
 	cd $(srcdir)/go; \
 	etags -o TAGS.sub *.c *.h gofrontend/*.h gofrontend/*.cc; \
 	etags --include TAGS.sub --include ../TAGS.sub
-go.man: doc/gccgo.1
-go.srcman: doc/gccgo.1
+
+go.man: doc/gccgo/man/man/gccgo.1
+
+go.srcman: doc/gccgo/man/man/gccgo.1
 	-cp -p $^ $(srcdir)/doc
 
+doc/gccgo/man/man/gccgo.1: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc man SOURCEDIR=$(srcdir)/go/doc BUILDDIR=$(objdir)/doc/gccgo/man
+
 lang_checks += check-go
 lang_checks_parallelized += check-go
 check_go_parallelize = 10
@@ -165,6 +154,10 @@ go.install-plugin:
 
 go.install-info: $(DESTDIR)$(infodir)/gccgo.info
 
+$(DESTDIR)$(infodir)/gccgo.info: doc/gccgo/info/texinfo/gccgo.info installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+
 go.install-pdf: doc/gccgo.pdf
 	@$(NORMAL_INSTALL)
 	test -z "$(pdfdir)" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)/gcc"
@@ -194,7 +187,7 @@ go.install-html: $(build_htmldir)/go
 
 go.install-man: $(DESTDIR)$(man1dir)/$(GCCGO_INSTALL_NAME)$(man1ext)
 
-$(DESTDIR)$(man1dir)/$(GCCGO_INSTALL_NAME)$(man1ext): doc/gccgo.1 installdirs
+$(DESTDIR)$(man1dir)/$(GCCGO_INSTALL_NAME)$(man1ext): doc/gccgo/man/man/gccgo.1 installdirs
 	-rm -f $@
 	-$(INSTALL_DATA) $< $@
 	-chmod a-x $@
@@ -214,7 +207,7 @@ go.mostlyclean:
 go.clean:
 go.distclean:
 go.maintainer-clean:
-	-rm -f $(docobjdir)/gccgo.1
+	-rm -f doc/doc/gccgo/man/man/gccgo.1
 
 # Stage hooks.
 
diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in
index 9685704c355..1d5763d67a1 100644
--- a/libgomp/Makefile.in
+++ b/libgomp/Makefile.in
@@ -274,45 +274,12 @@ AM_V_DVIPS = $(am__v_DVIPS_@AM_V@)
 am__v_DVIPS_ = $(am__v_DVIPS_@AM_DEFAULT_V@)
 am__v_DVIPS_0 = @echo "  DVIPS   " $@;
 am__v_DVIPS_1 = 
-AM_V_MAKEINFO = $(am__v_MAKEINFO_@AM_V@)
-am__v_MAKEINFO_ = $(am__v_MAKEINFO_@AM_DEFAULT_V@)
-am__v_MAKEINFO_0 = @echo "  MAKEINFO" $@;
-am__v_MAKEINFO_1 = 
-AM_V_INFOHTML = $(am__v_INFOHTML_@AM_V@)
-am__v_INFOHTML_ = $(am__v_INFOHTML_@AM_DEFAULT_V@)
-am__v_INFOHTML_0 = @echo "  INFOHTML" $@;
-am__v_INFOHTML_1 = 
-AM_V_TEXI2DVI = $(am__v_TEXI2DVI_@AM_V@)
-am__v_TEXI2DVI_ = $(am__v_TEXI2DVI_@AM_DEFAULT_V@)
-am__v_TEXI2DVI_0 = @echo "  TEXI2DVI" $@;
-am__v_TEXI2DVI_1 = 
-AM_V_TEXI2PDF = $(am__v_TEXI2PDF_@AM_V@)
-am__v_TEXI2PDF_ = $(am__v_TEXI2PDF_@AM_DEFAULT_V@)
-am__v_TEXI2PDF_0 = @echo "  TEXI2PDF" $@;
-am__v_TEXI2PDF_1 = 
-AM_V_texinfo = $(am__v_texinfo_@AM_V@)
-am__v_texinfo_ = $(am__v_texinfo_@AM_DEFAULT_V@)
-am__v_texinfo_0 = -q
-am__v_texinfo_1 = 
-AM_V_texidevnull = $(am__v_texidevnull_@AM_V@)
-am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@)
-am__v_texidevnull_0 = > /dev/null
-am__v_texidevnull_1 = 
-INFO_DEPS = libgomp.info
-am__TEXINFO_TEX_DIR = $(srcdir)/../gcc/doc/include
-DVIS = libgomp.dvi
-PDFS = libgomp.pdf
-PSS = libgomp.ps
-HTMLS = libgomp.html
-TEXINFOS = libgomp.texi
-TEXI2DVI = texi2dvi
-TEXI2PDF = $(TEXI2DVI) --pdf --batch
-MAKEINFOHTML = $(MAKEINFO) --html
-AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS)
-DVIPS = dvips
+INFO_DEPS = doc/info/texinfo/libgomp.info
+PDFS = doc/pdf/latex/libgomp.pdf
+HTMLS = doc/html/html/index.html
 RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
-	ctags-recursive dvi-recursive html-recursive info-recursive \
-	install-data-recursive install-dvi-recursive \
+	ctags-recursive html-recursive info-recursive \
+	install-data-recursive \
 	install-exec-recursive install-html-recursive \
 	install-info-recursive install-pdf-recursive \
 	install-ps-recursive install-recursive installcheck-recursive \
@@ -402,7 +369,6 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAINT = @MAINT@
-MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 NM = @NM@
 NMEDIT = @NMEDIT@
@@ -473,7 +439,6 @@ config_path = @config_path@
 datadir = @datadir@
 datarootdir = @datarootdir@
 docdir = @docdir@
-dvidir = @dvidir@
 enable_shared = @enable_shared@
 enable_static = @enable_static@
 exec_prefix = @exec_prefix@
@@ -592,16 +557,6 @@ LINK = $(LIBTOOL) --tag CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
 	$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LTLDFLAGS) -o $@
 
 
-# Automake Documentation:
-# If your package has Texinfo files in many directories, you can use the
-# variable TEXINFO_TEX to tell Automake where to find the canonical
-# `texinfo.tex' for your package. The value of this variable should be
-# the relative path from the current `Makefile.am' to `texinfo.tex'.
-TEXINFO_TEX = ../gcc/doc/include/texinfo.tex
-
-# Defines info, dvi, pdf and html targets
-MAKEINFOFLAGS = -I $(srcdir)/../gcc/doc/include
-info_TEXINFOS = libgomp.texi
 @GENINSRC_FALSE@STAMP_GENINSRC = 
 
 # AM_CONDITIONAL on configure option --generated-files-in-srcdir
@@ -622,7 +577,7 @@ all: config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
 
 .SUFFIXES:
-.SUFFIXES: .c .dvi .f90 .lo .o .obj .ps
+.SUFFIXES: .c .f90 .lo .o .obj .ps
 am--refresh: Makefile
 	@:
 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/plugin/Makefrag.am $(top_srcdir)/../multilib.am $(am__configure_deps)
@@ -833,48 +788,11 @@ clean-libtool:
 distclean-libtool:
 	-rm -f libtool config.lt
 
-libgomp.dvi: libgomp.texi  
-	$(AM_V_TEXI2DVI)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
-	MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \
-	$(TEXI2DVI) $(AM_V_texinfo) --build-dir=$(@:.dvi=.t2d) -o $@ $(AM_V_texidevnull) \
-	`test -f 'libgomp.texi' || echo '$(srcdir)/'`libgomp.texi
-
-libgomp.pdf: libgomp.texi  
-	$(AM_V_TEXI2PDF)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
-	MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \
-	$(TEXI2PDF) $(AM_V_texinfo) --build-dir=$(@:.pdf=.t2p) -o $@ $(AM_V_texidevnull) \
-	`test -f 'libgomp.texi' || echo '$(srcdir)/'`libgomp.texi
-
-libgomp.html: libgomp.texi  
-	$(AM_V_MAKEINFO)rm -rf $(@:.html=.htp)
-	$(AM_V_at)if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \
-	 -o $(@:.html=.htp) `test -f 'libgomp.texi' || echo '$(srcdir)/'`libgomp.texi; \
-	then \
-	  rm -rf $@ && mv $(@:.html=.htp) $@; \
-	else \
-	  rm -rf $(@:.html=.htp); exit 1; \
-	fi
-.dvi.ps:
-	$(AM_V_DVIPS)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
-	$(DVIPS) $(AM_V_texinfo) -o $@ $<
-
-uninstall-dvi-am:
-	@$(NORMAL_UNINSTALL)
-	@list='$(DVIS)'; test -n "$(dvidir)" || list=; \
-	for p in $$list; do \
-	  $(am__strip_dir) \
-	  echo " rm -f '$(DESTDIR)$(dvidir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(dvidir)/$$f"; \
-	done
+doc/pdf/latex/libgomp.pdf: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(srcdir)/doc BUILDDIR=`pwd`/doc/pdf
 
-uninstall-html-am:
-	@$(NORMAL_UNINSTALL)
-	@list='$(HTMLS)'; test -n "$(htmldir)" || list=; \
-	for p in $$list; do \
-	  $(am__strip_dir) \
-	  echo " rm -rf '$(DESTDIR)$(htmldir)/$$f'"; \
-	  rm -rf "$(DESTDIR)$(htmldir)/$$f"; \
-	done
+doc/html/html/index.html: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(srcdir)/doc BUILDDIR=`pwd`/doc/html
 
 uninstall-info-am:
 	@$(PRE_UNINSTALL)
@@ -938,8 +856,8 @@ mostlyclean-aminfo:
 	-rm -rf libgomp.t2d libgomp.t2p
 
 clean-aminfo:
-	-test -z "libgomp.dvi libgomp.pdf libgomp.ps libgomp.html" \
-	|| rm -rf libgomp.dvi libgomp.pdf libgomp.ps libgomp.html
+	-test -z "doc/pdf/latex/libgomp.pdf libgomp.html" \
+	|| rm -rf doc/pdf/latex/libgomp.pdf libgomp.html
 
 maintainer-clean-aminfo:
 	@list='$(INFO_DEPS)'; for i in $$list; do \
@@ -1169,9 +1087,6 @@ distclean: distclean-recursive
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-hdr distclean-libtool distclean-local distclean-tags
 
-dvi: dvi-recursive
-
-dvi-am: $(DVIS)
 
 html: html-recursive
 
@@ -1184,23 +1099,6 @@ info-am: $(INFO_DEPS)
 install-data-am: install-info-am install-nodist_fincludeHEADERS \
 	install-nodist_libsubincludeHEADERS
 
-install-dvi: install-dvi-recursive
-
-install-dvi-am: $(DVIS)
-	@$(NORMAL_INSTALL)
-	@list='$(DVIS)'; test -n "$(dvidir)" || list=; \
-	if test -n "$$list"; then \
-	  echo " $(MKDIR_P) '$(DESTDIR)$(dvidir)'"; \
-	  $(MKDIR_P) "$(DESTDIR)$(dvidir)" || exit 1; \
-	fi; \
-	for p in $$list; do \
-	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
-	  echo "$$d$$p"; \
-	done | $(am__base_list) | \
-	while read files; do \
-	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(dvidir)'"; \
-	  $(INSTALL_DATA) $$files "$(DESTDIR)$(dvidir)" || exit $$?; \
-	done
 install-exec-am: install-exec-local install-nodist_toolexeclibHEADERS \
 	install-toolexeclibLTLIBRARIES
 
@@ -1323,7 +1221,7 @@ ps: ps-recursive
 
 ps-am: $(PSS)
 
-uninstall-am: uninstall-dvi-am uninstall-html-am uninstall-info-am \
+uninstall-am: uninstall-html-am uninstall-info-am \
 	uninstall-nodist_fincludeHEADERS \
 	uninstall-nodist_libsubincludeHEADERS \
 	uninstall-nodist_toolexeclibHEADERS uninstall-pdf-am \
@@ -1337,9 +1235,9 @@ uninstall-am: uninstall-dvi-am uninstall-html-am uninstall-info-am \
 	clean-toolexeclibLTLIBRARIES cscope cscopelist-am ctags \
 	ctags-am dist-info distclean distclean-compile \
 	distclean-generic distclean-hdr distclean-libtool \
-	distclean-local distclean-tags dvi dvi-am html html-am info \
+	distclean-local distclean-tags html html-am info \
 	info-am install install-am install-data install-data-am \
-	install-dvi install-dvi-am install-exec install-exec-am \
+	install-exec install-exec-am \
 	install-exec-local install-html install-html-am install-info \
 	install-info-am install-man install-nodist_fincludeHEADERS \
 	install-nodist_libsubincludeHEADERS \
@@ -1351,7 +1249,7 @@ uninstall-am: uninstall-dvi-am uninstall-html-am uninstall-info-am \
 	maintainer-clean-local mostlyclean mostlyclean-aminfo \
 	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
 	mostlyclean-local pdf pdf-am ps ps-am tags tags-am uninstall \
-	uninstall-am uninstall-dvi-am uninstall-html-am \
+	uninstall-am uninstall-html-am \
 	uninstall-info-am uninstall-nodist_fincludeHEADERS \
 	uninstall-nodist_libsubincludeHEADERS \
 	uninstall-nodist_toolexeclibHEADERS uninstall-pdf-am \
@@ -1390,16 +1288,19 @@ env.o: libgomp_f.h
 
 all-local: $(STAMP_GENINSRC)
 
-stamp-geninsrc: libgomp.info
-	cp -p $(top_builddir)/libgomp.info $(srcdir)/libgomp.info
-	@touch $@
+RST_FILES:=$(shell find $(srcdir) -name *.rst)
+SPHINX_CONFIG_FILES:=$(srcdir)/doc/conf.py $(srcdir)/../doc/baseconf.py
+SPHINX_FILES:=$(RST_FILES) $(SPHINX_CONFIG_FILES)
 
-libgomp.info: $(STAMP_BUILD_INFO)
+export BUGURL=$(PACKAGE_BUGURL)
 
-stamp-build-info: libgomp.texi
-	$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) -o libgomp.info $(srcdir)/libgomp.texi
+stamp-geninsrc: doc/info/texinfo/libgomp.info
+	cp -p $(top_builddir)/libgomp.info $(srcdir)/libgomp.info
 	@touch $@
 
+doc/info/texinfo/libgomp.info: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(srcdir)/doc BUILDDIR=`pwd`/doc/info
+
 # target overrides
 -include $(tmake_file)
 
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index 4f1213b983b..ee4fc3cb8b2 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -56,7 +56,6 @@ CC = @CC@
 CFLAGS = @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 RANLIB = @RANLIB@
-MAKEINFO = @MAKEINFO@
 PERL = @PERL@
 
 PICFLAG = @PICFLAG@
@@ -273,12 +272,12 @@ $(TESTLIB): $(REQUIRED_OFILES) $(CONFIGURED_OFILES)
 	  $(REQUIRED_OFILES) $(CONFIGURED_OFILES)
 	$(RANLIB) $(TESTLIB)
 
-info: libiberty.info info-subdir
+info: doc/texinfo/libiberty.info info-subdir
 install-info: install-info-subdir
 clean-info: clean-info-subdir
 dvi: libiberty.dvi dvi-subdir
 
-LIBIBERTY_PDFFILES = libiberty.pdf
+LIBIBERTY_PDFFILES = doc/pdf/latex/libiberty.pdf
 
 pdf: $(LIBIBERTY_PDFFILES) pdf-subdir
 
@@ -297,7 +296,7 @@ install-pdf: $(LIBIBERTY_PDFFILES)
 	done
 
 # html, install-html targets
-HTMLS = libiberty.html
+HTMLS = doc/html/html/index.html
 
 html: $(HTMLS)
 
@@ -327,34 +326,24 @@ install-html-am: $(HTMLS)
 	  fi; \
 	done
 
-TEXISRC = \
-	$(srcdir)/libiberty.texi \
-	$(srcdir)/copying-lib.texi \
-	$(srcdir)/obstacks.texi \
-	$(srcdir)/functions.texi
+RST_FILES:=$(shell find $(srcdir) -name *.rst)
+SPHINX_CONFIG_FILES:=$(srcdir)/doc/conf.py $(srcdir)/../doc/baseconf.py
+SPHINX_FILES:=$(RST_FILES) $(SPHINX_CONFIG_FILES)
 
-# Additional files that have texi snippets that need to be collected
-# and sorted.  Some are here because the sources are imported from
-# elsewhere.  Others represent headers in ../include.
-TEXIFILES = fnmatch.txh pexecute.txh simple-object.txh
+doc/texinfo/libiberty.info: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(srcdir)/doc BUILDDIR=`pwd`/doc/info
 
-libiberty.info : $(srcdir)/libiberty.texi $(TEXISRC)
-	$(MAKEINFO) -I$(srcdir) $(srcdir)/libiberty.texi
+doc/pdf/latex/libiberty.pdf: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(srcdir)/doc BUILDDIR=`pwd`/doc/pdf
 
-libiberty.dvi : $(srcdir)/libiberty.texi $(TEXISRC)
-	texi2dvi $(srcdir)/libiberty.texi
-
-libiberty.pdf : $(srcdir)/libiberty.texi $(TEXISRC)
-	texi2pdf $(srcdir)/libiberty.texi
-
-libiberty.html : $(srcdir)/libiberty.texi $(TEXISRC)
-	$(MAKEINFO) --no-split --html -I$(srcdir) -o $@ $<
+doc/html/html/index.html: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(srcdir)/doc BUILDDIR=`pwd`/doc/html
 
 @MAINT@$(srcdir)/functions.texi : stamp-functions
 @MAINT@	@true
 
-@MAINT@stamp-functions : $(CFILES:%=$(srcdir)/%) $(TEXIFILES:%=$(srcdir)/%) $(srcdir)/gather-docs Makefile
-@MAINT@@HAVE_PERL@	$(PERL) $(srcdir)/gather-docs $(srcdir) $(srcdir)/functions.texi $(CFILES) $(TEXIFILES)
+@MAINT@stamp-functions : $(CFILES:%=$(srcdir)/%) $(srcdir)/gather-docs Makefile
+@MAINT@@HAVE_PERL@	$(PERL) $(srcdir)/gather-docs $(srcdir)
 @MAINT@	echo stamp > stamp-functions
 
 INSTALL_DEST = @INSTALL_DEST@
diff --git a/libitm/Makefile.in b/libitm/Makefile.in
index 7f53ea9b9db..7593b89f95b 100644
--- a/libitm/Makefile.in
+++ b/libitm/Makefile.in
@@ -230,46 +230,9 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
 am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
 SOURCES = $(libitm_la_SOURCES)
-AM_V_DVIPS = $(am__v_DVIPS_@AM_V@)
-am__v_DVIPS_ = $(am__v_DVIPS_@AM_DEFAULT_V@)
-am__v_DVIPS_0 = @echo "  DVIPS   " $@;
-am__v_DVIPS_1 = 
-AM_V_MAKEINFO = $(am__v_MAKEINFO_@AM_V@)
-am__v_MAKEINFO_ = $(am__v_MAKEINFO_@AM_DEFAULT_V@)
-am__v_MAKEINFO_0 = @echo "  MAKEINFO" $@;
-am__v_MAKEINFO_1 = 
-AM_V_INFOHTML = $(am__v_INFOHTML_@AM_V@)
-am__v_INFOHTML_ = $(am__v_INFOHTML_@AM_DEFAULT_V@)
-am__v_INFOHTML_0 = @echo "  INFOHTML" $@;
-am__v_INFOHTML_1 = 
-AM_V_TEXI2DVI = $(am__v_TEXI2DVI_@AM_V@)
-am__v_TEXI2DVI_ = $(am__v_TEXI2DVI_@AM_DEFAULT_V@)
-am__v_TEXI2DVI_0 = @echo "  TEXI2DVI" $@;
-am__v_TEXI2DVI_1 = 
-AM_V_TEXI2PDF = $(am__v_TEXI2PDF_@AM_V@)
-am__v_TEXI2PDF_ = $(am__v_TEXI2PDF_@AM_DEFAULT_V@)
-am__v_TEXI2PDF_0 = @echo "  TEXI2PDF" $@;
-am__v_TEXI2PDF_1 = 
-AM_V_texinfo = $(am__v_texinfo_@AM_V@)
-am__v_texinfo_ = $(am__v_texinfo_@AM_DEFAULT_V@)
-am__v_texinfo_0 = -q
-am__v_texinfo_1 = 
-AM_V_texidevnull = $(am__v_texidevnull_@AM_V@)
-am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@)
-am__v_texidevnull_0 = > /dev/null
-am__v_texidevnull_1 = 
-INFO_DEPS = libitm.info
-am__TEXINFO_TEX_DIR = $(srcdir)/../gcc/doc/include
-DVIS = libitm.dvi
-PDFS = libitm.pdf
-PSS = libitm.ps
-HTMLS = libitm.html
-TEXINFOS = libitm.texi
-TEXI2DVI = texi2dvi
-TEXI2PDF = $(TEXI2DVI) --pdf --batch
-MAKEINFOHTML = $(MAKEINFO) --html
-AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS)
-DVIPS = dvips
+INFO_DEPS = doc/info/texinfo/libitm.info
+PDFS = doc/pdf/latex/libitm.pdf
+HTMLS = doc/html/html/index.html
 RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
 	ctags-recursive dvi-recursive html-recursive info-recursive \
 	install-data-recursive install-dvi-recursive \
@@ -361,7 +324,6 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAINT = @MAINT@
-MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 NM = @NM@
 NMEDIT = @NMEDIT@
@@ -488,18 +450,6 @@ libitm_la_SOURCES = aatree.cc alloc.cc alloc_c.cc alloc_cpp.cc \
 	method-serial.cc method-gl.cc method-ml.cc $(am__append_1) \
 	$(am__append_2) $(am__append_3)
 
-# Automake Documentation:
-# If your package has Texinfo files in many directories, you can use the
-# variable TEXINFO_TEX to tell Automake where to find the canonical
-# `texinfo.tex' for your package. The value of this variable should be
-# the relative path from the current `Makefile.am' to `texinfo.tex'.
-TEXINFO_TEX = ../gcc/doc/include/texinfo.tex
-
-# Defines info, dvi, pdf and html targets
-MAKEINFOFLAGS = -I $(srcdir)/../gcc/doc/include
-info_TEXINFOS = libitm.texi
-@GENINSRC_FALSE@STAMP_GENINSRC = 
-
 # AM_CONDITIONAL on configure option --generated-files-in-srcdir
 @GENINSRC_TRUE@STAMP_GENINSRC = stamp-geninsrc
 @BUILD_INFO_FALSE@STAMP_BUILD_INFO = 
@@ -690,39 +640,11 @@ clean-libtool:
 distclean-libtool:
 	-rm -f libtool config.lt
 
-libitm.dvi: libitm.texi  
-	$(AM_V_TEXI2DVI)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
-	MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \
-	$(TEXI2DVI) $(AM_V_texinfo) --build-dir=$(@:.dvi=.t2d) -o $@ $(AM_V_texidevnull) \
-	`test -f 'libitm.texi' || echo '$(srcdir)/'`libitm.texi
-
-libitm.pdf: libitm.texi  
-	$(AM_V_TEXI2PDF)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
-	MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \
-	$(TEXI2PDF) $(AM_V_texinfo) --build-dir=$(@:.pdf=.t2p) -o $@ $(AM_V_texidevnull) \
-	`test -f 'libitm.texi' || echo '$(srcdir)/'`libitm.texi
-
-libitm.html: libitm.texi  
-	$(AM_V_MAKEINFO)rm -rf $(@:.html=.htp)
-	$(AM_V_at)if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \
-	 -o $(@:.html=.htp) `test -f 'libitm.texi' || echo '$(srcdir)/'`libitm.texi; \
-	then \
-	  rm -rf $@ && mv $(@:.html=.htp) $@; \
-	else \
-	  rm -rf $(@:.html=.htp); exit 1; \
-	fi
-.dvi.ps:
-	$(AM_V_DVIPS)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
-	$(DVIPS) $(AM_V_texinfo) -o $@ $<
+doc/pdf/latex/libitm.pdf: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(srcdir)/doc BUILDDIR=`pwd`/doc/pdf
 
-uninstall-dvi-am:
-	@$(NORMAL_UNINSTALL)
-	@list='$(DVIS)'; test -n "$(dvidir)" || list=; \
-	for p in $$list; do \
-	  $(am__strip_dir) \
-	  echo " rm -f '$(DESTDIR)$(dvidir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(dvidir)/$$f"; \
-	done
+doc/html/html/index.html: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(srcdir)/doc BUILDDIR=`pwd`/doc/html
 
 uninstall-html-am:
 	@$(NORMAL_UNINSTALL)
@@ -795,8 +717,8 @@ mostlyclean-aminfo:
 	-rm -rf libitm.t2d libitm.t2p
 
 clean-aminfo:
-	-test -z "libitm.dvi libitm.pdf libitm.ps libitm.html" \
-	|| rm -rf libitm.dvi libitm.pdf libitm.ps libitm.html
+	-test -z "doc/pdf/latex/libitm.pdf libitm.html" \
+	|| rm -rf doc/pdf/latex/libitm.pdf libitm.html
 
 maintainer-clean-aminfo:
 	@list='$(INFO_DEPS)'; for i in $$list; do \
@@ -1186,16 +1108,19 @@ vpath % $(strip $(search_path))
 
 all-local: $(STAMP_GENINSRC)
 
-stamp-geninsrc: libitm.info
-	cp -p $(top_builddir)/libitm.info $(srcdir)/libitm.info
-	@touch $@
+RST_FILES:=$(shell find $(srcdir) -name *.rst)
+SPHINX_CONFIG_FILES:=$(srcdir)/doc/conf.py $(srcdir)/../doc/baseconf.py
+SPHINX_FILES:=$(RST_FILES) $(SPHINX_CONFIG_FILES)
 
-libitm.info: $(STAMP_BUILD_INFO)
+export BUGURL=$(PACKAGE_BUGURL)
 
-stamp-build-info: libitm.texi
-	$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) -o libitm.info $(srcdir)/libitm.texi
+stamp-geninsrc: doc/info/texinfo/libitm.info
+	cp -p $(top_builddir)/libitm.info $(srcdir)/libitm.info
 	@touch $@
 
+doc/info/texinfo/libitm.info: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(srcdir)/doc BUILDDIR=`pwd`/doc/info
+
 # GNU Make needs to see an explicit $(MAKE) variable in the command it
 # runs to enable its job server during parallel builds.  Hence the
 # comments below.
diff --git a/libquadmath/Makefile.in b/libquadmath/Makefile.in
index 8c011212258..0d6e68af2f8 100644
--- a/libquadmath/Makefile.in
+++ b/libquadmath/Makefile.in
@@ -255,46 +255,9 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
 am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
 SOURCES = $(libquadmath_la_SOURCES)
-AM_V_DVIPS = $(am__v_DVIPS_@AM_V@)
-am__v_DVIPS_ = $(am__v_DVIPS_@AM_DEFAULT_V@)
-am__v_DVIPS_0 = @echo "  DVIPS   " $@;
-am__v_DVIPS_1 = 
-AM_V_MAKEINFO = $(am__v_MAKEINFO_@AM_V@)
-am__v_MAKEINFO_ = $(am__v_MAKEINFO_@AM_DEFAULT_V@)
-am__v_MAKEINFO_0 = @echo "  MAKEINFO" $@;
-am__v_MAKEINFO_1 = 
-AM_V_INFOHTML = $(am__v_INFOHTML_@AM_V@)
-am__v_INFOHTML_ = $(am__v_INFOHTML_@AM_DEFAULT_V@)
-am__v_INFOHTML_0 = @echo "  INFOHTML" $@;
-am__v_INFOHTML_1 = 
-AM_V_TEXI2DVI = $(am__v_TEXI2DVI_@AM_V@)
-am__v_TEXI2DVI_ = $(am__v_TEXI2DVI_@AM_DEFAULT_V@)
-am__v_TEXI2DVI_0 = @echo "  TEXI2DVI" $@;
-am__v_TEXI2DVI_1 = 
-AM_V_TEXI2PDF = $(am__v_TEXI2PDF_@AM_V@)
-am__v_TEXI2PDF_ = $(am__v_TEXI2PDF_@AM_DEFAULT_V@)
-am__v_TEXI2PDF_0 = @echo "  TEXI2PDF" $@;
-am__v_TEXI2PDF_1 = 
-AM_V_texinfo = $(am__v_texinfo_@AM_V@)
-am__v_texinfo_ = $(am__v_texinfo_@AM_DEFAULT_V@)
-am__v_texinfo_0 = -q
-am__v_texinfo_1 = 
-AM_V_texidevnull = $(am__v_texidevnull_@AM_V@)
-am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@)
-am__v_texidevnull_0 = > /dev/null
-am__v_texidevnull_1 = 
-INFO_DEPS = libquadmath.info
-am__TEXINFO_TEX_DIR = $(srcdir)/../gcc/doc/include
-DVIS = libquadmath.dvi
-PDFS = libquadmath.pdf
-PSS = libquadmath.ps
-HTMLS = libquadmath.html
-TEXINFOS =
-TEXI2DVI = texi2dvi
-TEXI2PDF = $(TEXI2DVI) --pdf --batch
-MAKEINFOHTML = $(MAKEINFO) --html
-AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS)
-DVIPS = dvips
+INFO_DEPS = doc/info/texinfo/libquadmath.info
+PDFS = doc/pdf/latex/libquadmath.pdf
+HTMLS = doc/html/html/index.html
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
     n|no|NO) false;; \
@@ -362,7 +325,6 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAINT = @MAINT@
-MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 NM = @NM@
 NMEDIT = @NMEDIT@
@@ -518,7 +480,6 @@ AUTOMAKE_OPTIONS = foreign info-in-builddir
 @BUILD_LIBQUADMATH_TRUE@	"LIBCFLAGS=$(LIBCFLAGS)" \
 @BUILD_LIBQUADMATH_TRUE@	"LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
 @BUILD_LIBQUADMATH_TRUE@	"MAKE=$(MAKE)" \
-@BUILD_LIBQUADMATH_TRUE@	"MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
 @BUILD_LIBQUADMATH_TRUE@	"PICFLAG=$(PICFLAG)" \
 @BUILD_LIBQUADMATH_TRUE@	"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
 @BUILD_LIBQUADMATH_TRUE@	"SHELL=$(SHELL)" \
@@ -563,10 +524,6 @@ AUTOMAKE_OPTIONS = foreign info-in-builddir
 TEXINFO_TEX = ../gcc/doc/include/texinfo.tex
 
 # Defines info, dvi, pdf and html targets
-MAKEINFOFLAGS = -I $(srcdir)/../gcc/doc/include
-@BUILD_LIBQUADMATH_FALSE@info_TEXINFOS = 
-@BUILD_LIBQUADMATH_TRUE@info_TEXINFOS = libquadmath.texi
-libquadmath_TEXINFOS = libquadmath-vers.texi
 MULTISRCTOP = 
 MULTIBUILDTOP = 
 MULTIDIRS = 
@@ -991,39 +948,11 @@ clean-libtool:
 distclean-libtool:
 	-rm -f libtool config.lt
 
-libquadmath.dvi: libquadmath.texi $(libquadmath_TEXINFOS) 
-	$(AM_V_TEXI2DVI)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
-	MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \
-	$(TEXI2DVI) $(AM_V_texinfo) --build-dir=$(@:.dvi=.t2d) -o $@ $(AM_V_texidevnull) \
-	`test -f 'libquadmath.texi' || echo '$(srcdir)/'`libquadmath.texi
-
-libquadmath.pdf: libquadmath.texi $(libquadmath_TEXINFOS) 
-	$(AM_V_TEXI2PDF)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
-	MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \
-	$(TEXI2PDF) $(AM_V_texinfo) --build-dir=$(@:.pdf=.t2p) -o $@ $(AM_V_texidevnull) \
-	`test -f 'libquadmath.texi' || echo '$(srcdir)/'`libquadmath.texi
-
-libquadmath.html: libquadmath.texi $(libquadmath_TEXINFOS) 
-	$(AM_V_MAKEINFO)rm -rf $(@:.html=.htp)
-	$(AM_V_at)if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \
-	 -o $(@:.html=.htp) `test -f 'libquadmath.texi' || echo '$(srcdir)/'`libquadmath.texi; \
-	then \
-	  rm -rf $@ && mv $(@:.html=.htp) $@; \
-	else \
-	  rm -rf $(@:.html=.htp); exit 1; \
-	fi
-.dvi.ps:
-	$(AM_V_DVIPS)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
-	$(DVIPS) $(AM_V_texinfo) -o $@ $<
+doc/pdf/latex/libquadmath.pdf: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(srcdir)/doc BUILDDIR=`pwd`/doc/pdf
 
-uninstall-dvi-am:
-	@$(NORMAL_UNINSTALL)
-	@list='$(DVIS)'; test -n "$(dvidir)" || list=; \
-	for p in $$list; do \
-	  $(am__strip_dir) \
-	  echo " rm -f '$(DESTDIR)$(dvidir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(dvidir)/$$f"; \
-	done
+doc/html/html/index.html: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(srcdir)/doc BUILDDIR=`pwd`/doc/html
 
 uninstall-html-am:
 	@$(NORMAL_UNINSTALL)
@@ -1434,22 +1363,16 @@ uninstall-am: uninstall-dvi-am uninstall-html-am uninstall-info-am \
 @BUILD_LIBQUADMATH_TRUE@@LIBQUAD_USE_SYMVER_SUN_TRUE@@LIBQUAD_USE_SYMVER_TRUE@	   sed 's,\([^/ 	]*\)\.l\([ao]\),.libs/\1.\2,g'` \
 @BUILD_LIBQUADMATH_TRUE@@LIBQUAD_USE_SYMVER_SUN_TRUE@@LIBQUAD_USE_SYMVER_TRUE@	 > $@ || (rm -f $@ ; exit 1)
 
-@BUILD_LIBQUADMATH_TRUE@stamp-geninsrc: libquadmath.info
-@BUILD_LIBQUADMATH_TRUE@	cp -p $(top_builddir)/libquadmath.info $(srcdir)/libquadmath.info
-@BUILD_LIBQUADMATH_TRUE@	@touch $@
-
-@BUILD_LIBQUADMATH_TRUE@stamp-build-info: libquadmath.texi $(libquadmath_TEXINFOS)
-@BUILD_LIBQUADMATH_TRUE@	$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) -o libquadmath.info $(srcdir)/libquadmath.texi
-@BUILD_LIBQUADMATH_TRUE@	@touch $@
-
 all-local: $(ALL_LOCAL_DEPS)
 
-# Unconditionally override this target, so that automake's definition
-# does not wrongly interfere.
-libquadmath.info: $(STAMP_BUILD_INFO)
+RST_FILES:=$(shell find $(srcdir) -name *.rst)
+SPHINX_CONFIG_FILES:=$(srcdir)/doc/conf.py $(srcdir)/../doc/baseconf.py
+SPHINX_FILES:=$(RST_FILES) $(SPHINX_CONFIG_FILES)
+
+export BUGURL=$(REPORT_BUGS_TO)
 
-libquadmath-vers.texi:
-	echo "@set BUGURL $(REPORT_BUGS_TEXI)" > $@
+doc/info/texinfo/libquadmath.info: $(SPHINX_FILES)
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(srcdir)/doc BUILDDIR=`pwd`/doc/info
 
 # GNU Make needs to see an explicit $(MAKE) variable in the command it
 # runs to enable its job server during parallel builds.  Hence the


More information about the Gcc-cvs mailing list