Rebuild files listed in AC_OUTPUT
diff --git a/ChangeLog b/ChangeLog
index 0efde9e..533f20d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 Wed Feb  7 18:00:29 1996  Tom Tromey  <tromey@creche.cygnus.com>
 
+	* Makefile.am (automake): Removed.
+	(DIST_OTHER): Removed.
+
 	* automake.in (handle_source_transform): All dep_files are
 	relative to $(srcdir).
 	(handle_libraries): Ditto.
@@ -11,6 +14,7 @@
 	Give error if appropriate install macro not seen.
 	(handle_subdirs): Ensure $seen_gettext before requiring
 	gettext-specific files.
+	(handle_configure): Automatically rebuild 
 
         From Jim Meyering:
 	* automake.in (handle_source_transform): Use \W when quoting
diff --git a/Makefile.am b/Makefile.am
index 77088aa..471b31e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,8 +20,6 @@
 COPYING INSTALL install-sh mdate-sh mkinstalldirs texinfo.tex \
 config.guess config.sub
 
-DIST_OTHER = automake.in
-
 # Gross.
 DIST_SUBDIRS = samples/cpio/*Makefile.am
 
@@ -48,9 +46,6 @@
 	  perl4.036 -c -w automake; \
 	else :; fi
 
-automake: automake.in
-	CONFIG_FILES=$@ CONFIG_HEADERS= ./config.status
-
 # Tag before making distribution.  Also, don't make a distribution if
 # checks fail.  Also, make sure the NEWS file is up-to-date.
 cvs-dist: maintainer-check
diff --git a/Makefile.in b/Makefile.in
index 356bd35..b8dbf40 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -58,8 +58,6 @@
 COPYING INSTALL install-sh mdate-sh mkinstalldirs texinfo.tex \
 config.guess config.sub
 
-DIST_OTHER = automake.in
-
 # Gross.
 DIST_SUBDIRS = samples/cpio/*Makefile.am
 
@@ -80,9 +78,9 @@
 DATA = $(pkgdata_DATA)
 
 DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \
-Makefile.in NEWS README THANKS TODO aclocal.m4 config.guess config.sub \
-configure configure.in install-sh mdate-sh mkinstalldirs stamp-vti \
-texinfo.tex version.texi
+Makefile.in NEWS README THANKS TODO aclocal.m4 automake.in config.guess \
+config.sub configure configure.in install-sh mdate-sh mkinstalldirs \
+stamp-vti texinfo.tex version.texi
 
 
 PACKAGE = @PACKAGE@
@@ -106,6 +104,8 @@
 	./config.status --recheck
 $(srcdir)/configure: configure.in $(ACLOCAL)
 	cd $(srcdir) && autoconf
+automake: $(top_builddir)/config.status automake.in
+	cd $(top_srcdir) && CONFIG_FILES=$@ CONFIG_HEADERS= ./config.status
 
 mostlyclean-binSCRIPTS:
 
@@ -322,9 +322,6 @@
 	  perl4.036 -c -w automake; \
 	else :; fi
 
-automake: automake.in
-	CONFIG_FILES=$@ CONFIG_HEADERS= ./config.status
-
 # Tag before making distribution.  Also, don't make a distribution if
 # checks fail.  Also, make sure the NEWS file is up-to-date.
 cvs-dist: maintainer-check
diff --git a/NEWS b/NEWS
index 78237d8..4e9ad34 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@
 * Allow hierarchies deeper than 2.  From Gord Matzigkeit.
 * HEADERS variable no longer needed; now can put .h files directly into
   foo_SOURCES variable.
+* Automake automatically rebuilds files listed in AC_OUTPUT.  The
+  corresponding ".in" files are included in the distribution.
 
 New in 0.28:
 * Added --gnu and --gnits options
diff --git a/TODO b/TODO
index b425968..2024810 100644
--- a/TODO
+++ b/TODO
@@ -2,8 +2,6 @@
 * Must rewrite am_install_var.  Should break into multiple functions.
   This will allow the callers to be a little smarter.
 * Rewrite clean targets.
-* Use @other_input_files to automate regeneration.  Must do dirname
-  canonicalization
 
 Handle MAINT_CHARSET.  Use recode in dist target.  Handle dist-zoo and
 dist-zip.
diff --git a/automake.in b/automake.in
index 9f998ba..04d5b48 100755
--- a/automake.in
+++ b/automake.in
@@ -1141,6 +1141,29 @@
 	if $config_name;
     $contents{'CONFIG_HEADER'} = "${top_builddir}/${config_name}"
 	if $config_name;
+
+    # Now look for other files in this directory which must be remade
+    # by config.status, and generate rules for them.
+    local ($file, $local);
+    foreach $file (@other_input_files)
+    {
+	# Skip files not in this directory, any Makefile, and the
+	# config header.  These last two must be handled specially.
+	next unless &dirname ($file) eq $relative_dir;
+	next if $file eq $top_builddir . '/' . $config_name;
+	($local = $file) =~ s/^.*\///;
+	next if $local eq 'Makefile';
+
+	# FIXME support ":" syntax of AC_OUTPUT here.
+	$output_rules .= ($local . ': '
+			  . '$(top_builddir)/config.status ' . $local . ".in\n"
+			  . "\t"
+			  . 'cd $(top_srcdir) && CONFIG_FILES='
+			  . ($relative_dir eq '.' ? '' : '$(subdir)/')
+			  . '$@ CONFIG_HEADERS= ./config.status'
+			  . "\n");
+	&require_file ($NORMAL, $local . '.in');
+    }
 }
 
 # Handle C headers.
diff --git a/lib/am/Makefile.am b/lib/am/Makefile.am
index 77088aa..471b31e 100644
--- a/lib/am/Makefile.am
+++ b/lib/am/Makefile.am
@@ -20,8 +20,6 @@
 COPYING INSTALL install-sh mdate-sh mkinstalldirs texinfo.tex \
 config.guess config.sub
 
-DIST_OTHER = automake.in
-
 # Gross.
 DIST_SUBDIRS = samples/cpio/*Makefile.am
 
@@ -48,9 +46,6 @@
 	  perl4.036 -c -w automake; \
 	else :; fi
 
-automake: automake.in
-	CONFIG_FILES=$@ CONFIG_HEADERS= ./config.status
-
 # Tag before making distribution.  Also, don't make a distribution if
 # checks fail.  Also, make sure the NEWS file is up-to-date.
 cvs-dist: maintainer-check