newlib: merge doc into top-level Makefile

Message ID 20211111020714.11610-1-vapier@gentoo.org
State New
Headers show
Series
  • newlib: merge doc into top-level Makefile
Related show

Commit Message

Mike Frysinger Nov. 11, 2021, 2:07 a.m.
Avoid a recursive make with this tiny subdir to speed things up a bit.
---
 newlib/Makefile.am      |   29 +-
 newlib/Makefile.in      |   66 +-
 newlib/configure        |   36 +-
 newlib/configure.ac     |   26 +-
 newlib/doc/Makefile.am  |   28 -
 newlib/doc/Makefile.in  |  368 ---
 newlib/doc/aclocal.m4   | 1012 ---------
 newlib/doc/configure    | 4804 ---------------------------------------
 newlib/doc/configure.ac |   43 -
 newlib/doc/local.mk     |   20 +
 10 files changed, 135 insertions(+), 6297 deletions(-)
 delete mode 100644 newlib/doc/Makefile.am
 delete mode 100644 newlib/doc/Makefile.in
 delete mode 100644 newlib/doc/aclocal.m4
 delete mode 100755 newlib/doc/configure
 delete mode 100644 newlib/doc/configure.ac
 create mode 100644 newlib/doc/local.mk

-- 
2.33.0

Comments

Corinna Vinschen Nov. 11, 2021, 10:45 a.m. | #1
On Nov 10 21:07, Mike Frysinger wrote:
> Avoid a recursive make with this tiny subdir to speed things up a bit.

> ---

>  newlib/Makefile.am      |   29 +-

>  newlib/Makefile.in      |   66 +-

>  newlib/configure        |   36 +-

>  newlib/configure.ac     |   26 +-

>  newlib/doc/Makefile.am  |   28 -

>  newlib/doc/Makefile.in  |  368 ---

>  newlib/doc/aclocal.m4   | 1012 ---------

>  newlib/doc/configure    | 4804 ---------------------------------------

>  newlib/doc/configure.ac |   43 -

>  newlib/doc/local.mk     |   20 +

>  10 files changed, 135 insertions(+), 6297 deletions(-)

>  delete mode 100644 newlib/doc/Makefile.am

>  delete mode 100644 newlib/doc/Makefile.in

>  delete mode 100644 newlib/doc/aclocal.m4

>  delete mode 100755 newlib/doc/configure

>  delete mode 100644 newlib/doc/configure.ac

>  create mode 100644 newlib/doc/local.mk


Patch doesn't apply cleanly to current master.  Please rebase.


Thanks,
Corinna
Mike Frysinger Nov. 11, 2021, 10:33 p.m. | #2
On 11 Nov 2021 11:45, Corinna Vinschen wrote:
> On Nov 10 21:07, Mike Frysinger wrote:

> > Avoid a recursive make with this tiny subdir to speed things up a bit.

> > ---

> >  newlib/Makefile.am      |   29 +-

> >  newlib/Makefile.in      |   66 +-

> >  newlib/configure        |   36 +-

> >  newlib/configure.ac     |   26 +-

> >  newlib/doc/Makefile.am  |   28 -

> >  newlib/doc/Makefile.in  |  368 ---

> >  newlib/doc/aclocal.m4   | 1012 ---------

> >  newlib/doc/configure    | 4804 ---------------------------------------

> >  newlib/doc/configure.ac |   43 -

> >  newlib/doc/local.mk     |   20 +

> >  10 files changed, 135 insertions(+), 6297 deletions(-)

> >  delete mode 100644 newlib/doc/Makefile.am

> >  delete mode 100644 newlib/doc/Makefile.in

> >  delete mode 100644 newlib/doc/aclocal.m4

> >  delete mode 100755 newlib/doc/configure

> >  delete mode 100644 newlib/doc/configure.ac

> >  create mode 100644 newlib/doc/local.mk

> 

> Patch doesn't apply cleanly to current master.  Please rebase.


it isn't a rebase issue.  i deleted the hunks for generated files that i removed
since the patch is huge & noisy with them in it via --irreversible-delete.  you
could do:
  patch -p1 ...
  rm newlib/doc/{Makefile.*,*.m4,configure*}

or i can compress & post it.
-mike
Mike Frysinger Nov. 13, 2021, 5:13 a.m. | #3
here's the patch compressed.  it should apply cleanly to current master.
-mike
Corinna Vinschen Nov. 15, 2021, 10:38 a.m. | #4
On Nov 13 00:13, Mike Frysinger wrote:
> here's the patch compressed.  it should apply cleanly to current master.

> -mike


LGTM, please push.


Thanks,
Corinna

Patch

diff --git a/newlib/Makefile.am b/newlib/Makefile.am
index 3a8b99fce3e6..1ab75f9957e7 100644
--- a/newlib/Makefile.am
+++ b/newlib/Makefile.am
@@ -1,8 +1,12 @@ 
 ## Process this file with automake to generate Makefile.in
 
-AUTOMAKE_OPTIONS = cygnus dejagnu
+AUTOMAKE_OPTIONS = cygnus dejagnu subdir-objects
 ACLOCAL_AMFLAGS = -I . -I ..
 
+# Variables that will accumulate in subdirs.
+PHONY =
+noinst_DATA =
+
 # Multilib support variables.
 MULTISRCTOP =
 MULTIBUILDTOP =
@@ -63,21 +67,15 @@  AM_MAKEFLAGS = \
 
 FLAGS_TO_PASS=$(AM_MAKEFLAGS)
 
-if HAVE_DOC
-DOCDIR = doc
-else
-DOCDIR =
-endif
-
 SUBDIRS = libc libm \
-	$(DOCDIR) . $(EXTRA_DIRS)
+	. $(EXTRA_DIRS)
 
 tooldir = $(exec_prefix)/$(host_alias)
 toollibdir = $(tooldir)/lib$(MULTISUBDIR)
 
 AR_FLAGS = rc
 
-noinst_DATA = stmp-targ-include
+noinst_DATA += stmp-targ-include
 
 if USE_LIBTOOL
 toollib_LTLIBRARIES = libm.la \
@@ -424,10 +422,7 @@  unidata:
 	cd $(srcdir)/libc/ctype; ./mkunidata -u
 
 # Force makedoc to be built before building info files.
-info-recursive: doc/makedoc
-dvi-recursive: doc/makedoc
-doc/makedoc:
-	cd doc && $(MAKE) all
+info-recursive dvi-recursive: doc/makedoc$(EXEEXT_FOR_BUILD)
 
 # Recursive targets for man and install-man
 man:
@@ -448,7 +443,7 @@  install-man:
 CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
 
 # Multilib support.
-.PHONY: all-multi check-multi mostlyclean-multi clean-multi distclean-multi \
+PHONY += all-multi check-multi mostlyclean-multi clean-multi distclean-multi \
 	maintainer-clean-multi
 
 all-recursive: all-multi
@@ -540,3 +535,9 @@  check-DEJAGNU: site.exp
 
 clean-local:
 	-rm -rf targ-include newlib.h _newlib_version.h stamp-*
+
+if HAVE_DOC
+include doc/local.mk
+endif
+
+.PHONY: $(PHONY)
diff --git a/newlib/Makefile.in b/newlib/Makefile.in
index 266b61a8a8ad..dede75fcf642 100644
--- a/newlib/Makefile.in
+++ b/newlib/Makefile.in
@@ -55,11 +55,16 @@  build_triplet = @build@
 host_triplet = @host@
 @HAVE_CRT0_TRUE@@HAVE_MULTISUBDIR_TRUE@@USE_LIBTOOL_FALSE@am__append_1 = $(BUILD_MULTISUBDIR)/$(CRT0)
 @HAVE_MULTISUBDIR_TRUE@@USE_LIBTOOL_FALSE@am__append_2 = $(BUILD_MULTISUBDIR)/libc.a $(BUILD_MULTISUBDIR)/libm.a
+DIST_COMMON = $(srcdir)/doc/local.mk NEWS README ChangeLog \
+	$(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(top_srcdir)/configure $(am__configure_deps) acconfig.h \
+	$(srcdir)/_newlib_version.hin $(srcdir)/newlib.hin \
+	$(srcdir)/../mkinstalldirs
+
+# We can't use noinst_PROGRAMS, because automake will add $(EXEEXT).
+@HAVE_DOC_TRUE@am__append_3 = doc/makedoc
+@HAVE_DOC_TRUE@am__append_4 = man-cache
 subdir = .
-DIST_COMMON = NEWS README ChangeLog $(srcdir)/Makefile.in \
-	$(srcdir)/Makefile.am $(top_srcdir)/configure \
-	$(am__configure_deps) acconfig.h $(srcdir)/_newlib_version.hin \
-	$(srcdir)/newlib.hin $(srcdir)/../mkinstalldirs
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../libtool.m4 \
 	$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
@@ -171,7 +176,7 @@  RUNTEST = `if test -f $(top_srcdir)/../dejagnu/runtest; then \
 	   else \
 	     echo runtest; \
 	   fi`
-DIST_SUBDIRS = libc libm doc . @EXTRA_DIRS@
+DIST_SUBDIRS = $(SUBDIRS)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AR = @AR@
@@ -187,7 +192,6 @@  CCDEPMODE = @CCDEPMODE@
 CC_FOR_BUILD = @CC_FOR_BUILD@
 CC_FOR_NEWLIB = @CC_FOR_NEWLIB@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CRT0 = @CRT0@
 CRT0_DIR = @CRT0_DIR@
@@ -204,6 +208,7 @@  ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
+EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@
 EXTRA_DIRS = @EXTRA_DIRS@
 FGREP = @FGREP@
 GREP = @GREP@
@@ -306,6 +311,7 @@  pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 shared_machine_dir = @shared_machine_dir@
 sharedstatedir = @sharedstatedir@
@@ -317,9 +323,17 @@  target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-AUTOMAKE_OPTIONS = cygnus dejagnu
+AUTOMAKE_OPTIONS = cygnus dejagnu subdir-objects
 ACLOCAL_AMFLAGS = -I . -I ..
 
+# Variables that will accumulate in subdirs.
+
+# Multilib support.
+PHONY = all-multi check-multi mostlyclean-multi clean-multi \
+	distclean-multi maintainer-clean-multi $(am__append_4)
+noinst_DATA = stmp-targ-include $(am__append_1) $(am__append_2) \
+	$(am__append_3)
+
 # Multilib support variables.
 MULTISRCTOP = 
 MULTIBUILDTOP = 
@@ -375,15 +389,12 @@  AM_MAKEFLAGS = \
 	"DESTDIR=$(DESTDIR)"
 
 FLAGS_TO_PASS = $(AM_MAKEFLAGS)
-@HAVE_DOC_FALSE@DOCDIR = 
-@HAVE_DOC_TRUE@DOCDIR = doc
 SUBDIRS = libc libm \
-	$(DOCDIR) . $(EXTRA_DIRS)
+	. $(EXTRA_DIRS)
 
 tooldir = $(exec_prefix)/$(host_alias)
 toollibdir = $(tooldir)/lib$(MULTISUBDIR)
 AR_FLAGS = rc
-noinst_DATA = stmp-targ-include $(am__append_1) $(am__append_2)
 @USE_LIBTOOL_TRUE@toollib_LTLIBRARIES = libm.la \
 @USE_LIBTOOL_TRUE@	libc.la
 
@@ -449,6 +460,7 @@  MAKEOVERRIDES =
 
 # dejagnu support
 RUNTESTFLAGS = 
+@HAVE_DOC_TRUE@MKDOC = doc/makedoc$(EXEEXT_FOR_BUILD)
 all: _newlib_version.h newlib.h
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
 
@@ -456,7 +468,7 @@  all: _newlib_version.h newlib.h
 .SUFFIXES: .c .lo .o .obj
 am--refresh: Makefile
 	@:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/doc/local.mk $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -479,6 +491,7 @@  Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
 	    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
 	esac;
+$(srcdir)/doc/local.mk:
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	$(SHELL) ./config.status --recheck
@@ -594,10 +607,10 @@  distclean-compile:
 	-rm -f *.tab.c
 
 .c.o:
-	$(COMPILE) -c $<
+	$(COMPILE) -c -o $@ $<
 
 .c.obj:
-	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .c.lo:
 	$(LTCOMPILE) -c -o $@ $<
@@ -1172,10 +1185,7 @@  unidata:
 	cd $(srcdir)/libc/ctype; ./mkunidata -u
 
 # Force makedoc to be built before building info files.
-info-recursive: doc/makedoc
-dvi-recursive: doc/makedoc
-doc/makedoc:
-	cd doc && $(MAKE) all
+info-recursive dvi-recursive: doc/makedoc$(EXEEXT_FOR_BUILD)
 
 # Recursive targets for man and install-man
 man:
@@ -1193,10 +1203,6 @@  install-man:
 	  fi; \
 	done
 
-# Multilib support.
-.PHONY: all-multi check-multi mostlyclean-multi clean-multi distclean-multi \
-	maintainer-clean-multi
-
 all-recursive: all-multi
 check-recursive: check-multi
 mostlyclean-recursive: mostlyclean-multi
@@ -1281,6 +1287,22 @@  check-DEJAGNU: site.exp
 clean-local:
 	-rm -rf targ-include newlib.h _newlib_version.h stamp-*
 
+# We don't use CFLAGS with CC_FOR_BUILD because here CFLAGS will
+# actually be CFLAGS_FOR_TARGET, and in some cases that will include
+# -Os, which CC_FOR_BUILD may not recognize.
+
+@HAVE_DOC_TRUE@$(MKDOC): doc/makedoc.o
+@HAVE_DOC_TRUE@	$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ $<
+
+@HAVE_DOC_TRUE@doc/makedoc.o: doc/makedoc.c
+@HAVE_DOC_TRUE@	$(MKDIR_P) doc
+@HAVE_DOC_TRUE@	$(CC_FOR_BUILD) -g $(CFLAGS_FOR_BUILD) -o $@ -c $<
+
+@HAVE_DOC_TRUE@man-cache:
+@HAVE_DOC_TRUE@	${srcdir}/doc/makedocbook.py --cache
+
+.PHONY: $(PHONY)
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/newlib/configure b/newlib/configure
index 2771fa263102..ce2fb55d2c43 100755
--- a/newlib/configure
+++ b/newlib/configure
@@ -618,6 +618,7 @@  HAVE_LONG_DOUBLE_FALSE
 HAVE_LONG_DOUBLE_TRUE
 libc_cv_cc_loop_to_function
 libc_cv_initfinit_array
+EXEEXT_FOR_BUILD
 CC_FOR_BUILD
 STDIO64_OBJECTLIST
 UNIX_OBJECTLIST
@@ -838,7 +839,6 @@  CPPFLAGS
 CPP'
 ac_subdirs_all='libc
 libm
-doc
 iconvdata'
 
 # Initialize some variables set by options.
@@ -12237,8 +12237,6 @@  subdirs="$subdirs libm"
 
 if test -z "${with_multisubdir}"; then
   have_multisubdir=no
-  subdirs="$subdirs doc"
-
 else
   have_multisubdir=yes
 fi
@@ -12355,7 +12353,37 @@  fi
 
 # Put a plausible default for CC_FOR_BUILD in Makefile.
 if test -z "$CC_FOR_BUILD"; then
-  CC_FOR_BUILD=gcc
+  if test "x$cross_compiling" = "xno"; then
+    CC_FOR_BUILD='$(CC)'
+  else
+    CC_FOR_BUILD=gcc
+  fi
+fi
+
+
+# Also set EXEEXT_FOR_BUILD.
+if test "x$cross_compiling" = "xno"; then
+  EXEEXT_FOR_BUILD='$(EXEEXT)'
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for build system executable suffix" >&5
+$as_echo_n "checking for build system executable suffix... " >&6; }
+if ${newlib_cv_build_exeext+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > ac_c_test.c << 'EOF'
+int main() {
+/* Nothing needed here */
+}
+EOF
+    ${CC_FOR_BUILD} -o ac_c_test am_c_test.c 1>&5 2>&5
+    newlib_cv_build_exeext=`echo ac_c_test.* | grep -v ac_c_test.c | sed -e s/ac_c_test//`
+    rm -f ac_c_test*
+    test x"${newlib_cv_build_exeext}" = x && newlib_cv_build_exeext=no
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $newlib_cv_build_exeext" >&5
+$as_echo "$newlib_cv_build_exeext" >&6; }
+  EXEEXT_FOR_BUILD=""
+  test x"${newlib_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${newlib_cv_build_exeext}
 fi
 
 
diff --git a/newlib/configure.ac b/newlib/configure.ac
index 67597bb48c4a..49a1b5fddc89 100644
--- a/newlib/configure.ac
+++ b/newlib/configure.ac
@@ -303,7 +303,6 @@  AC_CONFIG_SUBDIRS(libm)
 
 if test -z "${with_multisubdir}"; then
   have_multisubdir=no
-  AC_CONFIG_SUBDIRS(doc)
 else
   have_multisubdir=yes
 fi
@@ -398,10 +397,33 @@  AC_SUBST(STDIO64_OBJECTLIST)
 
 # Put a plausible default for CC_FOR_BUILD in Makefile.
 if test -z "$CC_FOR_BUILD"; then
-  CC_FOR_BUILD=gcc
+  if test "x$cross_compiling" = "xno"; then
+    CC_FOR_BUILD='$(CC)'
+  else
+    CC_FOR_BUILD=gcc
+  fi
 fi
 AC_SUBST(CC_FOR_BUILD)
 
+# Also set EXEEXT_FOR_BUILD.
+if test "x$cross_compiling" = "xno"; then
+  EXEEXT_FOR_BUILD='$(EXEEXT)'
+else
+  AC_CACHE_CHECK([for build system executable suffix], newlib_cv_build_exeext,
+    [cat > ac_c_test.c << 'EOF'
+int main() {
+/* Nothing needed here */
+}
+EOF
+    ${CC_FOR_BUILD} -o ac_c_test am_c_test.c 1>&5 2>&5
+    newlib_cv_build_exeext=`echo ac_c_test.* | grep -v ac_c_test.c | sed -e s/ac_c_test//`
+    rm -f ac_c_test*
+    test x"${newlib_cv_build_exeext}" = x && newlib_cv_build_exeext=no])
+  EXEEXT_FOR_BUILD=""
+  test x"${newlib_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${newlib_cv_build_exeext}
+fi
+AC_SUBST(EXEEXT_FOR_BUILD)
+
 if test "${newlib_elix_level}" -gt "0"; then
 AC_DEFINE_UNQUOTED(_ELIX_LEVEL,${newlib_elix_level})
 fi
diff --git a/newlib/doc/Makefile.am b/newlib/doc/Makefile.am
deleted file mode 100644
index dbebfcc9a94b..000000000000
--- a/newlib/doc/Makefile.am
+++ /dev/null
@@ -1,28 +0,0 @@ 
-## Process this file with automake to generate Makefile.in
-
-AUTOMAKE_OPTIONS = cygnus
-
-# We can't use noinst_PROGRAMS, because automake will add $(EXEEXT).
-noinst_DATA = makedoc
-
-MKDOC = makedoc$(EXEEXT_FOR_BUILD)
-
-# We don't use CFLAGS with CC_FOR_BUILD because here CFLAGS will
-# actually be CFLAGS_FOR_TARGET, and in some cases that will include
-# -Os, which CC_FOR_BUILD may not recognize.
-
-$(MKDOC): makedoc.o
-	$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $(MKDOC) makedoc.o
-
-makedoc.o: makedoc.c
-	$(CC_FOR_BUILD) -g $(CFLAGS_FOR_BUILD) -c $(srcdir)/makedoc.c
-
-ACLOCAL_AMFLAGS = -I .. -I ../..
-CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
-
-man:
-
-man-cache:
-	${srcdir}/makedocbook.py --cache
-
-.PHONY: man-cache
diff --git a/newlib/doc/Makefile.in b/newlib/doc/Makefile.in
deleted file mode 100644
index 46b0869c7ab3..000000000000
--- a/newlib/doc/Makefile.in
+++ /dev/null
diff --git a/newlib/doc/aclocal.m4 b/newlib/doc/aclocal.m4
deleted file mode 100644
index 782a9e5ded50..000000000000
--- a/newlib/doc/aclocal.m4
+++ /dev/null
diff --git a/newlib/doc/configure b/newlib/doc/configure
deleted file mode 100755
index 68a99892611d..000000000000
--- a/newlib/doc/configure
+++ /dev/null
diff --git a/newlib/doc/configure.ac b/newlib/doc/configure.ac
deleted file mode 100644
index 28428a9082cb..000000000000
--- a/newlib/doc/configure.ac
+++ /dev/null
@@ -1,43 +0,0 @@ 
-dnl This is the newlib/doc configure.in file.
-dnl Process this file with autoconf to produce a configure script.
-
-AC_PREREQ(2.59)
-AC_INIT([newlib],[NEWLIB_VERSION])
-AC_CONFIG_SRCDIR([makedoc.c])
-
-dnl Can't be done in NEWLIB_CONFIGURE because that confuses automake. 
-AC_CONFIG_AUX_DIR(../..)
-
-NEWLIB_CONFIGURE(..)
-
-# Put a plausible default for CC_FOR_BUILD in Makefile.
-if test -z "$CC_FOR_BUILD"; then
-  if test "x$cross_compiling" = "xno"; then
-    CC_FOR_BUILD='$(CC)'
-  else
-    CC_FOR_BUILD=gcc
-  fi
-fi
-AC_SUBST(CC_FOR_BUILD)
-
-# Also set EXEEXT_FOR_BUILD.
-if test "x$cross_compiling" = "xno"; then
-  EXEEXT_FOR_BUILD='$(EXEEXT)'
-else
-  AC_CACHE_CHECK([for build system executable suffix], newlib_cv_build_exeext,
-    [cat > ac_c_test.c << 'EOF'
-int main() {
-/* Nothing needed here */
-}
-EOF
-    ${CC_FOR_BUILD} -o ac_c_test am_c_test.c 1>&5 2>&5
-    newlib_cv_build_exeext=`echo ac_c_test.* | grep -v ac_c_test.c | sed -e s/ac_c_test//`
-    rm -f ac_c_test*
-    test x"${newlib_cv_build_exeext}" = x && newlib_cv_build_exeext=no])
-  EXEEXT_FOR_BUILD=""
-  test x"${newlib_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${newlib_cv_build_exeext}
-fi
-AC_SUBST(EXEEXT_FOR_BUILD)
-
-AC_CONFIG_FILES([Makefile])
-AC_OUTPUT
diff --git a/newlib/doc/local.mk b/newlib/doc/local.mk
new file mode 100644
index 000000000000..64083c3dd600
--- /dev/null
+++ b/newlib/doc/local.mk
@@ -0,0 +1,20 @@ 
+# We can't use noinst_PROGRAMS, because automake will add $(EXEEXT).
+noinst_DATA += doc/makedoc
+
+MKDOC = doc/makedoc$(EXEEXT_FOR_BUILD)
+
+# We don't use CFLAGS with CC_FOR_BUILD because here CFLAGS will
+# actually be CFLAGS_FOR_TARGET, and in some cases that will include
+# -Os, which CC_FOR_BUILD may not recognize.
+
+$(MKDOC): doc/makedoc.o
+	$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ $<
+
+doc/makedoc.o: doc/makedoc.c
+	$(MKDIR_P) doc
+	$(CC_FOR_BUILD) -g $(CFLAGS_FOR_BUILD) -o $@ -c $<
+
+man-cache:
+	${srcdir}/doc/makedocbook.py --cache
+
+PHONY += man-cache