[gcc(refs/users/marxin/heads/sphinx-v7)] sphinx: add --with-sphinx-build

Martin Liska marxin@gcc.gnu.org
Thu Aug 18 13:57:31 GMT 2022


https://gcc.gnu.org/g:a6966fa463dcc583ba2ad5358a65720604f835b6

commit a6966fa463dcc583ba2ad5358a65720604f835b6
Author: Martin Liska <mliska@suse.cz>
Date:   Wed Jul 27 15:40:48 2022 +0200

    sphinx: add --with-sphinx-build
    
    gcc/ChangeLog:
    
            * Makefile.in: Support --with-sphinx-build.
            * configure.ac:
            * configure: Regenerate.
    
    gcc/ada/ChangeLog:
    
            * gcc-interface/Make-lang.in: Support --with-sphinx-build.
    
    gcc/d/ChangeLog:
    
            * Make-lang.in: Support --with-sphinx-build.
    
    gcc/fortran/ChangeLog:
    
            * Make-lang.in: Support --with-sphinx-build.
    
    gcc/go/ChangeLog:
    
            * Make-lang.in: Support --with-sphinx-build.
    
    gcc/jit/ChangeLog:
    
            * Make-lang.in: Support --with-sphinx-build.
    
    libgomp/ChangeLog:
    
            * Makefile.in: Support --with-sphinx-build.
            * configure.ac: Likewise..
            * configure: Regenerate.
    
    libiberty/ChangeLog:
    
            * Makefile.in: Support --with-sphinx-build.
            * configure.ac: Likewise.
            * configure: Regenerate.
    
    libitm/ChangeLog:
    
            * Makefile.in: Support --with-sphinx-build.
            * configure.ac: Likewise.
            * configure: Regenerate.
    
    libquadmath/ChangeLog:
    
            * Makefile.in: Support --with-sphinx-build.
            * configure.ac: Likewise.
            * configure: Regenerate.

Diff:
---
 gcc/Makefile.in                    | 39 +++++++++++++------------
 gcc/ada/gcc-interface/Make-lang.in | 24 +++++++--------
 gcc/configure                      | 38 +++++++++++++++++++++---
 gcc/configure.ac                   | 27 +++++++++++++++--
 gcc/d/Make-lang.in                 | 10 +++----
 gcc/fortran/Make-lang.in           | 18 ++++++------
 gcc/go/Make-lang.in                | 10 +++----
 gcc/jit/Make-lang.in               | 14 ++++-----
 libgomp/Makefile.in                |  7 +++--
 libgomp/configure                  | 56 +++++++++++++++++++++++++++++++++--
 libgomp/configure.ac               | 38 ++++++++++++++++++++++++
 libiberty/Makefile.in              | 10 +++++--
 libiberty/configure                | 55 ++++++++++++++++++++++++++++++++++
 libiberty/configure.ac             | 38 ++++++++++++++++++++++++
 libitm/Makefile.in                 |  7 +++--
 libitm/configure                   | 56 +++++++++++++++++++++++++++++++++--
 libitm/configure.ac                | 38 ++++++++++++++++++++++++
 libquadmath/Makefile.in            |  7 +++--
 libquadmath/configure              | 60 +++++++++++++++++++++++++++++++++++---
 libquadmath/configure.ac           | 38 ++++++++++++++++++++++++
 20 files changed, 507 insertions(+), 83 deletions(-)

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 39d14684969..c30b637d99f 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -765,6 +765,7 @@ INSTALL_HEADERS=install-headers install-mkheaders
 
 # Control whether manpages generated by sphinx-build can be rebuilt.
 SPHINX_BUILD = @SPHINX_BUILD@
+HAS_SPHINX_BUILD = @HAS_SPHINX_BUILD@
 
 # Additional directories of header files to run fixincludes on.
 # These should be directories searched automatically by default
@@ -3276,7 +3277,7 @@ install-no-fixedincludes:
 
 # Remake the info files.
 
-doc: $(SPHINX_BUILD)
+doc: $(HAS_SPHINX_BUILD)
 
 INFOFILES = doc/gcc/info/texinfo/gcc.info \
 	    doc/gccint/info/texinfo/gccint.info \
@@ -3295,19 +3296,19 @@ PDFFILES = doc/gcc/pdf/latex/gcc.pdf doc/gccint/pdf/latex/gccint.pdf doc/install
 pdf:: $(PDFFILES) lang.pdf
 
 doc/gcc/pdf/latex/gcc.pdf: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_docdir)/gcc BUILDDIR=$(objdir)/doc/gcc/pdf
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_docdir)/gcc BUILDDIR=$(objdir)/doc/gcc/pdf SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/gccint/pdf/latex/gccint.pdf: $(SPHINX_FILES) s-tm-rst-in
-	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_docdir)/gccint BUILDDIR=$(objdir)/doc/gccint/pdf
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_docdir)/gccint BUILDDIR=$(objdir)/doc/gccint/pdf SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/install/pdf/latex/install.pdf: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_docdir)/install BUILDDIR=$(objdir)/doc/install/pdf
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_docdir)/install BUILDDIR=$(objdir)/doc/install/pdf SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/cpp/pdf/latex/cpp.pdf: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_docdir)/cpp BUILDDIR=$(objdir)/doc/cpp/pdf
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_docdir)/cpp BUILDDIR=$(objdir)/doc/cpp/pdf SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/cppinternals/pdf/latex/cppinternals.pdf: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_docdir)/cppinternals BUILDDIR=$(objdir)/doc/cppinternals/pdf
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_docdir)/cppinternals BUILDDIR=$(objdir)/doc/cppinternals/pdf SPHINXBUILD=$(SPHINX_BUILD)
 
 # List the directories or single hmtl files which are installed by
 # install-html. The lang.html file triggers language fragments to build
@@ -3323,19 +3324,19 @@ HTMLS = doc/gcc/html/html/index.html doc/gccint/html/html/index.html doc/install
 html:: $(HTMLS) lang.html
 
 doc/gcc/html/html/index.html: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_docdir)/gcc BUILDDIR=$(objdir)/doc/gcc/html
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_docdir)/gcc BUILDDIR=$(objdir)/doc/gcc/html SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/gccint/html/html/index.html: $(SPHINX_FILES) s-tm-rst-in
-	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_docdir)/gccint BUILDDIR=$(objdir)/doc/gccint/html
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_docdir)/gccint BUILDDIR=$(objdir)/doc/gccint/html SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/install/html/html/index.html: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_docdir)/install BUILDDIR=$(objdir)/doc/install/html
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_docdir)/install BUILDDIR=$(objdir)/doc/install/html SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/cpp/html/html/index.html: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_docdir)/cpp BUILDDIR=$(objdir)/doc/cpp/html
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_docdir)/cpp BUILDDIR=$(objdir)/doc/cpp/html SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/cppinternals/html/html/index.html: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_docdir)/cppinternals BUILDDIR=$(objdir)/doc/cppinternals/html
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_docdir)/cppinternals BUILDDIR=$(objdir)/doc/cppinternals/html SPHINXBUILD=$(SPHINX_BUILD)
 
 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 \
@@ -3352,14 +3353,14 @@ man: $(MANFILES) lang.man @GENINSRC@ srcman lang.srcman
 srcman: $(MANFILES)
 	-cp -p $^ $(srcdir)/doc
 
-sphinx-build: man info
+has-sphinx-build: man info
 
 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)
 
 doc/gcc/man/man/gcc.1: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc man SOURCEDIR=$(abs_docdir)/gcc BUILDDIR=$(objdir)/doc/gcc/man
+	+ make -C $(srcdir)/../doc man SOURCEDIR=$(abs_docdir)/gcc BUILDDIR=$(objdir)/doc/gcc/man SPHINXBUILD=$(SPHINX_BUILD)
 
 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
@@ -3370,22 +3371,22 @@ 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
 
 doc/cpp/man/man/cpp.1: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc man SOURCEDIR=$(abs_docdir)/cpp BUILDDIR=$(objdir)/doc/cpp/man
+	+ make -C $(srcdir)/../doc man SOURCEDIR=$(abs_docdir)/cpp BUILDDIR=$(objdir)/doc/cpp/man SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/gcc/info/texinfo/gcc.info: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_docdir)/gcc BUILDDIR=$(objdir)/doc/gcc/info
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_docdir)/gcc BUILDDIR=$(objdir)/doc/gcc/info SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/gccint/info/texinfo/gccint.info: $(SPHINX_FILES) s-tm-rst-in
-	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_docdir)/gccint BUILDDIR=$(objdir)/doc/gccint/info
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_docdir)/gccint BUILDDIR=$(objdir)/doc/gccint/info SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/cpp/info/texinfo/cpp.info: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_docdir)/cpp BUILDDIR=$(objdir)/doc/cpp/info
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_docdir)/cpp BUILDDIR=$(objdir)/doc/cpp/info SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/cppinternals/info/texinfo/cppinternals.info: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_docdir)/cppinternals BUILDDIR=$(objdir)/doc/cppinternals/info
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_docdir)/cppinternals BUILDDIR=$(objdir)/doc/cppinternals/info SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/install/info/texinfo/install.info: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_docdir)/install BUILDDIR=$(objdir)/doc/install/info
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_docdir)/install BUILDDIR=$(objdir)/doc/install/info SPHINXBUILD=$(SPHINX_BUILD)
 
 #
 # Deletion of files made during compilation.
diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in
index f91b8c63a60..50a0babc525 100644
--- a/gcc/ada/gcc-interface/Make-lang.in
+++ b/gcc/ada/gcc-interface/Make-lang.in
@@ -809,18 +809,18 @@ ada.tags: force
 # Generate documentation.
 
 doc/gnat_ugn/info/texinfo/gnat_ugn.info: $(SPHINX_FILES)
-	+ if [ x$(SPHINX_BUILD) = xsphinx-build ]; then \
-	  make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/ada/doc/gnat_ugn BUILDDIR=$(objdir)/doc/gnat_ugn/info; \
+	+ if [ x$(HAS_SPHINX_BUILD) = xhas-sphinx-build ]; then \
+	  make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/ada/doc/gnat_ugn BUILDDIR=$(objdir)/doc/gnat_ugn/info SPHINXBUILD=$(SPHINX_BUILD); \
 	else true; fi
 
 doc/gnat_rm/info/texinfo/gnat_rm.info: $(SPHINX_FILES)
-	+ if [ x$(SPHINX_BUILD) = xsphinx-build ]; then \
-	  make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/ada/doc/gnat_rm BUILDDIR=$(objdir)/doc/gnat_rm/info; \
+	+ if [ x$(HAS_SPHINX_BUILD) = xhas-sphinx-build ]; then \
+	  make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/ada/doc/gnat_rm BUILDDIR=$(objdir)/doc/gnat_rm/info SPHINXBUILD=$(SPHINX_BUILD); \
 	else true; fi
 
 doc/gnat-style/info/texinfo/gnat-style.info: $(SPHINX_FILES)
-	+ if [ x$(SPHINX_BUILD) = xsphinx-build ]; then \
-	  make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/ada/doc/gnat-style BUILDDIR=$(objdir)/doc/gnat-style/info; \
+	+ if [ x$(HAS_SPHINX_BUILD) = xhas-sphinx-build ]; then \
+	  make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/ada/doc/gnat-style BUILDDIR=$(objdir)/doc/gnat-style/info SPHINXBUILD=$(SPHINX_BUILD); \
 	else true; fi
 
 ADA_INFOFILES = doc/gnat_ugn/info/texinfo/gnat_ugn.info \
@@ -855,13 +855,13 @@ ADA_PDFFILES = doc/gnat_ugn/pdf/latex/gnat_ugn.pdf\
 ada.pdf: $(ADA_PDFFILES)
 
 doc/gnat_ugn/pdf/latex/gnat_ugn.pdf: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/ada/doc/gnat_ugn BUILDDIR=$(objdir)/doc/gnat_ugn/pdf
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/ada/doc/gnat_ugn BUILDDIR=$(objdir)/doc/gnat_ugn/pdf SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/gnat_rm/pdf/latex/gnat_rm.pdf: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/ada/doc/gnat_rm BUILDDIR=$(objdir)/doc/gnat_rm/pdf
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/ada/doc/gnat_rm BUILDDIR=$(objdir)/doc/gnat_rm/pdf SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/gnat-style/pdf/latex/gnat-style.pdf: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/ada/doc/gnat-style BUILDDIR=$(objdir)/doc/gnat-style/pdf
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/ada/doc/gnat-style BUILDDIR=$(objdir)/doc/gnat-style/pdf SPHINXBUILD=$(SPHINX_BUILD)
 
 ada.install-pdf: $(ADA_PDFFILES)
 	@$(NORMAL_INSTALL)
@@ -876,13 +876,13 @@ ada.install-pdf: $(ADA_PDFFILES)
 ada.html: doc/gnat_ugn/html/html/index.html doc/gnat_rm/html/html/index.html doc/gnat-style/html/html/index.html
 
 doc/gnat_ugn/html/html/index.html: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/ada/doc/gnat_ugn BUILDDIR=$(objdir)/doc/gnat_ugn/html
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/ada/doc/gnat_ugn BUILDDIR=$(objdir)/doc/gnat_ugn/html SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/gnat_rm/html/html/index.html: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/ada/doc/gnat_rm BUILDDIR=$(objdir)/doc/gnat_rm/html
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/ada/doc/gnat_rm BUILDDIR=$(objdir)/doc/gnat_rm/html SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/gnat-style/html/html/index.html: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/ada/doc/gnat-style BUILDDIR=$(objdir)/doc/gnat-style/html
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/ada/doc/gnat-style BUILDDIR=$(objdir)/doc/gnat-style/html SPHINXBUILD=$(SPHINX_BUILD)
 
 ada.install-html:
 
diff --git a/gcc/configure b/gcc/configure
index 02a6bed5ec5..0096a6fb1b7 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -807,7 +807,9 @@ AR
 NM
 BISON
 FLEX
+HAS_SPHINX_BUILD
 SPHINX_BUILD
+CONFIGURE_SPHINX_BUILD
 GENERATED_MANPAGES
 BUILD_INFO
 MAKEINFO
@@ -982,6 +984,7 @@ with_changes_root_url
 enable_languages
 with_multilib_list
 with_multilib_generator
+with_sphinx_build
 with_zstd
 with_zstd_include
 with_zstd_lib
@@ -1836,6 +1839,7 @@ Optional Packages:
                           SH and x86-64 only)
   --with-multilib-generator
                           Multi-libs configuration string (RISC-V only)
+  --with-sphinx-build=    Use sphinx-build from a given path
   --with-zstd=PATH        specify prefix directory for installed zstd library.
                           Equivalent to --with-zstd-include=PATH/include plus
                           --with-zstd-lib=PATH/lib
@@ -8807,12 +8811,34 @@ $as_echo "no" >&6; }
 fi
 
 
+
+# Check whether --with-sphinx-build was given.
+if test "${with_sphinx_build+set}" = set; then :
+  withval=$with_sphinx_build; CONFIGURE_SPHINX_BUILD=$withval
+else
+  CONFIGURE_SPHINX_BUILD=
+
+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
+sphinx=sphinx-build
+if test x${CONFIGURE_SPHINX_BUILD} != x ; then
+  sphinx=${CONFIGURE_SPHINX_BUILD}
+fi
+
+tempdir=build.$$
+source=source.$$
+mkdir $source
+grep 'needs_sphinx =' ${srcdir}/../doc/baseconf.py > $source/conf.py
+touch $source/index.rst
+if ${sphinx} $source $tempdir >/dev/null 2>&1; then
+  SPHINX_BUILD=${sphinx}
+  HAS_SPHINX_BUILD=has-sphinx-build
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 else
@@ -8825,7 +8851,11 @@ $as_echo "$as_me: WARNING:
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
   SPHINX_BUILD=
+  HAS_SPHINX_BUILD=
 fi
+rm -rf $tempdir
+rm -rf $source
+
 
 
 MISSING="${CONFIG_SHELL-/bin/sh} $ac_aux_dir/missing"
@@ -19696,7 +19726,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19699 "configure"
+#line 19729 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19802,7 +19832,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19805 "configure"
+#line 19835 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index a9a30865a06..d859c37d771 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1259,11 +1259,30 @@ else
 fi
 AC_SUBST(GENERATED_MANPAGES)
 
+AC_ARG_WITH(sphinx-build,
+  [AS_HELP_STRING([--with-sphinx-build=],
+                  [Use sphinx-build from a given path])],
+  [CONFIGURE_SPHINX_BUILD=$withval],
+  [CONFIGURE_SPHINX_BUILD=]
+)
+AC_SUBST(CONFIGURE_SPHINX_BUILD)
+
 # 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
+sphinx=sphinx-build
+if test x${CONFIGURE_SPHINX_BUILD} != x ; then
+  sphinx=${CONFIGURE_SPHINX_BUILD}
+fi
+
+tempdir=build.$$
+source=source.$$
+mkdir $source
+grep 'needs_sphinx =' ${srcdir}/../doc/baseconf.py > $source/conf.py
+touch $source/index.rst
+if ${sphinx} $source $tempdir >/dev/null 2>&1; then
+  SPHINX_BUILD=${sphinx}
+  HAS_SPHINX_BUILD=has-sphinx-build
   AC_MSG_RESULT(yes)
 else
   AC_MSG_WARN([
@@ -1271,8 +1290,12 @@ else
   *** Info and man pages documentation will not be built.])
   AC_MSG_RESULT(no)
   SPHINX_BUILD=
+  HAS_SPHINX_BUILD=
 fi
+rm -rf $tempdir
+rm -rf $source
 AC_SUBST(SPHINX_BUILD)
+AC_SUBST(HAS_SPHINX_BUILD)
 
 MISSING="${CONFIG_SHELL-/bin/sh} $ac_aux_dir/missing"
 
diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in
index 87178e37145..47bee4c74f4 100644
--- a/gcc/d/Make-lang.in
+++ b/gcc/d/Make-lang.in
@@ -237,15 +237,15 @@ d21$(exeext): $(D_ALL_OBJS) attribs.o $(BACKEND) $(LIBDEPS) $(d.prev)
 
 # Documentation.
 doc/gdc/info/texinfo/gdc.info: $(SPHINX_FILES)
-	+ if [ x$(SPHINX_BUILD) = xsphinx-build ]; then \
-	  make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/d/doc BUILDDIR=$(objdir)/doc/gdc/info; \
+	+ if [ x$(HAS_SPHINX_BUILD) = xhas-sphinx-build ]; then \
+	  make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/d/doc BUILDDIR=$(objdir)/doc/gdc/info SPHINXBUILD=$(SPHINX_BUILD); \
 	else true; fi
 
 doc/gdc.pdf: $(D_TEXI_FILES)
 	$(TEXI2PDF) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
 
 doc/gdc/html/html/index.html: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/d/doc BUILDDIR=$(objdir)/doc/gdc/html
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/d/doc BUILDDIR=$(objdir)/doc/gdc/html SPHINXBUILD=$(SPHINX_BUILD)
 # Build hooks.
 
 d.all.cross: gdc-cross$(exeext)
@@ -271,7 +271,7 @@ 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=$(abs_srcdir)/d/doc BUILDDIR=$(objdir)/doc/gdc/man
+	+ make -C $(srcdir)/../doc man SOURCEDIR=$(abs_srcdir)/d/doc BUILDDIR=$(objdir)/doc/gdc/man SPHINXBUILD=$(SPHINX_BUILD)
 
 # '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
@@ -304,7 +304,7 @@ d.install-plugin:
 d.install-info: $(DESTDIR)$(infodir)/gdc.info
 
 doc/gdc/pdf/latex/gdc.pdf: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/d/doc BUILDDIR=$(objdir)/doc/gdc/pdf
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/d/doc BUILDDIR=$(objdir)/doc/gdc/pdf SPHINXBUILD=$(SPHINX_BUILD)
 
 $(DESTDIR)$(infodir)/gdc.info: doc/gdc/info/texinfo/gdc.info installdirs
 	-rm -f $@
diff --git a/gcc/fortran/Make-lang.in b/gcc/fortran/Make-lang.in
index df8099608bd..7eb2009dc6e 100644
--- a/gcc/fortran/Make-lang.in
+++ b/gcc/fortran/Make-lang.in
@@ -119,8 +119,8 @@ fortran.tags: force
 fortran.info: doc/fortran/info/texinfo/gfortran.info doc/gfc-internals/info/texinfo/gfc-internals.info
 
 doc/fortran/info/texinfo/gfortran.info: $(SPHINX_FILES)
-	+ if [ x$(SPHINX_BUILD) = xsphinx-build ]; then \
-	  make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/fortran/doc/gfortran BUILDDIR=$(objdir)/doc/fortran/info; \
+	+ if [ x$(HAS_SPHINX_BUILD) = xhas-sphinx-build ]; then \
+	  make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/fortran/doc/gfortran BUILDDIR=$(objdir)/doc/fortran/info SPHINXBUILD=$(SPHINX_BUILD); \
 	else true; fi
 
 F95_HTMLFILES = doc/fortran/html/html/index.html
@@ -161,7 +161,7 @@ fortran.install-pdf: $(F95_PDFFILES)
 F95_MANFILES = doc/fortran/man/man/gfortran.1
 
 doc/fortran/man/man/gfortran.1: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc man SOURCEDIR=$(abs_srcdir)/fortran/doc/gfortran BUILDDIR=$(objdir)/doc/fortran/man
+	+ make -C $(srcdir)/../doc man SOURCEDIR=$(abs_srcdir)/fortran/doc/gfortran BUILDDIR=$(objdir)/doc/fortran/man SPHINXBUILD=$(SPHINX_BUILD)
 
 fortran.man: $(F95_MANFILES)
 
@@ -183,22 +183,22 @@ check_gfortran_parallelize = 10000
 selftest-fortran:
 
 doc/fortran/pdf/latex/gfortran.pdf: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/fortran/doc/gfortran BUILDDIR=$(objdir)/doc/fortran/pdf
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/fortran/doc/gfortran BUILDDIR=$(objdir)/doc/fortran/pdf SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/fortran/html/html/index.html: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/fortran/doc/gfortran BUILDDIR=$(objdir)/doc/fortran/html
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/fortran/doc/gfortran BUILDDIR=$(objdir)/doc/fortran/html SPHINXBUILD=$(SPHINX_BUILD)
 
 # GFORTRAN internals documentation.
 doc/gfc-internals/info/texinfo/gfc-internals.info: $(SPHINX_FILES)
-	+ if [ x$(SPHINX_BUILD) = xsphinx-build ]; then \
-	  make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/fortran/doc/gfc-internals BUILDDIR=$(objdir)/doc/gfc-internals/info; \
+	+ if [ x$(HAS_SPHINX_BUILD) = xhas-sphinx-build ]; then \
+	  make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/fortran/doc/gfc-internals BUILDDIR=$(objdir)/doc/gfc-internals/info SPHINXBUILD=$(SPHINX_BUILD); \
 	else true; fi
 
 doc/gfc-internals/pdf/latex/gfc-internals.pdf: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/fortran/doc/gfc-internals BUILDDIR=$(objdir)/doc/gfc-internals/pdf
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/fortran/doc/gfc-internals BUILDDIR=$(objdir)/doc/gfc-internals/pdf SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/gfc-internals/html/html/index.html: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/fortran/doc/gfc-internals BUILDDIR=$(objdir)/doc/gfc-internals/html
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/fortran/doc/gfc-internals BUILDDIR=$(objdir)/doc/gfc-internals/html SPHINXBUILD=$(SPHINX_BUILD)
 
 # Create or recreate the gfortran private include file directory.
 install-finclude-dir: installdirs
diff --git a/gcc/go/Make-lang.in b/gcc/go/Make-lang.in
index e5de16f8580..b1b1b5fc3ca 100644
--- a/gcc/go/Make-lang.in
+++ b/gcc/go/Make-lang.in
@@ -89,15 +89,15 @@ go1$(exeext): $(GO_OBJS) attribs.o $(BACKEND) $(LIBDEPS) $(go.prev)
 # Documentation.
 
 doc/gccgo/info/texinfo/gccgo.info: $(SPHINX_FILES)
-	+ if [ x$(SPHINX_BUILD) = xsphinx-build ]; then \
-	  make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/go/doc/ BUILDDIR=$(objdir)/doc/gccgo/info; \
+	+ if [ x$(HAS_SPHINX_BUILD) = xhas-sphinx-build ]; then \
+	  make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/go/doc/ BUILDDIR=$(objdir)/doc/gccgo/info SPHINXBUILD=$(SPHINX_BUILD); \
 	else true; fi
 
 doc/gccgo/pdf/latex/gccgo.pdf: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/go/doc/ BUILDDIR=$(objdir)/doc/gccgo/pdf
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/go/doc/ BUILDDIR=$(objdir)/doc/gccgo/pdf SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/gccgo/html/html/index.html: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/go/doc/ BUILDDIR=$(objdir)/doc/gccgo/html
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/go/doc/ BUILDDIR=$(objdir)/doc/gccgo/html SPHINXBUILD=$(SPHINX_BUILD)
 
 # Build hooks.
 
@@ -126,7 +126,7 @@ 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=$(abs_srcdir)/go/doc BUILDDIR=$(objdir)/doc/gccgo/man
+	+ make -C $(srcdir)/../doc man SOURCEDIR=$(abs_srcdir)/go/doc BUILDDIR=$(objdir)/doc/gccgo/man SPHINXBUILD=$(SPHINX_BUILD)
 
 lang_checks += check-go
 lang_checks_parallelized += check-go
diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in
index a9aee905f2c..e972a25a55a 100644
--- a/gcc/jit/Make-lang.in
+++ b/gcc/jit/Make-lang.in
@@ -244,8 +244,8 @@ jit.install-pdf: jit.texinfo.install-pdf
 jit.info: doc/libgccjit/info/texinfo/libgccjit.info
 
 doc/libgccjit/info/texinfo/libgccjit.info: $(SPHINX_FILES)
-	+ if [ x$(SPHINX_BUILD) = xsphinx-build ]; then \
-	  make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/jit/doc/ BUILDDIR=$(objdir)/doc/libgccjit/info; \
+	+ if [ x$(HAS_SPHINX_BUILD) = xhas-sphinx-build ]; then \
+	  make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/jit/doc/ BUILDDIR=$(objdir)/doc/libgccjit/info SPHINXBUILD=$(SPHINX_BUILD); \
 	else true; fi
 
 jit.install-info: $(DESTDIR)$(infodir)/libgccjit.info
@@ -255,7 +255,7 @@ $(DESTDIR)$(infodir)/libgccjit.info: doc/libgccjit/info/texinfo/libgccjit.info i
 	-$(INSTALL_DATA) $< $@
 
 doc/libgccjit/html/html/index.html: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/jit/doc/ BUILDDIR=$(objdir)/doc/libgccjit/html
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/jit/doc/ BUILDDIR=$(objdir)/doc/libgccjit/html SPHINXBUILD=$(SPHINX_BUILD)
 
 jit.texinfo.install-html: doc/libgccjit/html/html/index.html
 	@$(NORMAL_INSTALL)
@@ -276,7 +276,7 @@ jit.texinfo.install-html: doc/libgccjit/html/html/index.html
 
 
 doc/libgccjit/pdf/latex/libgccjit.pdf: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/jit/doc/ BUILDDIR=$(objdir)/doc/libgccjit/pdf
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/jit/doc/ BUILDDIR=$(objdir)/doc/libgccjit/pdf SPHINXBUILD=$(SPHINX_BUILD)
 
 jit.texinfo.install-pdf: doc/libgccjit.pdf
 	@$(NORMAL_INSTALL)
@@ -295,7 +295,7 @@ SPHINX_BUILD_DIR=jit/sphinx-build
 jit.sphinx.html:
 	$(mkinstalldirs) $(SPHINX_BUILD_DIR)
 	(cd $(srcdir)/jit/docs && \
-	  make html BUILDDIR=$(PWD)/$(SPHINX_BUILD_DIR) )
+	  make html BUILDDIR=$(PWD)/$(SPHINX_BUILD_DIR) ) SPHINXBUILD=$(SPHINX_BUILD)
 
 jit_htmldir=$(htmldir)/jit
 
@@ -316,7 +316,7 @@ jit.sphinx.pdf: $(SPHINX_BUILD_DIR)/latex/libgccjit.pdf
 $(SPHINX_BUILD_DIR)/latex/libgccjit.pdf:
 	$(mkinstalldirs) $(SPHINX_BUILD_DIR)
 	(cd $(srcdir)/jit/docs && \
-	  make latexpdf BUILDDIR=$(PWD)/$(SPHINX_BUILD_DIR) )
+	  make latexpdf BUILDDIR=$(PWD)/$(SPHINX_BUILD_DIR) ) SPHINXBUILD=$(SPHINX_BUILD)
 
 jit.sphinx.install-pdf: $(SPHINX_BUILD_DIR)/latex/libgccjit.pdf
 	@$(NORMAL_INSTALL)
@@ -336,7 +336,7 @@ jit.tags:
 jit.man: doc/libgccjit/man/man/libgccjit.1
 
 doc/libgccjit/man/man/libgccjit.1: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc man SOURCEDIR=$(abs_srcdir)/jit/doc/ BUILDDIR=$(objdir)/doc/libgccjit/man
+	+ make -C $(srcdir)/../doc man SOURCEDIR=$(abs_srcdir)/jit/doc/ BUILDDIR=$(objdir)/doc/libgccjit/man SPHINXBUILD=$(SPHINX_BUILD)
 
 jit.srcman:
 
diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in
index 14849a061cc..9d1787d8458 100644
--- a/libgomp/Makefile.in
+++ b/libgomp/Makefile.in
@@ -400,6 +400,7 @@ SECTION_LDFLAGS = @SECTION_LDFLAGS@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
+SPHINX_BUILD = @SPHINX_BUILD@
 STRIP = @STRIP@
 VERSION = @VERSION@
 XCFLAGS = @XCFLAGS@
@@ -793,10 +794,10 @@ distclean-libtool:
 	-rm -f libtool config.lt
 
 doc/pdf/latex/libgomp.pdf: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/pdf
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/pdf SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/html/html/index.html: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/html
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/html SPHINXBUILD=$(SPHINX_BUILD)
 
 uninstall-info-am:
 	@$(PRE_UNINSTALL)
@@ -1303,7 +1304,7 @@ stamp-geninsrc: doc/info/texinfo/libgomp.info
 	@touch $@
 
 doc/info/texinfo/libgomp.info: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/info
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/info SPHINXBUILD=$(SPHINX_BUILD)
 
 # target overrides
 -include $(tmake_file)
diff --git a/libgomp/configure b/libgomp/configure
index b11170e6a7c..19ceb7253b0 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -635,6 +635,9 @@ am__EXEEXT_TRUE
 LTLIBOBJS
 LIBOBJS
 get_gcc_base_ver
+HAS_SPHINX_BUILD
+SPHINX_BUILD
+CONFIGURE_SPHINX_BUILD
 OMP_DEPEND_KIND
 OMP_NEST_LOCK_25_KIND
 OMP_LOCK_25_KIND
@@ -826,6 +829,7 @@ enable_linux_futex
 enable_tls
 enable_symvers
 enable_cet
+with_sphinx_build
 with_gcc_major_version_only
 '
       ac_precious_vars='build_alias
@@ -1494,6 +1498,7 @@ Optional Packages:
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-sphinx-build=    Use sphinx-build from a given path
   --with-gcc-major-version-only
                           use only GCC major number in filesystem paths
 
@@ -11394,7 +11399,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11397 "configure"
+#line 11402 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11500,7 +11505,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11503 "configure"
+#line 11508 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -16832,6 +16837,53 @@ fi
 
 CFLAGS="$save_CFLAGS"
 
+
+# Check whether --with-sphinx-build was given.
+if test "${with_sphinx_build+set}" = set; then :
+  withval=$with_sphinx_build; CONFIGURE_SPHINX_BUILD=$withval
+else
+  CONFIGURE_SPHINX_BUILD=
+
+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; }
+sphinx=sphinx-build
+if test x${CONFIGURE_SPHINX_BUILD} != x ; then
+  sphinx=${CONFIGURE_SPHINX_BUILD}
+fi
+
+tempdir=build.$$
+source=source.$$
+mkdir $source
+grep 'needs_sphinx =' ${srcdir}/../doc/baseconf.py > $source/conf.py
+touch $source/index.rst
+if ${sphinx} $source $tempdir >/dev/null 2>&1; then
+  SPHINX_BUILD=${sphinx}
+  HAS_SPHINX_BUILD=has-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=
+  HAS_SPHINX_BUILD=
+fi
+rm -rf $tempdir
+rm -rf $source
+
+
+
 # Determine what GCC version number to use in filesystem paths.
 
   get_gcc_base_ver="cat"
diff --git a/libgomp/configure.ac b/libgomp/configure.ac
index a9b1f3973f7..1aeac2d3cca 100644
--- a/libgomp/configure.ac
+++ b/libgomp/configure.ac
@@ -469,6 +469,44 @@ AC_SUBST(OMP_NEST_LOCK_25_KIND)
 AC_SUBST(OMP_DEPEND_KIND)
 CFLAGS="$save_CFLAGS"
 
+AC_ARG_WITH(sphinx-build,
+  [AS_HELP_STRING([--with-sphinx-build=],
+                  [Use sphinx-build from a given path])],
+  [CONFIGURE_SPHINX_BUILD=$withval],
+  [CONFIGURE_SPHINX_BUILD=]
+)
+AC_SUBST(CONFIGURE_SPHINX_BUILD)
+
+# See if sphinx-build has been installed and is modern enough
+# that we can use it.
+AC_MSG_CHECKING([for sphinx-build])
+sphinx=sphinx-build
+if test x${CONFIGURE_SPHINX_BUILD} != x ; then
+  sphinx=${CONFIGURE_SPHINX_BUILD}
+fi
+
+tempdir=build.$$
+source=source.$$
+mkdir $source
+grep 'needs_sphinx =' ${srcdir}/../doc/baseconf.py > $source/conf.py
+touch $source/index.rst
+if ${sphinx} $source $tempdir >/dev/null 2>&1; then
+  SPHINX_BUILD=${sphinx}
+  HAS_SPHINX_BUILD=has-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=
+  HAS_SPHINX_BUILD=
+fi
+rm -rf $tempdir
+rm -rf $source
+AC_SUBST(SPHINX_BUILD)
+AC_SUBST(HAS_SPHINX_BUILD)
+
 # Determine what GCC version number to use in filesystem paths.
 GCC_BASE_VER
 
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index dfd5f757ab5..d2156bab23f 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -73,6 +73,10 @@ TESTLIB = ./testlib.a
 
 LIBOBJS = @LIBOBJS@
 
+# Control whether manpages generated by sphinx-build can be rebuilt.
+SPHINX_BUILD = @SPHINX_BUILD@
+HAS_SPHINX_BUILD = @HAS_SPHINX_BUILD@
+
 # A configuration can specify extra .o files that should be included,
 # even if they are in libc. (Perhaps the libc version is buggy.)
 EXTRA_OFILES = 
@@ -353,13 +357,13 @@ SPHINX_CONFIG_FILES:=$(srcdir)/doc/conf.py $(srcdir)/../doc/baseconf.py
 SPHINX_FILES:=$(RST_FILES) $(SPHINX_CONFIG_FILES)
 
 doc/texinfo/libiberty.info: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_docdir) BUILDDIR=$(abs_doc_builddir)/info
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_docdir) BUILDDIR=$(abs_doc_builddir)/info SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/pdf/latex/libiberty.pdf: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_docdir) BUILDDIR=$(abs_doc_builddir)/pdf
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_docdir) BUILDDIR=$(abs_doc_builddir)/pdf SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/html/html/index.html: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_docdir) BUILDDIR=$(abs_doc_builddir)/html
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_docdir) BUILDDIR=$(abs_doc_builddir)/html SPHINXBUILD=$(SPHINX_BUILD)
 
 @MAINT@$(srcdir)/functions.texi : stamp-functions
 @MAINT@	@true
diff --git a/libiberty/configure b/libiberty/configure
index 1d42a5e3a11..08cd01295bb 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -663,6 +663,9 @@ ETAGS
 NOTMAINT
 MAINT
 libiberty_topdir
+HAS_SPHINX_BUILD
+SPHINX_BUILD
+CONFIGURE_SPHINX_BUILD
 target_alias
 host_alias
 build_alias
@@ -708,6 +711,7 @@ with_target_subdir
 with_build_subdir
 with_cross_host
 with_newlib
+with_sphinx_build
 enable_maintainer_mode
 enable_multilib
 enable_install_libiberty
@@ -1349,6 +1353,7 @@ Optional Packages:
   --with-build-subdir=SUBDIR       Configuring in a subdirectory for build
   --with-cross-host=HOST           Configuring with a cross compiler
   --with-newlib                    Configuring with newlib
+  --with-sphinx-build=    Use sphinx-build from a given path
 
 Some influential environment variables:
   CC          C compiler command
@@ -2491,6 +2496,53 @@ if test "${with_newlib+set}" = set; then :
 fi
 
 
+
+# Check whether --with-sphinx-build was given.
+if test "${with_sphinx_build+set}" = set; then :
+  withval=$with_sphinx_build; CONFIGURE_SPHINX_BUILD=$withval
+else
+  CONFIGURE_SPHINX_BUILD=
+
+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; }
+sphinx=sphinx-build
+if test x${CONFIGURE_SPHINX_BUILD} != x ; then
+  sphinx=${CONFIGURE_SPHINX_BUILD}
+fi
+
+tempdir=build.$$
+source=source.$$
+mkdir $source
+grep 'needs_sphinx =' ${srcdir}/../doc/baseconf.py > $source/conf.py
+touch $source/index.rst
+if ${sphinx} $source $tempdir >/dev/null 2>&1; then
+  SPHINX_BUILD=${sphinx}
+  HAS_SPHINX_BUILD=has-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=
+  HAS_SPHINX_BUILD=
+fi
+rm -rf $tempdir
+rm -rf $source
+
+
+
 if test "${srcdir}" = "."; then
   if test -n "${with_build_subdir}"; then
     libiberty_topdir="${srcdir}/../.."
@@ -5209,6 +5261,9 @@ case "${host}" in
 	# sets the default TLS model and affects inlining.
 	PICFLAG=-fPIC
 	;;
+    loongarch*-*-*)
+	PICFLAG=-fpic
+	;;
     mips-sgi-irix6*)
 	# PIC is the default.
 	;;
diff --git a/libiberty/configure.ac b/libiberty/configure.ac
index 28d996f9cf7..b2cfef90489 100644
--- a/libiberty/configure.ac
+++ b/libiberty/configure.ac
@@ -20,6 +20,44 @@ AC_ARG_WITH(cross-host,
 AC_ARG_WITH(newlib,
 [  --with-newlib                    Configuring with newlib])
 
+AC_ARG_WITH(sphinx-build,
+  [AS_HELP_STRING([--with-sphinx-build=],
+                  [Use sphinx-build from a given path])],
+  [CONFIGURE_SPHINX_BUILD=$withval],
+  [CONFIGURE_SPHINX_BUILD=]
+)
+AC_SUBST(CONFIGURE_SPHINX_BUILD)
+
+# See if sphinx-build has been installed and is modern enough
+# that we can use it.
+AC_MSG_CHECKING([for sphinx-build])
+sphinx=sphinx-build
+if test x${CONFIGURE_SPHINX_BUILD} != x ; then
+  sphinx=${CONFIGURE_SPHINX_BUILD}
+fi
+
+tempdir=build.$$
+source=source.$$
+mkdir $source
+grep 'needs_sphinx =' ${srcdir}/../doc/baseconf.py > $source/conf.py
+touch $source/index.rst
+if ${sphinx} $source $tempdir >/dev/null 2>&1; then
+  SPHINX_BUILD=${sphinx}
+  HAS_SPHINX_BUILD=has-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=
+  HAS_SPHINX_BUILD=
+fi
+rm -rf $tempdir
+rm -rf $source
+AC_SUBST(SPHINX_BUILD)
+AC_SUBST(HAS_SPHINX_BUILD)
+
 if test "${srcdir}" = "."; then
   if test -n "${with_build_subdir}"; then
     libiberty_topdir="${srcdir}/../.."
diff --git a/libitm/Makefile.in b/libitm/Makefile.in
index d2f34b05fa6..38a7e5bf731 100644
--- a/libitm/Makefile.in
+++ b/libitm/Makefile.in
@@ -346,6 +346,7 @@ SECTION_LDFLAGS = @SECTION_LDFLAGS@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
+SPHINX_BUILD = @SPHINX_BUILD@
 STRIP = @STRIP@
 VERSION = @VERSION@
 XCFLAGS = @XCFLAGS@
@@ -642,10 +643,10 @@ distclean-libtool:
 	-rm -f libtool config.lt
 
 doc/pdf/latex/libitm.pdf: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/pdf
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/pdf SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/html/html/index.html: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/html
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/html SPHINXBUILD=$(SPHINX_BUILD)
 
 uninstall-html-am:
 	@$(NORMAL_UNINSTALL)
@@ -1120,7 +1121,7 @@ stamp-geninsrc: doc/info/texinfo/libitm.info
 	@touch $@
 
 doc/info/texinfo/libitm.info: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/info
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/info SPHINXBUILD=$(SPHINX_BUILD)
 
 # GNU Make needs to see an explicit $(MAKE) variable in the command it
 # runs to enable its job server during parallel builds.  Hence the
diff --git a/libitm/configure b/libitm/configure
index 18fc2d3a10a..7e768647474 100755
--- a/libitm/configure
+++ b/libitm/configure
@@ -633,6 +633,9 @@ am__EXEEXT_TRUE
 LTLIBOBJS
 LIBOBJS
 get_gcc_base_ver
+HAS_SPHINX_BUILD
+SPHINX_BUILD
+CONFIGURE_SPHINX_BUILD
 ARCH_FUTEX_FALSE
 ARCH_FUTEX_TRUE
 ARCH_X86_AVX_FALSE
@@ -816,6 +819,7 @@ enable_tls
 enable_symvers
 enable_werror
 enable_cet
+with_sphinx_build
 with_gcc_major_version_only
 '
       ac_precious_vars='build_alias
@@ -1481,6 +1485,7 @@ Optional Packages:
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-sphinx-build=    Use sphinx-build from a given path
   --with-gcc-major-version-only
                           use only GCC major number in filesystem paths
 
@@ -12058,7 +12063,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12061 "configure"
+#line 12066 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12164,7 +12169,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12167 "configure"
+#line 12172 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18006,6 +18011,53 @@ else
 fi
 
 
+
+# Check whether --with-sphinx-build was given.
+if test "${with_sphinx_build+set}" = set; then :
+  withval=$with_sphinx_build; CONFIGURE_SPHINX_BUILD=$withval
+else
+  CONFIGURE_SPHINX_BUILD=
+
+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; }
+sphinx=sphinx-build
+if test x${CONFIGURE_SPHINX_BUILD} != x ; then
+  sphinx=${CONFIGURE_SPHINX_BUILD}
+fi
+
+tempdir=build.$$
+source=source.$$
+mkdir $source
+grep 'needs_sphinx =' ${srcdir}/../doc/baseconf.py > $source/conf.py
+touch $source/index.rst
+if ${sphinx} $source $tempdir >/dev/null 2>&1; then
+  SPHINX_BUILD=${sphinx}
+  HAS_SPHINX_BUILD=has-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=
+  HAS_SPHINX_BUILD=
+fi
+rm -rf $tempdir
+rm -rf $source
+
+
+
 # Determine what GCC version number to use in filesystem paths.
 
   get_gcc_base_ver="cat"
diff --git a/libitm/configure.ac b/libitm/configure.ac
index 78a682376d9..6930f5abaae 100644
--- a/libitm/configure.ac
+++ b/libitm/configure.ac
@@ -301,6 +301,44 @@ AM_CONDITIONAL([ARCH_X86], [test "$ARCH" = x86])
 AM_CONDITIONAL([ARCH_X86_AVX], [test "$libitm_cv_as_avx" = yes])
 AM_CONDITIONAL([ARCH_FUTEX], [test $enable_linux_futex = yes])
 
+AC_ARG_WITH(sphinx-build,
+  [AS_HELP_STRING([--with-sphinx-build=],
+                  [Use sphinx-build from a given path])],
+  [CONFIGURE_SPHINX_BUILD=$withval],
+  [CONFIGURE_SPHINX_BUILD=]
+)
+AC_SUBST(CONFIGURE_SPHINX_BUILD)
+
+# See if sphinx-build has been installed and is modern enough
+# that we can use it.
+AC_MSG_CHECKING([for sphinx-build])
+sphinx=sphinx-build
+if test x${CONFIGURE_SPHINX_BUILD} != x ; then
+  sphinx=${CONFIGURE_SPHINX_BUILD}
+fi
+
+tempdir=build.$$
+source=source.$$
+mkdir $source
+grep 'needs_sphinx =' ${srcdir}/../doc/baseconf.py > $source/conf.py
+touch $source/index.rst
+if ${sphinx} $source $tempdir >/dev/null 2>&1; then
+  SPHINX_BUILD=${sphinx}
+  HAS_SPHINX_BUILD=has-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=
+  HAS_SPHINX_BUILD=
+fi
+rm -rf $tempdir
+rm -rf $source
+AC_SUBST(SPHINX_BUILD)
+AC_SUBST(HAS_SPHINX_BUILD)
+
 # Determine what GCC version number to use in filesystem paths.
 GCC_BASE_VER
 
diff --git a/libquadmath/Makefile.in b/libquadmath/Makefile.in
index 259ef2a5f4b..d551f56ce62 100644
--- a/libquadmath/Makefile.in
+++ b/libquadmath/Makefile.in
@@ -346,6 +346,7 @@ REPORT_BUGS_TO = @REPORT_BUGS_TO@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
+SPHINX_BUILD = @SPHINX_BUILD@
 STRIP = @STRIP@
 VERSION = @VERSION@
 XCFLAGS = @XCFLAGS@
@@ -950,10 +951,10 @@ distclean-libtool:
 	-rm -f libtool config.lt
 
 doc/pdf/latex/libquadmath.pdf: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/pdf
+	+ make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/pdf SPHINXBUILD=$(SPHINX_BUILD)
 
 doc/html/html/index.html: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/html
+	+ make -C $(srcdir)/../doc html SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/html SPHINXBUILD=$(SPHINX_BUILD)
 
 uninstall-html-am:
 	@$(NORMAL_UNINSTALL)
@@ -1373,7 +1374,7 @@ SPHINX_FILES:=$(RST_FILES) $(SPHINX_CONFIG_FILES)
 export BUGURL=$(REPORT_BUGS_TO)
 
 doc/info/texinfo/libquadmath.info: $(SPHINX_FILES)
-	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/info
+	+ make -C $(srcdir)/../doc info SOURCEDIR=$(abs_srcdir)/doc BUILDDIR=$(abs_doc_builddir)/info SPHINXBUILD=$(SPHINX_BUILD)
 
 # GNU Make needs to see an explicit $(MAKE) variable in the command it
 # runs to enable its job server during parallel builds.  Hence the
diff --git a/libquadmath/configure b/libquadmath/configure
index b3ee64f9c7d..14f20f69ca9 100755
--- a/libquadmath/configure
+++ b/libquadmath/configure
@@ -633,6 +633,9 @@ am__EXEEXT_TRUE
 LTLIBOBJS
 LIBOBJS
 get_gcc_base_ver
+HAS_SPHINX_BUILD
+SPHINX_BUILD
+CONFIGURE_SPHINX_BUILD
 GENINSRC_FALSE
 GENINSRC_TRUE
 XCFLAGS
@@ -790,6 +793,7 @@ with_toolexeclibdir
 enable_symvers
 enable_cet
 enable_generated_files_in_srcdir
+with_sphinx_build
 with_gcc_major_version_only
 '
       ac_precious_vars='build_alias
@@ -1455,6 +1459,7 @@ Optional Packages:
   --with-toolexeclibdir=DIR
                           install libraries built with a cross compiler within
                           DIR
+  --with-sphinx-build=    Use sphinx-build from a given path
   --with-gcc-major-version-only
                           use only GCC major number in filesystem paths
 
@@ -4693,7 +4698,7 @@ fi
     REPORT_BUGS_TEXI=
     ;;
   *)
-    REPORT_BUGS_TO="<$BUGURL>"
+    REPORT_BUGS_TO="$BUGURL"
     REPORT_BUGS_TEXI=@uref{`echo "$BUGURL" | sed 's/@/@@/g'`}
     ;;
   esac;
@@ -10806,7 +10811,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10819 "configure"
+#line 10814 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10912,7 +10917,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10925 "configure"
+#line 10920 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13031,7 +13036,7 @@ case "$host" in
     case "$enable_cet" in
       auto)
 	# Check if target supports multi-byte NOPs
-	# and if assembler supports CET insn.
+	# and if compiler and assembler support CET insn.
 	cet_save_CFLAGS="$CFLAGS"
 	CFLAGS="$CFLAGS -fcf-protection"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -13243,6 +13248,53 @@ else
 fi
 
 
+
+# Check whether --with-sphinx-build was given.
+if test "${with_sphinx_build+set}" = set; then :
+  withval=$with_sphinx_build; CONFIGURE_SPHINX_BUILD=$withval
+else
+  CONFIGURE_SPHINX_BUILD=
+
+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; }
+sphinx=sphinx-build
+if test x${CONFIGURE_SPHINX_BUILD} != x ; then
+  sphinx=${CONFIGURE_SPHINX_BUILD}
+fi
+
+tempdir=build.$$
+source=source.$$
+mkdir $source
+grep 'needs_sphinx =' ${srcdir}/../doc/baseconf.py > $source/conf.py
+touch $source/index.rst
+if ${sphinx} $source $tempdir >/dev/null 2>&1; then
+  SPHINX_BUILD=${sphinx}
+  HAS_SPHINX_BUILD=has-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=
+  HAS_SPHINX_BUILD=
+fi
+rm -rf $tempdir
+rm -rf $source
+
+
+
 # Determine what GCC version number to use in filesystem paths.
 
   get_gcc_base_ver="cat"
diff --git a/libquadmath/configure.ac b/libquadmath/configure.ac
index eec4084a45f..f2befdcb16e 100644
--- a/libquadmath/configure.ac
+++ b/libquadmath/configure.ac
@@ -394,6 +394,44 @@ AS_HELP_STRING([--enable-generated-files-in-srcdir],
 AC_MSG_RESULT($enable_generated_files_in_srcdir)
 AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
 
+AC_ARG_WITH(sphinx-build,
+  [AS_HELP_STRING([--with-sphinx-build=],
+                  [Use sphinx-build from a given path])],
+  [CONFIGURE_SPHINX_BUILD=$withval],
+  [CONFIGURE_SPHINX_BUILD=]
+)
+AC_SUBST(CONFIGURE_SPHINX_BUILD)
+
+# See if sphinx-build has been installed and is modern enough
+# that we can use it.
+AC_MSG_CHECKING([for sphinx-build])
+sphinx=sphinx-build
+if test x${CONFIGURE_SPHINX_BUILD} != x ; then
+  sphinx=${CONFIGURE_SPHINX_BUILD}
+fi
+
+tempdir=build.$$
+source=source.$$
+mkdir $source
+grep 'needs_sphinx =' ${srcdir}/../doc/baseconf.py > $source/conf.py
+touch $source/index.rst
+if ${sphinx} $source $tempdir >/dev/null 2>&1; then
+  SPHINX_BUILD=${sphinx}
+  HAS_SPHINX_BUILD=has-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=
+  HAS_SPHINX_BUILD=
+fi
+rm -rf $tempdir
+rm -rf $source
+AC_SUBST(SPHINX_BUILD)
+AC_SUBST(HAS_SPHINX_BUILD)
+
 # Determine what GCC version number to use in filesystem paths.
 GCC_BASE_VER


More information about the Gcc-cvs mailing list