[PATCH 4/5] newlib: move man page generation into top-level build

Mike Frysinger <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
This allows building the libc & libm pages in parallel, and drops
the duplication in the subdirs with the chew/chapter settings.

The unused rules in Makefile.shared are left in place to minimize
noise in the change.
---
 newlib/Makefile.am              |  16 --
 newlib/Makefile.in              |  71 +++--
 newlib/doc/local.mk             |  12 +
 newlib/libc/Makefile.am         |  70 +----
 newlib/libc/Makefile.in         | 445 +++-----------------------------
 newlib/libc/ctype/Makefile.am   |   6 -
 newlib/libc/ctype/Makefile.in   |  15 +-
 newlib/libc/iconv/Makefile.am   |   6 -
 newlib/libc/iconv/Makefile.in   |   8 +-
 newlib/libc/local.mk            |  23 +-
 newlib/libc/locale/Makefile.am  |   6 -
 newlib/libc/locale/Makefile.in  |   9 +-
 newlib/libc/machine/Makefile.in |   4 -
 newlib/libc/misc/Makefile.am    |   6 -
 newlib/libc/misc/Makefile.in    |   8 +-
 newlib/libc/posix/Makefile.am   |   6 -
 newlib/libc/posix/Makefile.in   |   8 +-
 newlib/libc/reent/Makefile.am   |   6 -
 newlib/libc/reent/Makefile.in   |  12 +-
 newlib/libc/search/Makefile.am  |   6 -
 newlib/libc/search/Makefile.in  |   8 +-
 newlib/libc/signal/Makefile.am  |   6 -
 newlib/libc/signal/Makefile.in  |   8 +-
 newlib/libc/ssp/Makefile.am     |   6 -
 newlib/libc/ssp/Makefile.in     |   8 +-
 newlib/libc/stdio/Makefile.am   |   6 -
 newlib/libc/stdio/Makefile.in   |  24 +-
 newlib/libc/stdio64/Makefile.am |   6 -
 newlib/libc/stdio64/Makefile.in |  10 +-
 newlib/libc/stdlib/Makefile.am  |   6 -
 newlib/libc/stdlib/Makefile.in  |  17 +-
 newlib/libc/string/Makefile.am  |   6 -
 newlib/libc/string/Makefile.in  |  26 +-
 newlib/libc/sys/Makefile.in     |   4 -
 newlib/libc/time/Makefile.am    |   6 -
 newlib/libc/time/Makefile.in    |  14 +-
 newlib/libm/Makefile.am         |  22 --
 newlib/libm/Makefile.in         |  24 +-
 newlib/libm/common/Makefile.am  |   6 -
 newlib/libm/common/Makefile.in  |  13 +-
 newlib/libm/complex/Makefile.am |   6 -
 newlib/libm/complex/Makefile.in |  11 +-
 newlib/libm/fenv/Makefile.am    |   6 -
 newlib/libm/fenv/Makefile.in    |  11 +-
 newlib/libm/local.mk            |  23 +-
 newlib/libm/machine/Makefile.am |   4 -
 newlib/libm/machine/Makefile.in |   4 -
 newlib/libm/math/Makefile.am    |   6 -
 newlib/libm/math/Makefile.in    |  13 +-
 newlib/libm/mathfp/Makefile.am  |   6 -
 newlib/libm/mathfp/Makefile.in  |  14 +-
 51 files changed, 189 insertions(+), 884 deletions(-)

diff --git a/newlib/Makefile.am b/newlib/Makefile.am
index 21945fd71c0f..0ad3045246fc 100644
--- a/newlib/Makefile.am
+++ b/newlib/Makefile.am
@@ -426,22 +426,6 @@ unidata:
 # Force makedoc to be built before building info files.
 info-recursive dvi-recursive: doc/makedoc$(EXEEXT_FOR_BUILD)
 
-# Recursive targets for man and install-man
-man:
-	$(MAKE) man-cache || exit 1; \
-	for d in $(SUBDIRS); do \
-	  if test "$$d" != "."; then \
-	    (cd $$d && $(MAKE) man) || exit 1; \
-	  fi; \
-	done
-
-install-man:
-	for d in $(SUBDIRS); do \
-	  if test "$$d" != "."; then \
-	    (cd $$d && $(MAKE) install-man) || exit 1; \
-	  fi; \
-	done
-
 CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
 
 # Multilib support.
diff --git a/newlib/doc/local.mk b/newlib/doc/local.mk
index 5c867c998251..15c43f225e66 100644
--- a/newlib/doc/local.mk
+++ b/newlib/doc/local.mk
@@ -29,3 +29,15 @@ CHEW = $(MKDOC) -f $(srcdir)/%D%/doc.str
 
 .c.def:
 	$(AM_V_GEN)$(CHEW) < $< > $*.def || ( rm $*.def && false )
+
+SUFFIXES += .xml
+
+DOCBOOK_CHEW = ${top_srcdir}/%D%/makedocbook.py
+
+.c.xml:
+	$(AM_V_GEN)$(DOCBOOK_CHEW) < $< > $*.xml || ( rm $*.xml && false )
+
+# We can't use .tex.xml rule here as it'll conflict with .c.xml when the chapter
+# name (e.g. "stdio.xml") matches a source file name (e.g. "stdio.c").  We've
+# been flattening chapters into the main library dir (e.g. libc/) to avoid that.
+TEXI2DOCBOOK = $(top_srcdir)/%D%/chapter-texi2docbook.py
diff --git a/newlib/libc/Makefile.am b/newlib/libc/Makefile.am
index 62e04abcfbc1..91f6b95d7dc3 100644
--- a/newlib/libc/Makefile.am
+++ b/newlib/libc/Makefile.am
@@ -121,75 +121,7 @@ crt0.o: sys/crt0.o
 
 sys/crt0.o: ; @true
 
-# This is a list of the stmp-def files in each subdirectory which
-# builds .def files.  We don't list subdirectories which don't build
-# .def files; if the list of subdirectories changes, we must change
-# this as well.
-SUBDEFS = \
-	stdlib/stmp-def \
-	ctype/stmp-def \
-	stdio/stmp-def \
-	stdio64/stmp-def \
-	posix/stmp-def \
-	xdr/stmp-def \
-	string/stmp-def \
-	signal/stmp-def \
-	time/stmp-def \
-	locale/stmp-def \
-	reent/stmp-def \
-	misc/stmp-def
-
-# ditto for stmp-xml files in each subdirectory which builds .xml files
-SUBXMLS = $(SUBDEFS:stmp-def=stmp-xml)
-
-libc.info: targetdep.tex $(SUBDEFS)
-
-libc.dvi: targetdep.tex $(SUBDEFS)
-
-stmp-targetdep: force
-	rm -f tmp-targetdep.texi
-	targetdoc=`pwd`/tmp-targetdep.texi; \
-	for d in $(SUBDIRS); do \
-	  if test "$$d" != "."; then \
-	    (cd $$d && $(MAKE) TARGETDOC=$${targetdoc} doc) || exit 1; \
-	  fi; \
-	done
-	cat $(srcdir)/sys.tex >>tmp-targetdep.texi
-	$(SHELL) $(newlib_basedir)/../move-if-change tmp-targetdep.texi targetdep.tex
-	touch $@
-
-targetdep.tex: stmp-targetdep ; @true
-
-$(SUBDEFS): stmp-targetdep ; @true
-
-TEXINFO_TEX = ../../texinfo/texinfo.tex
-info_TEXINFOS = libc.texi
-libc_TEXINFOS = targetdep.tex $(SUBDEFS)
-
-docbook-recursive: force
-	for d in $(SUBDIRS); do \
-	  if test "$$d" != "."; then \
-	    (cd $$d && $(MAKE) docbook) || exit 1; \
-	  fi; \
-	done
-
-$(SUBXMLS): docbook-recursive
-
-man: $(SUBXMLS) libc.in.xml
-	xsltproc --xinclude --path ${builddir} --nonet ${srcdir}/../refcontainers.xslt ${srcdir}/libc.in.xml >libc.xml
-	xmlto --skip-validation man -m ${srcdir}/../man.xsl libc.xml
-
-install-man: man
-	mkdir -p $(DESTDIR)$(mandir)/man3
-	$(INSTALL_DATA) *.3 $(DESTDIR)$(mandir)/man3
-
-.PHONY: force
-force:
-
-CLEANFILES = $(CRT0) \
-	targetdep.tex stmp-targetdep \
-	tmp-targetdep.texi \
-	*.xml *.3
+CLEANFILES = $(CRT0)
 
 ACLOCAL_AMFLAGS = -I .. -I ../.. -I ../../config
 CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
diff --git a/newlib/libc/ctype/Makefile.am b/newlib/libc/ctype/Makefile.am
index 6d68622b5175..4c4c36db1520 100644
--- a/newlib/libc/ctype/Makefile.am
+++ b/newlib/libc/ctype/Makefile.am
@@ -95,10 +95,4 @@ endif # USE_LIBTOOL
 
 include $(srcdir)/../../Makefile.shared
 
-LIBC_CHEWOUT_FILES =
-LIBC_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBC_CHEWOUT_FILES)
-CHAPTERS = $(LIBC_CHAPTERS)
-
 $(lpfx)ctype_.$(oext): ctype_.c ctype_iso.h ctype_cp.h
diff --git a/newlib/libc/iconv/Makefile.am b/newlib/libc/iconv/Makefile.am
index 0b861d3b8c68..d9c0d4077b4b 100644
--- a/newlib/libc/iconv/Makefile.am
+++ b/newlib/libc/iconv/Makefile.am
@@ -7,9 +7,3 @@ cct_DATA=encoding.aliases
 AM_CPPFLAGS = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
 
 include $(srcdir)/../../Makefile.shared
-
-LIBC_CHEWOUT_FILES =
-LIBC_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBC_CHEWOUT_FILES)
-CHAPTERS = $(LIBC_CHAPTERS)
diff --git a/newlib/libc/local.mk b/newlib/libc/local.mk
index f6b797f612c2..d3cd02315af4 100644
--- a/newlib/libc/local.mk
+++ b/newlib/libc/local.mk
@@ -4,6 +4,7 @@ info_TEXINFOS += %D%/libc.texi
 LIBC_CHEWOUT_FILES =
 
 LIBC_CHAPTERS = %D%/sys.tex
+LIBC_DOCBOOK_OUT_FILES = $(LIBC_CHEWOUT_FILES:.def=.xml)
 
 %D%/libc.dvi: %D%/targetdep.tex $(LIBC_CHEWOUT_FILES)
 
@@ -12,6 +13,24 @@ LIBC_CHAPTERS = %D%/sys.tex
 	$(AM_V_at)$(SHELL) $(newlib_basedir)/../move-if-change [email protected] $@
 	$(AM_V_at)touch $@
 
+%D%/libc.xml: %D%/libc.in.xml $(LIBC_CHAPTERS) $(LIBC_DOCBOOK_OUT_FILES)
+	$(AM_V_at)\
+	for chapter in $(LIBC_CHAPTERS); do \
+	  $(TEXI2DOCBOOK) < $(srcdir)/$$chapter > %D%/`basename $${chapter%.tex}`.xml || exit 1; \
+	done
+	$(AM_V_GEN)xsltproc --xinclude --path $(builddir)/%D% --nonet $(srcdir)/refcontainers.xslt $< > [email protected]
+	$(AM_V_at)$(SHELL) $(newlib_basedir)/../move-if-change [email protected] $@
+	$(AM_V_at)touch $@
+
+%C%_man: %D%/libc.xml
+	$(AM_V_GEN)xmlto --skip-validation -o %D% --searchpath $(builddir)/%D% man -m $(srcdir)/man.xsl %D%/libc.xml
+man: %C%_man
+
+%C%_install-man: %C%_man
+	$(MKDIR_P) $(DESTDIR)$(mandir)/man3
+	$(INSTALL_DATA) %D%/*.3 $(DESTDIR)$(mandir)/man3/
+install-man: %C%_install-man
+
 include %D%/ctype/local.mk
 include %D%/iconv/local.mk
 include %D%/locale/local.mk
@@ -29,4 +48,6 @@ include %D%/time/local.mk
 
 CLEANFILES += \
 	%D%/targetdep.tex \
-	$(LIBC_CHEWOUT_FILES)
+	$(LIBC_CHEWOUT_FILES) \
+	$(LIBC_DOCBOOK_OUT_FILES) \
+	%D%/*.xml %D%/*.3
diff --git a/newlib/libc/locale/Makefile.am b/newlib/libc/locale/Makefile.am
index 0fc51ffd4d74..c060496cfcdb 100644
--- a/newlib/libc/locale/Makefile.am
+++ b/newlib/libc/locale/Makefile.am
@@ -35,9 +35,3 @@ noinst_DATA =
 endif # USE_LIBTOOL
 
 include $(srcdir)/../../Makefile.shared
-
-LIBC_CHEWOUT_FILES =
-LIBC_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBC_CHEWOUT_FILES)
-CHAPTERS = $(LIBC_CHAPTERS)
diff --git a/newlib/libc/misc/Makefile.am b/newlib/libc/misc/Makefile.am
index c9fb96c68696..f8f8bb15a548 100644
--- a/newlib/libc/misc/Makefile.am
+++ b/newlib/libc/misc/Makefile.am
@@ -23,9 +23,3 @@ noinst_DATA =
 endif # USE_LIBTOOL
 
 include $(srcdir)/../../Makefile.shared
-
-LIBC_CHEWOUT_FILES =
-LIBC_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBC_CHEWOUT_FILES)
-CHAPTERS = $(LIBC_CHAPTERS)
diff --git a/newlib/libc/posix/Makefile.am b/newlib/libc/posix/Makefile.am
index 88976a14d4a9..4f4c12d8a3e8 100644
--- a/newlib/libc/posix/Makefile.am
+++ b/newlib/libc/posix/Makefile.am
@@ -49,10 +49,4 @@ endif # USE_LIBTOOL
 
 include $(srcdir)/../../Makefile.shared
 
-LIBC_CHEWOUT_FILES =
-LIBC_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBC_CHEWOUT_FILES)
-CHAPTERS = $(LIBC_CHAPTERS)
-
 AM_CFLAGS = -D_GNU_SOURCE
diff --git a/newlib/libc/reent/Makefile.am b/newlib/libc/reent/Makefile.am
index c5396890d067..bf0c8d7f6a17 100644
--- a/newlib/libc/reent/Makefile.am
+++ b/newlib/libc/reent/Makefile.am
@@ -61,10 +61,4 @@ endif # USE_LIBTOOL
 
 include $(srcdir)/../../Makefile.shared
 
-LIBC_CHEWOUT_FILES =
-LIBC_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBC_CHEWOUT_FILES)
-CHAPTERS = $(LIBC_CHAPTERS)
-
 $(lpfx)impure.$(oext): $(srcdir)/impure.c $(srcdir)/../include/sys/reent.h
diff --git a/newlib/libc/search/Makefile.am b/newlib/libc/search/Makefile.am
index ef1c1e223376..c64f28931171 100644
--- a/newlib/libc/search/Makefile.am
+++ b/newlib/libc/search/Makefile.am
@@ -62,9 +62,3 @@ noinst_DATA =
 endif # USE_LIBTOOL
 
 include $(srcdir)/../../Makefile.shared
-
-LIBC_CHEWOUT_FILES =
-LIBC_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBC_CHEWOUT_FILES)
-CHAPTERS = $(LIBC_CHAPTERS)
diff --git a/newlib/libc/signal/Makefile.am b/newlib/libc/signal/Makefile.am
index 1f644b9c9ef3..d631662beda1 100644
--- a/newlib/libc/signal/Makefile.am
+++ b/newlib/libc/signal/Makefile.am
@@ -18,9 +18,3 @@ noinst_DATA =
 endif # USE_LIBTOOL
 
 include $(srcdir)/../../Makefile.shared
-
-LIBC_CHEWOUT_FILES =
-LIBC_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBC_CHEWOUT_FILES)
-CHAPTERS = $(LIBC_CHAPTERS)
diff --git a/newlib/libc/ssp/Makefile.am b/newlib/libc/ssp/Makefile.am
index 2d0a25d0c63f..2ff5fa0bf924 100644
--- a/newlib/libc/ssp/Makefile.am
+++ b/newlib/libc/ssp/Makefile.am
@@ -62,9 +62,3 @@ noinst_DATA =
 endif # USE_LIBTOOL
 
 include $(srcdir)/../../Makefile.shared
-
-LIBC_CHEWOUT_FILES =
-LIBC_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBC_CHEWOUT_FILES)
-CHAPTERS = $(LIBC_CHAPTERS)
diff --git a/newlib/libc/stdio/Makefile.am b/newlib/libc/stdio/Makefile.am
index 25207cea26bb..f1fd89f364c8 100644
--- a/newlib/libc/stdio/Makefile.am
+++ b/newlib/libc/stdio/Makefile.am
@@ -241,12 +241,6 @@ endif # USE_LIBTOOL
 
 include $(srcdir)/../../Makefile.shared
 
-LIBC_CHEWOUT_FILES =
-LIBC_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBC_CHEWOUT_FILES)
-CHAPTERS = $(LIBC_CHAPTERS)
-
 # Though small footprint nano-formatted-IO implementation is used
 # when NEWLIB_NANO_FORMATTED_IO is enabled, we keep all rules for
 # the other implementation of formatted IO including all i-family
diff --git a/newlib/libc/stdio64/Makefile.am b/newlib/libc/stdio64/Makefile.am
index e93f7056518c..3d479d7faf26 100644
--- a/newlib/libc/stdio64/Makefile.am
+++ b/newlib/libc/stdio64/Makefile.am
@@ -38,10 +38,4 @@ endif # USE_LIBTOOL
 
 include $(srcdir)/../../Makefile.shared
 
-LIBC_CHEWOUT_FILES =
-LIBC_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBC_CHEWOUT_FILES)
-CHAPTERS = $(LIBC_CHAPTERS)
-
 AM_CFLAGS = -I $(srcdir)/../stdio
diff --git a/newlib/libc/stdlib/Makefile.am b/newlib/libc/stdlib/Makefile.am
index 4cfcab39a9d6..75fb52f50d7e 100644
--- a/newlib/libc/stdlib/Makefile.am
+++ b/newlib/libc/stdlib/Makefile.am
@@ -222,12 +222,6 @@ endif # USE_LIBTOOL
 
 include $(srcdir)/../../Makefile.shared
 
-LIBC_CHEWOUT_FILES =
-LIBC_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBC_CHEWOUT_FILES)
-CHAPTERS = $(LIBC_CHAPTERS)
-
 MALLOC_COMPILE = $(LIB_COMPILE) -DINTERNAL_NEWLIB
 
 $(lpfx)$(MALLOCR).$(oext): $(MALLOCR).c
diff --git a/newlib/libc/string/Makefile.am b/newlib/libc/string/Makefile.am
index 70bf7afdc01f..ac41665bb2dc 100644
--- a/newlib/libc/string/Makefile.am
+++ b/newlib/libc/string/Makefile.am
@@ -143,9 +143,3 @@ noinst_DATA =
 endif # USE_LIBTOOL
 
 include $(srcdir)/../../Makefile.shared
-
-LIBC_CHEWOUT_FILES =
-LIBC_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBC_CHEWOUT_FILES)
-CHAPTERS = $(LIBC_CHAPTERS)
diff --git a/newlib/libc/time/Makefile.am b/newlib/libc/time/Makefile.am
index 90081823230e..a2a807917e76 100644
--- a/newlib/libc/time/Makefile.am
+++ b/newlib/libc/time/Makefile.am
@@ -42,10 +42,4 @@ endif # USE_LIBTOOL
 # This rule is needed so that wcsftime.o is rebuilt when strftime.c changes.
 include $(srcdir)/../../Makefile.shared
 
-LIBC_CHEWOUT_FILES =
-LIBC_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBC_CHEWOUT_FILES)
-CHAPTERS = $(LIBC_CHAPTERS)
-
 $(lpfx)wcsftime.$(oext): strftime.c
diff --git a/newlib/libm/Makefile.am b/newlib/libm/Makefile.am
index 08d6faa8ac17..158d873ca815 100644
--- a/newlib/libm/Makefile.am
+++ b/newlib/libm/Makefile.am
@@ -33,27 +33,5 @@ endif
 
 $(SUBLIBS):
 
-docbook-recursive: force
-	for d in $(SUBDIRS); do \
-	  if test "$$d" != "."; then \
-	    (cd $$d && $(MAKE) docbook) || exit 1; \
-	  fi; \
-	done
-
-math/stmp-xml complex/stmp-xml: docbook-recursive
-
-man: math/stmp-xml complex/stmp-xml libm.in.xml
-	xsltproc --xinclude --path ${builddir} --nonet ${srcdir}/../refcontainers.xslt ${srcdir}/libm.in.xml >libm.xml
-	xmlto --skip-validation --searchpath ${builddir} man -m ${srcdir}/../man.xsl libm.xml
-
-install-man: man
-	mkdir -p $(DESTDIR)$(mandir)/man3
-	$(INSTALL_DATA) *.3 $(DESTDIR)$(mandir)/man3/
-
-.PHONY: force
-force:
-
-CLEANFILES = *.xml *.3
-
 ACLOCAL_AMFLAGS = -I .. -I ../.. -I ../../config
 CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
diff --git a/newlib/libm/common/Makefile.am b/newlib/libm/common/Makefile.am
index 52f74eec5763..325f4717d736 100644
--- a/newlib/libm/common/Makefile.am
+++ b/newlib/libm/common/Makefile.am
@@ -59,12 +59,6 @@ endif # USE_LIBTOOL
 
 include $(srcdir)/../../Makefile.shared
 
-LIBM_CHEWOUT_FILES =
-LIBM_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBM_CHEWOUT_FILES)
-CHAPTERS = $(LIBM_CHAPTERS)
-
 # A partial dependency list.
 
 $(lib_a_OBJECTS): $(srcdir)/../../libc/include/math.h fdlibm.h
diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 27993dc43fa2..aceb55e9fc7b 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -35,12 +35,6 @@ endif # USE_LIBTOOL
 
 include $(srcdir)/../../Makefile.shared
 
-LIBM_CHEWOUT_FILES =
-LIBM_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBM_CHEWOUT_FILES)
-CHAPTERS = $(LIBM_CHAPTERS)
-
 # A partial dependency list.
 
 $(lib_a_OBJECTS): $(srcdir)/../../libc/include/complex.h $(srcdir)/cephes_subr.h $(srcdir)/cephes_subrf.h  $(srcdir)/cephes_subrl.h
diff --git a/newlib/libm/fenv/Makefile.am b/newlib/libm/fenv/Makefile.am
index 3d0052e53617..d515192c0b36 100644
--- a/newlib/libm/fenv/Makefile.am
+++ b/newlib/libm/fenv/Makefile.am
@@ -22,12 +22,6 @@ endif # USE_LIBTOOL
 
 include $(srcdir)/../../Makefile.shared
 
-LIBM_CHEWOUT_FILES =
-LIBM_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBM_CHEWOUT_FILES)
-CHAPTERS = $(LIBM_CHAPTERS)
-
 # A partial dependency list.
 
 $(lib_a_OBJECTS): $(srcdir)/../../libc/include/fenv.h
diff --git a/newlib/libm/local.mk b/newlib/libm/local.mk
index db10751f9392..a6bdfc8fd511 100644
--- a/newlib/libm/local.mk
+++ b/newlib/libm/local.mk
@@ -4,6 +4,7 @@ info_TEXINFOS += %D%/libm.texi
 LIBM_CHEWOUT_FILES =
 
 LIBM_CHAPTERS =
+LIBM_DOCBOOK_OUT_FILES = $(LIBM_CHEWOUT_FILES:.def=.xml)
 
 %D%/libm.dvi: %D%/targetdep.tex $(LIBM_CHEWOUT_FILES)
 
@@ -12,6 +13,24 @@ LIBM_CHAPTERS =
 	$(AM_V_at)$(SHELL) $(newlib_basedir)/../move-if-change [email protected] $@
 	$(AM_V_at)touch $@
 
+%D%/libm.xml: %D%/libm.in.xml $(LIBM_CHAPTERS) $(LIBM_DOCBOOK_OUT_FILES)
+	$(AM_V_at)\
+	for chapter in $(LIBM_CHAPTERS); do \
+	  $(TEXI2DOCBOOK) < $(srcdir)/$$chapter > %D%/`basename $${chapter%.tex}`.xml || exit 1; \
+	done
+	$(AM_V_GEN)xsltproc --xinclude --path $(builddir)/%D% --nonet $(srcdir)/refcontainers.xslt $< > [email protected]
+	$(AM_V_at)$(SHELL) $(newlib_basedir)/../move-if-change [email protected] $@
+	$(AM_V_at)touch $@
+
+%C%_man: %D%/libm.xml
+	$(AM_V_GEN)xmlto --skip-validation -o %D% --searchpath $(builddir)/%D% man -m $(srcdir)/man.xsl %D%/libm.xml
+man: %C%_man
+
+%C%_install-man: %C%_man
+	$(MKDIR_P) $(DESTDIR)$(mandir)/man3
+	$(INSTALL_DATA) %D%/*.3 $(DESTDIR)$(mandir)/man3/
+install-man: %C%_install-man
+
 include %D%/common/local.mk
 include %D%/complex/local.mk
 include %D%/fenv/local.mk
@@ -23,4 +42,6 @@ endif
 
 CLEANFILES += \
 	%D%/targetdep.tex \
-	$(LIBM_CHEWOUT_FILES)
+	$(LIBM_CHEWOUT_FILES) \
+	$(LIBM_DOCBOOK_OUT_FILES) \
+	%D%/*.xml %D%/*.3
diff --git a/newlib/libm/machine/Makefile.am b/newlib/libm/machine/Makefile.am
index 3b05fb103fc1..823a3302c03c 100644
--- a/newlib/libm/machine/Makefile.am
+++ b/newlib/libm/machine/Makefile.am
@@ -18,9 +18,5 @@ endif # USE_LIBTOOL
 
 $(libm_machine_dir)/lib.a:
 
-doc:
-
-docbook:
-
 ACLOCAL_AMFLAGS = -I ../.. -I ../../.. -I ../../../config
 CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
diff --git a/newlib/libm/math/Makefile.am b/newlib/libm/math/Makefile.am
index 97d5d3748936..3402090aaecb 100644
--- a/newlib/libm/math/Makefile.am
+++ b/newlib/libm/math/Makefile.am
@@ -66,12 +66,6 @@ endif # USE_LIBTOOL
 
 include $(srcdir)/../../Makefile.shared
 
-LIBM_CHEWOUT_FILES =
-LIBM_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBM_CHEWOUT_FILES)
-CHAPTERS = $(LIBM_CHAPTERS)
-
 # A partial dependency list.
 
 $(lib_a_OBJECTS): $(srcdir)/../../libc/include/math.h $(srcdir)/../common/fdlibm.h
diff --git a/newlib/libm/mathfp/Makefile.am b/newlib/libm/mathfp/Makefile.am
index a35ae1f54d36..3f4bd75d32df 100644
--- a/newlib/libm/mathfp/Makefile.am
+++ b/newlib/libm/mathfp/Makefile.am
@@ -56,12 +56,6 @@ endif # USE_LIBTOOL
 
 include $(srcdir)/../../Makefile.shared
 
-LIBM_CHEWOUT_FILES =
-LIBM_CHAPTERS =
-include ./local.mk
-CHEWOUT_FILES = $(LIBM_CHEWOUT_FILES)
-CHAPTERS = $(LIBM_CHAPTERS)
-
 # A partial dependency list.
 
 $(lib_a_OBJECTS): $(srcdir)/../../libc/include/math.h $(srcdir)/../common/fdlibm.h
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.