]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/Makefile.in
configure: Implement --enable-host-pie
[thirdparty/gcc.git] / gcc / Makefile.in
index 246a85a167741ce81d1697507aba7df4d6e23d14..5a78c7476d2813027ac3eedb098280ac304d3219 100644 (file)
@@ -113,12 +113,13 @@ 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 .rst files here because they
+# 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 %.rst $(gcc_docdir)
+vpath %.texi $(gcc_docdir)
+vpath %.texi $(gcc_docdir)/include
 
 # --------
 # UNSORTED
@@ -157,6 +158,9 @@ LDFLAGS = @LDFLAGS@
 # Should we build position-independent host code?
 PICFLAG = @PICFLAG@
 
+# The linker flag for the above.
+LD_PICFLAG = @LD_PICFLAG@
+
 # Flags to determine code coverage. When coverage is disabled, this will
 # contain the optimization flags, as you normally want code coverage
 # without optimization.
@@ -265,18 +269,17 @@ LINKER = $(CC)
 LINKER_FLAGS = $(CFLAGS)
 endif
 
+enable_host_pie = @enable_host_pie@
+
 # Enable Intel CET on Intel CET enabled host if needed.
 CET_HOST_FLAGS = @CET_HOST_FLAGS@
 COMPILER += $(CET_HOST_FLAGS)
 
-NO_PIE_CFLAGS = @NO_PIE_CFLAGS@
-NO_PIE_FLAG = @NO_PIE_FLAG@
-
-# We don't want to compile the compilers with -fPIE, it make PCH fail.
-COMPILER += $(NO_PIE_CFLAGS)
+# Maybe compile the compilers with -fPIE or -fPIC.
+COMPILER += $(PICFLAG)
 
-# Link with -no-pie since we compile the compiler with -fno-PIE.
-LINKER += $(NO_PIE_FLAG)
+# Link with -pie, or -no-pie, depending on the above.
+LINKER += $(LD_PICFLAG)
 
 # Like LINKER, but use a mutex for serializing front end links.
 ifeq (@DO_LINK_MUTEX@,true)
@@ -320,6 +323,13 @@ 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.
@@ -770,9 +780,11 @@ LIBCONVERT =
 # Control whether header files are installed.
 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@
+# 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@
 
 # Additional directories of header files to run fixincludes on.
 # These should be directories searched automatically by default
@@ -896,6 +908,7 @@ PKGVERSION_s:= "\"@PKGVERSION@\""
 BUGURL_s    := "\"@REPORT_BUGS_TO@\""
 
 PKGVERSION  := @PKGVERSION@
+BUGURL_TEXI := @REPORT_BUGS_TEXI@
 
 ifdef REVISION_c
 REVISION_s  := \
@@ -1049,18 +1062,21 @@ ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS)
 ALL_COMPILERFLAGS = $(ALL_CXXFLAGS)
 
 # This is the variable to use when using $(LINKER).
-ALL_LINKERFLAGS = $(ALL_CXXFLAGS)
+ALL_LINKERFLAGS = $(ALL_CXXFLAGS) $(LD_PICFLAG)
 
 # Build and host support libraries.
 
-# Use the "pic" build of libiberty if --enable-host-shared, unless we are
-# building for mingw.
+# Use the "pic" build of libiberty if --enable-host-shared or --enable-host-pie,
+# unless we are building for mingw.
 LIBIBERTY_PICDIR=$(if $(findstring mingw,$(target)),,pic)
-ifeq ($(enable_host_shared),yes)
+ifneq ($(enable_host_shared)$(enable_host_pie),)
 LIBIBERTY = ../libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
-BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
 else
 LIBIBERTY = ../libiberty/libiberty.a
+endif
+ifeq ($(enable_host_shared),yes)
+BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
+else
 BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/libiberty.a
 endif
 
@@ -1181,6 +1197,8 @@ FLAGS_TO_PASS = \
        "LN=$(LN)" \
        "LN_S=$(LN_S)" \
        "RANLIB_FOR_TARGET=$(RANLIB_FOR_TARGET)" \
+       "MAKEINFO=$(MAKEINFO)" \
+       "MAKEINFOFLAGS=$(MAKEINFOFLAGS)" \
        "MAKEOVERRIDES=" \
        "SHELL=$(SHELL)" \
        "TFLAGS=$(TFLAGS)" \
@@ -1236,6 +1254,7 @@ C_COMMON_OBJS = c-family/c-common.o c-family/c-cppbuiltin.o c-family/c-dump.o \
 ANALYZER_OBJS = \
        analyzer/analysis-plan.o \
        analyzer/analyzer.o \
+       analyzer/analyzer-language.o \
        analyzer/analyzer-logging.o \
        analyzer/analyzer-pass.o \
        analyzer/analyzer-selftests.o \
@@ -1243,6 +1262,7 @@ ANALYZER_OBJS = \
        analyzer/call-info.o \
        analyzer/call-string.o \
        analyzer/call-summary.o \
+       analyzer/checker-event.o \
        analyzer/checker-path.o \
        analyzer/complexity.o \
        analyzer/constraint-manager.o \
@@ -2036,7 +2056,7 @@ cstamp-h: config.in config.status
 # config.status does not exist before failing.
 config.status: $(srcdir)/configure $(srcdir)/config.gcc $(LANG_CONFIGUREFRAGS)
        @if [ ! -f config.status ] ; then \
-         echo You must configure gcc.  Look at http://gcc.gnu.org/onlinedocs/install/ for details.; \
+         echo You must configure gcc.  Look at http://gcc.gnu.org/install/ for details.; \
          false; \
        else \
          LANGUAGES="$(CONFIG_LANGUAGES)" $(SHELL) config.status --recheck; \
@@ -2562,6 +2582,8 @@ 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" \
@@ -2597,20 +2619,38 @@ s-d-target-hooks-def-h: build/genhooks$(build_exeext)
                                             d/d-target-hooks-def.h
        $(STAMP) s-d-target-hooks-def-h
 
-# The tm.rst.in we want to compare against / check into svn should have
+# 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
 # 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-rst-in: build/genhooks$(build_exeext) $(srcdir)/doc/gccint/target-macros/tm.rst.in
-       $(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 \
+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 \
          $(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.rst.in, then copy it to $(srcdir)/doc/gccint/target-macros/tm.rst.in. >&2 ; \
+         echo new text in $(objdir)/tm.texi, then copy it to $(srcdir)/doc/tm.texi. >&2 ; \
          false; \
        fi
 
@@ -2709,6 +2749,7 @@ GTFILES = $(CPPLIB_H) $(srcdir)/input.h $(srcdir)/coretypes.h \
   $(srcdir)/internal-fn.h \
   $(srcdir)/calls.cc \
   $(srcdir)/omp-general.h \
+  $(srcdir)/analyzer/analyzer-language.cc \
   @all_gtfiles@
 
 # Compute the list of GT header files from the corresponding C sources,
@@ -3283,38 +3324,121 @@ install-no-fixedincludes:
 
 # Remake the info files.
 
-doc: $(HAS_SPHINX_BUILD)
+doc: $(BUILD_INFO) $(GENERATED_MANPAGES)
 
-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
+INFOFILES = doc/cpp.info doc/gcc.info doc/gccint.info \
+            doc/gccinstall.info doc/cppinternals.info
 
 info: $(INFOFILES) lang.info @GENINSRC@ srcinfo lang.srcinfo
 
 srcinfo: $(INFOFILES)
        -cp -p $^ $(srcdir)/doc
 
-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
+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 $@
 
-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 SPHINXBUILD=$(SPHINX_BUILD)
+# 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.
+
+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)
 
-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 SPHINXBUILD=$(SPHINX_BUILD)
+DVIFILES = doc/gcc.dvi doc/gccint.dvi doc/gccinstall.dvi doc/cpp.dvi \
+           doc/cppinternals.dvi
 
-doc/install/pdf/latex/install.pdf: $(SPHINX_FILES)
-       + make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_docdir)/install BUILDDIR=$(objdir)/doc/install/pdf SPHINXBUILD=$(SPHINX_BUILD)
+dvi:: $(DVIFILES) lang.dvi
+
+doc/%.dvi: %.texi
+       $(TEXI2DVI) -I . -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
+
+# Duplicate entry to handle renaming of gccinstall.dvi
+doc/gccinstall.dvi: $(TEXI_GCCINSTALL_FILES)
+       $(TEXI2DVI) -I . -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
+
+PDFFILES = doc/gcc.pdf doc/gccint.pdf doc/gccinstall.pdf doc/cpp.pdf \
+           doc/cppinternals.pdf
+
+pdf:: $(PDFFILES) lang.pdf
 
-doc/cpp/pdf/latex/cpp.pdf: $(SPHINX_FILES)
-       + make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_docdir)/cpp BUILDDIR=$(objdir)/doc/cpp/pdf SPHINXBUILD=$(SPHINX_BUILD)
+doc/%.pdf: %.texi
+       $(TEXI2PDF) -I . -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
 
-doc/cppinternals/pdf/latex/cppinternals.pdf: $(SPHINX_FILES)
-       + make -C $(srcdir)/../doc latexpdf SOURCEDIR=$(abs_docdir)/cppinternals BUILDDIR=$(objdir)/doc/cppinternals/pdf SPHINXBUILD=$(SPHINX_BUILD)
+# Duplicate entry to handle renaming of gccinstall.pdf
+doc/gccinstall.pdf: $(TEXI_GCCINSTALL_FILES)
+       $(TEXI2PDF) -I . -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
 
 # List the directories or single hmtl files which are installed by
 # install-html. The lang.html file triggers language fragments to build
@@ -3324,75 +3448,70 @@ HTMLS_INSTALL=$(build_htmldir)/cpp $(build_htmldir)/gcc \
        $(build_htmldir)/cppinternals
 
 # List the html file targets.
-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
+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
 
-html:: $(HTMLS) lang.html
+html:: $(HTMLS_BUILD)
 
-doc/gcc/html/html/index.html: $(SPHINX_FILES)
-       + make -C $(srcdir)/../doc html SOURCEDIR=$(abs_docdir)/gcc BUILDDIR=$(objdir)/doc/gcc/html SPHINXBUILD=$(SPHINX_BUILD)
+$(build_htmldir)/%/index.html: %.texi
+       $(mkinstalldirs) $(@D)
+       rm -f $(@D)/*
+       $(TEXI2HTML) -I $(abs_docdir) -I $(abs_docdir)/include -o $(@D) $<
 
-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 SPHINXBUILD=$(SPHINX_BUILD)
+# 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/install/html/html/index.html: $(SPHINX_FILES)
-       + make -C $(srcdir)/../doc html SOURCEDIR=$(abs_docdir)/install BUILDDIR=$(objdir)/doc/install/html SPHINXBUILD=$(SPHINX_BUILD)
+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/cpp/html/html/index.html: $(SPHINX_FILES)
-       + 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 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 \
-           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)"
+generated-manpages: man
 
 man: $(MANFILES) lang.man @GENINSRC@ srcman lang.srcman
 
 srcman: $(MANFILES)
        -cp -p $^ $(srcdir)/doc
 
-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 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
-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
-
-doc/cpp/man/man/cpp.1: $(SPHINX_FILES)
-       + make -C $(srcdir)/../doc man SOURCEDIR=$(abs_docdir)/cpp BUILDDIR=$(objdir)/doc/cpp/man SPHINXBUILD=$(SPHINX_BUILD)
+doc/%.1: %.pod
+       $(STAMP) $@
+       -($(POD2MAN) --section=1 $< > $(@).T$$$$ && \
+               mv -f $(@).T$$$$ $@) || \
+               (rm -f $(@).T$$$$ && exit 1)
 
-doc/gcc/info/texinfo/gcc.info: $(SPHINX_FILES)
-       + make -C $(srcdir)/../doc info SOURCEDIR=$(abs_docdir)/gcc BUILDDIR=$(objdir)/doc/gcc/info SPHINXBUILD=$(SPHINX_BUILD)
+doc/%.7: %.pod
+       $(STAMP) $@
+       -($(POD2MAN) --section=7 $< > $(@).T$$$$ && \
+               mv -f $(@).T$$$$ $@) || \
+               (rm -f $(@).T$$$$ && exit 1)
 
-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 SPHINXBUILD=$(SPHINX_BUILD)
+%.pod: %.texi
+       $(STAMP) $@
+       -$(TEXI2POD) -DBUGURL="$(BUGURL_TEXI)" $< > $@
 
-doc/cpp/info/texinfo/cpp.info: $(SPHINX_FILES)
-       + make -C $(srcdir)/../doc info SOURCEDIR=$(abs_docdir)/cpp BUILDDIR=$(objdir)/doc/cpp/info SPHINXBUILD=$(SPHINX_BUILD)
+.INTERMEDIATE: cpp.pod gcc.pod gfdl.pod fsf-funding.pod gpl.pod
+cpp.pod: cpp.texi cppenv.texi cppopts.texi
 
-doc/cppinternals/info/texinfo/cppinternals.info: $(SPHINX_FILES)
-       + make -C $(srcdir)/../doc info SOURCEDIR=$(abs_docdir)/cppinternals BUILDDIR=$(objdir)/doc/cppinternals/info SPHINXBUILD=$(SPHINX_BUILD)
+# 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/install/info/texinfo/install.info: $(SPHINX_FILES)
-       + make -C $(srcdir)/../doc info SOURCEDIR=$(abs_docdir)/install BUILDDIR=$(objdir)/doc/install/info SPHINXBUILD=$(SPHINX_BUILD)
+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) $< > $@
 
 #\f
 # Deletion of files made during compilation.
@@ -3452,7 +3571,8 @@ clean: mostlyclean lang.clean
        -rm -f config.h tconfig.h bconfig.h tm_p.h tm.h
        -rm -f options.cc options.h optionlist
        -rm -f cs-*
-       -rm -rf doc
+       -rm -f doc/*.dvi
+       -rm -f doc/*.pdf
 # Delete the include directories.
        -rm -rf include include-fixed
 # Delete files used by the "multilib" facility (including libgcc subdirs).
@@ -3480,6 +3600,7 @@ 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
@@ -3492,7 +3613,7 @@ maintainer-clean:
        $(MAKE) lang.maintainer-clean distclean
        -rm -f cpp.??s cpp.*aux
        -rm -f gcc.??s gcc.*aux
-       -rm -rf doc
+       -rm -f $(gcc_docdir)/*.info $(gcc_docdir)/*.1 $(gcc_docdir)/*.7 $(gcc_docdir)/*.dvi $(gcc_docdir)/*.pdf
 #\f
 # Entry points `install', `install-strip', and `uninstall'.
 # Also use `install-collect2' to install collect2 when the config files don't.
@@ -3689,36 +3810,24 @@ install-info:: doc installdirs \
        $(DESTDIR)$(infodir)/cpp.info \
        $(DESTDIR)$(infodir)/gcc.info \
        $(DESTDIR)$(infodir)/cppinternals.info \
-       $(DESTDIR)$(infodir)/install.info \
+       $(DESTDIR)$(infodir)/gccinstall.info \
        $(DESTDIR)$(infodir)/gccint.info \
        lang.install-info
 
-$(DESTDIR)$(infodir)/gcc.info: installdirs
-       -if [ -f doc/gcc/info/texinfo/gcc.info ]; then rm -f $@; $(INSTALL_DATA) doc/gcc/info/texinfo/gcc.info $@; fi
-
-$(DESTDIR)$(infodir)/gccint.info: installdirs
-       -if [ -f doc/gccint/info/texinfo/gccint.info ]; then rm -f $@; $(INSTALL_DATA) doc/gccint/info/texinfo/gccint.info $@; fi
-
-$(DESTDIR)$(infodir)/install.info: installdirs
-       -if [ -f doc/install/info/texinfo/install.info ]; then rm -f $@; $(INSTALL_DATA) doc/install/info/texinfo/install.info $@; fi
-
-$(DESTDIR)$(infodir)/cpp.info: installdirs
-       -if [ -f doc/cpp/info/texinfo/cpp.info ]; then rm -f $@; $(INSTALL_DATA) doc/cpp/info/texinfo/cpp.info $@; fi
-
-$(DESTDIR)$(infodir)/cppinternals.info: installdirs
-       -if [ -f doc/cppinternals/info/texinfo/cppinternals.info ]; then rm -f $@; $(INSTALL_DATA) doc/cppinternals/info/texinfo/cppinternals.info $@; fi
-
-$(DESTDIR)$(infodir)/gcov.info: installdirs
-       -if [ -f doc/gcc/info/texinfo/gcov.info ]; then rm -f $@; $(INSTALL_DATA) doc/gcc/info/texinfo/gcov.info $@; fi
-
-$(DESTDIR)$(infodir)/gcov-tool.info: installdirs
-       -if [ -f doc/gcc/info/texinfo/gcov-tool.info ]; then rm -f $@; $(INSTALL_DATA) doc/gcc/info/texinfo/gcov-tool.info $@; fi
-
-$(DESTDIR)$(infodir)/gcov-dump.info: installdirs
-       -if [ -f doc/gcc/info/texinfo/gcov-dump.info ]; then rm -f $@; $(INSTALL_DATA) doc/gcc/info/texinfo/gcov-dump.info $@; fi
-
-$(DESTDIR)$(infodir)/lto-dump.info: installdirs
-       -if [ -f doc/gcc/info/texinfo/lto-dump.info ]; then rm -f $@; $(INSTALL_DATA) doc/gcc/info/texinfo/lto-dump.info $@; fi
+$(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;
 
 dvi__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 
@@ -3746,7 +3855,7 @@ install-pdf: $(PDFFILES) lang.install-pdf
 
 html__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 
-install-html: $(HTMLS) lang.install-html
+install-html: $(HTMLS_BUILD) lang.install-html
        @$(NORMAL_INSTALL)
        test -z "$(htmldir)" || $(mkinstalldirs) "$(DESTDIR)$(htmldir)"
        @list='$(HTMLS_INSTALL)'; for p in $$list; do \
@@ -3780,32 +3889,35 @@ $(DESTDIR)$(man7dir)/%$(man7ext): doc/%.7 installdirs
        -$(INSTALL_DATA) $< $@
        -chmod a-x $@
 
-$(DESTDIR)$(man1dir)/$(GCC_INSTALL_NAME)$(man1ext):  installdirs
-       -if [ -f doc/gcc/man/man/gcc.1 ]; then rm -f $@; $(INSTALL_DATA) doc/gcc/man/man/gcc.1 $@; chmod a-x $@; fi
-
-$(DESTDIR)$(man1dir)/$(CPP_INSTALL_NAME)$(man1ext):  installdirs
-       -if [ -f doc/gcc/man/man/cpp.1 ]; then rm -f $@; $(INSTALL_DATA) doc/gcc/man/man/cpp.1 $@; chmod a-x $@; fi
-
-$(DESTDIR)$(man1dir)/$(GCOV_INSTALL_NAME)$(man1ext): installdirs
-       -if [ -f doc/gcc/man/man/gcov.1 ]; then rm -f $@; $(INSTALL_DATA) doc/gcc/man/man/gcov.1 $@; chmod a-x $@; fi
-
-$(DESTDIR)$(man1dir)/$(GCOV_TOOL_INSTALL_NAME)$(man1ext): installdirs
-       -if [ -f doc/gcc/man/man/gcov-tool.1 ]; then rm -f $@; $(INSTALL_DATA) doc/gcc/man/man/gcov-tool.1 $@; chmod a-x $@; fi
+$(DESTDIR)$(man1dir)/$(GCC_INSTALL_NAME)$(man1ext): doc/gcc.1 installdirs
+       -rm -f $@
+       -$(INSTALL_DATA) $< $@
+       -chmod a-x $@
 
-$(DESTDIR)$(man1dir)/$(GCOV_DUMP_INSTALL_NAME)$(man1ext): installdirs
-       -if [ -f doc/gcc/man/man/gcov-dump.1 ]; then rm -f $@; $(INSTALL_DATA) doc/gcc/man/man/gcov-dump.1 $@; chmod a-x $@; fi
+$(DESTDIR)$(man1dir)/$(CPP_INSTALL_NAME)$(man1ext): doc/cpp.1 installdirs
+       -rm -f $@
+       -$(INSTALL_DATA) $< $@
+       -chmod a-x $@
 
-$(DESTDIR)$(man1dir)/$(LTO_DUMP_INSTALL_NAME)$(man1ext): installdirs
-       -if [ -f doc/gcc/man/man/lto-dump.1 ]; then rm -f $@; $(INSTALL_DATA) doc/gcc/man/man/lto-dump.1 $@; chmod a-x $@; fi
+$(DESTDIR)$(man1dir)/$(GCOV_INSTALL_NAME)$(man1ext): doc/gcov.1 installdirs
+       -rm -f $@
+       -$(INSTALL_DATA) $< $@
+       -chmod a-x $@
 
-$(DESTDIR)$(man7dir)/fsf-funding$(man7ext): installdirs
-       -if [ -f doc/gcc/man/man/fsf-funding.7 ]; then rm -f $@; $(INSTALL_DATA) doc/gcc/man/man/fsf-funding.7 $@; chmod a-x $@; fi
+$(DESTDIR)$(man1dir)/$(GCOV_TOOL_INSTALL_NAME)$(man1ext): doc/gcov-tool.1 installdirs
+       -rm -f $@
+       -$(INSTALL_DATA) $< $@
+       -chmod a-x $@
 
-$(DESTDIR)$(man7dir)/gfdl$(man7ext): installdirs
-       -if [ -f doc/gcc/man/man/gfdl.7 ]; then rm -f $@; $(INSTALL_DATA) doc/gcc/man/man/gfdl.7 $@; chmod a-x $@; fi
+$(DESTDIR)$(man1dir)/$(GCOV_DUMP_INSTALL_NAME)$(man1ext): doc/gcov-dump.1 installdirs
+       -rm -f $@
+       -$(INSTALL_DATA) $< $@
+       -chmod a-x $@
 
-$(DESTDIR)$(man7dir)/gpl$(man7ext): installdirs
-       -if [ -f doc/gcc/man/man/gpl.7 ]; then rm -f $@; $(INSTALL_DATA) doc/gcc/man/man/gpl.7 $@; chmod a-x $@; fi
+$(DESTDIR)$(man1dir)/$(LTO_DUMP_INSTALL_NAME)$(man1ext): doc/lto-dump.1 installdirs
+       -rm -f $@
+       -$(INSTALL_DATA) $< $@
+       -chmod a-x $@
 
 # Install all the header files built in the include subdirectory.
 install-headers: $(INSTALL_HEADERS_DIR)