Allow config.h in subdir; other config.h cleanups
authorTom Tromey <tromey@redhat.com>
Fri, 20 Sep 1996 15:55:22 +0000 (15:55 +0000)
committerTom Tromey <tromey@redhat.com>
Fri, 20 Sep 1996 15:55:22 +0000 (15:55 +0000)
15 files changed:
ChangeLog
TODO
automake.in
automake.texi
clean.am
lib/am/clean.am
lib/am/remake-hdr.am
lib/am/tags.am
remake-hdr.am
tags.am
tests/ChangeLog
tests/Makefile.am
tests/Makefile.in
tests/confsub.test [new file with mode: 0755]
version.texi

index 8661b78..2bd647b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+Fri Sep 20 09:06:37 1996  Tom Tromey  <tromey@creche.cygnus.com>
+
+       * tags.am (TAGS): Minor cleanup.
+
+       * clean.am (distclean-generic): Don't remove CONFIG_HEADER.
+
+       * remake-hdr.am (mostlyclean-hdr, clean-hdr, distclean-hdr,
+       maintainer-clean-hdr): New targets.
+
+       * automake.in (handle_configure): Define CONFIG_HEADER correctly
+       when it is in current directory.
+       (handle_configure): Push "hdr" on @clean.
+
+       * remake-hdr.am (stamp-h): Run config.status in top_builddir.
+       ($(srcdir)/stamp-h.in): Run autoheader in top_srcdir.
+
+       * automake.in (scan_configure): Check for install.sh here.
+       (basename): New sub.
+       (handle_configure): Handle case where config.h is in subdir.
+       (handle_configure): Make stamp-in.h for user if it doesn't already
+       exist.
+       (touch): New sub.
+
 Tue Sep 17 23:35:14 1996  Tom Tromey  <tromey@creche.cygnus.com>
 
        * Makefile.am (EXTRA_DIST): Include pkgdata_DATA.
diff --git a/TODO b/TODO
index 086285a..89aad9c 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,9 +1,9 @@
 Priorities for release:
   [ none ]
 
-support config.h in subdir
+must move CONFIG_HEADER from tags.am... allow it to work in subdir.
 
-consider auto-creating stamp-h.in for user
+if @...@ substitution in _PROGRAMS, then require EXTRA_PROGRAMS!
 
 take diff-n-query code from libit
 
@@ -288,9 +288,6 @@ some support for this.  Here are some of the issues:
     * can do this by looking at subdirs, seeing configure.in
       and auto-running Automake there
 
-dejagnu support:
-* use RUNTEST_FOR_TARGET in some cases?
-
 These can both be handled via dist-hook:
 . Consider supporting guile-style PLUGIN directories automatically?
 . Consider allowing eg "foo/bar" to appear in EXTRA_DIST, and generating
@@ -353,6 +350,8 @@ This is insufficiently clear
 must document the targets required for integration with
 non-automake-using subdirs
 
+use of (eg) EXTRA_PROGRAMS is not very clear right now
+
 ================================================================
 
 Libraries:
index 10a49b6..33bb046 100755 (executable)
@@ -1983,48 +1983,43 @@ sub handle_configure
                                                        . $strictness_name
                                                        . '/g',
                                                        'remake');
+       $top_reldir = '';
+    }
 
-       &am_error
-           ("\`install.sh' is an anachronism; use \`install-sh' instead")
-               if -f $relative_dir . '/install.sh';
-
-       # If we have a configure header, require it.
-       if ($config_header)
-       {
-           # FIXME: this restriction should be lifted.
-           # FIXME: first see if it is even needed as-is.
-           &am_conf_line_error ($config_header_line,
-                                "argument to AC_CONFIG_HEADER contains \`/'\n")
-               if ($config_header =~ /\//);
-
-           &require_file_with_conf_line ($config_header_line,
-                                         $FOREIGN, $config_header);
-
-           # Header defined and in this directory.
-           if (-f 'acconfig.h')
-           {
-               &define_variable ("ACCONFIG", "acconfig.h");
-               &push_dist_common ('acconfig.h');
-           }
-           if (-f $config_name . '.top')
-           {
-               &define_variable ("CONFIG_TOP", "${config_name}.top");
-               &push_dist_common ($config_name . '.top');
-           }
-           if (-f $config_name . '.bot')
-           {
-               &define_variable ("CONFIG_BOT", "${config_name}.bot");
-               &push_dist_common ($config_name . '.bot');
-           }
+    # If we have a configure header, require it.
+    if ($config_header && $relative_dir eq &dirname ($config_header))
+    {
+       local ($ch_sans_dir) = &basename ($config_header);
+       local ($cn_sans_dir) = &basename ($config_name);
 
-           &require_file_with_conf_line ($config_header_line, $FOREIGN,
-                                         'stamp-h.in');
+       &require_file_with_conf_line ($config_header_line,
+                                     $FOREIGN, $ch_sans_dir);
 
-           $output_rules .= &file_contents ('remake-hdr');
-           &define_variable ("CONFIG_HEADER_IN", "${config_header}");
+       # Header defined and in this directory.
+       if (-f $relative_dir . '/acconfig.h')
+       {
+           &define_variable ("ACCONFIG", "acconfig.h");
+           &push_dist_common ('acconfig.h');
+       }
+       if (-f $config_name . '.top')
+       {
+           &define_variable ("CONFIG_TOP", "${cn_sans_dir}.top");
+           &push_dist_common ($cn_sans_dir . '.top');
+       }
+       if (-f $config_name . '.bot')
+       {
+           &define_variable ("CONFIG_BOT", "${cn_sans_dir}.bot");
+           &push_dist_common ($cn_sans_dir . '.bot');
        }
 
-       $top_reldir = '';
+       &touch ($relative_dir . '/stamp-h.in');
+       &require_file_with_conf_line ($config_header_line, $FOREIGN,
+                                     'stamp-h.in');
+
+       $output_rules .= &file_contents ('remake-hdr');
+       push (@clean, 'hdr');
+       &push_phony_cleaners ('hdr');
+       &define_variable ("CONFIG_HEADER_IN", "${ch_sans_dir}");
     }
 
     # Set location of mkinstalldirs.
@@ -2041,9 +2036,19 @@ sub handle_configure
                    "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
        if &variable_defined ('CONFIG_HEADER');
 
-    # Generate CONFIG_HEADER define.
-    &define_variable ("CONFIG_HEADER", "${top_builddir}/${config_name}")
-       if $config_name;
+    if ($config_name)
+    {
+       # Generate CONFIG_HEADER define.
+       if ($relative_dir eq &dirname ($config_name))
+       {
+           &define_variable ("CONFIG_HEADER", &basename ($config_name));
+       }
+       else
+       {
+           &define_variable ("CONFIG_HEADER",
+                             "${top_builddir}/${config_name}");
+       }
+    }
 
     # Now look for other files in this directory which must be remade
     # by config.status, and generate rules for them.
@@ -2853,6 +2858,8 @@ sub scan_configure
     # the file-finding machinery works.
     local ($relative_dir) = '.';
     &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs');
+    &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
+        if -f $config_aux_path[0] . '/install.sh';
 }
 
 ################################################################
@@ -3934,6 +3941,25 @@ sub dirname
     return $sub;
 }
 
+# Return file name of a file.
+sub basename
+{
+    local ($file) = @_;
+    local ($sub);
+
+    ($sub = $file) =~s,^.*/+,,g;
+    return $sub;
+}
+
+# Touch a file.
+sub touch
+{
+    local ($file) = @_;
+
+    open (TOUCH, ">> $file");
+    close (TOUCH);
+}
+
 ################################################################
 
 # Print an error message and set exit status.
index 7664c8f..7e83dfc 100644 (file)
@@ -1402,7 +1402,9 @@ current directory, are automatically included.  This list is printed by
 
 Still, sometimes there are files which must be distributed, but which
 are not covered in the automatic rules.  These files should be listed in
-the @code{EXTRA_DIST} variable.
+the @code{EXTRA_DIST} variable.  Note that @code{EXTRA_DIST} can only
+handle files in the current directory; files in other directories will
+cause @code{make dist} runtime failures.
 @vindex EXTRA_DIST
 
 Occasionally it is useful to be able to change the distribution before
index 387d245..165f115 100644 (file)
--- a/clean.am
+++ b/clean.am
@@ -27,7 +27,7 @@ clean-generic:
 
 distclean-generic:
        rm -f Makefile $(DISTCLEANFILES)
-       rm -f config.cache config.log $(CONFIG_HEADER) stamp-h
+       rm -f config.cache config.log stamp-h
        test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
 
 maintainer-clean-generic:
index 387d245..165f115 100644 (file)
@@ -27,7 +27,7 @@ clean-generic:
 
 distclean-generic:
        rm -f Makefile $(DISTCLEANFILES)
-       rm -f config.cache config.log $(CONFIG_HEADER) stamp-h
+       rm -f config.cache config.log stamp-h
        test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
 
 maintainer-clean-generic:
index f7fad83..efc60c7 100644 (file)
 ## 02111-1307, USA.
 $(CONFIG_HEADER): stamp-h
 stamp-h: $(CONFIG_HEADER_IN) config.status
-       CONFIG_FILES= CONFIG_HEADERS=$(CONFIG_HEADER) ./config.status
+       cd $(top_builddir) \
+         && CONFIG_FILES= CONFIG_HEADERS=$(CONFIG_HEADER) ./config.status
        @echo timestamp > stamp-h
 $(srcdir)/$(CONFIG_HEADER_IN): @MAINT@stamp-h.in
 $(srcdir)/stamp-h.in: configure.in $(ACLOCAL) $(ACCONFIG) $(CONFIG_TOP) $(CONFIG_BOT)
-       cd $(srcdir) && autoheader
+       cd $(top_srcdir) && autoheader
        echo timestamp > $(srcdir)/stamp-h.in
+
+mostlyclean-hdr:
+
+clean-hdr:
+
+distclean-hdr:
+       rm -f $(CONFIG_HEADER)
+
+maintainer-clean-hdr:
index 68e2bd5..6da6509 100644 (file)
@@ -28,9 +28,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) $(CONFIG_HEADER) \
        tags=; \
        here=`pwd`; \
        for subdir in $(SUBDIRS); do \
-         test -f $$subdir/TAGS && { \
-           tags="$$tags -i $$here/$$subdir/TAGS"; \
-         } \
+         test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
        done; \
 ## Make sure we have something to run etags on.
        test -z "$(ETAGS_ARGS)$(CONFIG_HEADER)$(SOURCES)$(HEADERS)$$tags" \
index f7fad83..efc60c7 100644 (file)
 ## 02111-1307, USA.
 $(CONFIG_HEADER): stamp-h
 stamp-h: $(CONFIG_HEADER_IN) config.status
-       CONFIG_FILES= CONFIG_HEADERS=$(CONFIG_HEADER) ./config.status
+       cd $(top_builddir) \
+         && CONFIG_FILES= CONFIG_HEADERS=$(CONFIG_HEADER) ./config.status
        @echo timestamp > stamp-h
 $(srcdir)/$(CONFIG_HEADER_IN): @MAINT@stamp-h.in
 $(srcdir)/stamp-h.in: configure.in $(ACLOCAL) $(ACCONFIG) $(CONFIG_TOP) $(CONFIG_BOT)
-       cd $(srcdir) && autoheader
+       cd $(top_srcdir) && autoheader
        echo timestamp > $(srcdir)/stamp-h.in
+
+mostlyclean-hdr:
+
+clean-hdr:
+
+distclean-hdr:
+       rm -f $(CONFIG_HEADER)
+
+maintainer-clean-hdr:
diff --git a/tags.am b/tags.am
index 68e2bd5..6da6509 100644 (file)
--- a/tags.am
+++ b/tags.am
@@ -28,9 +28,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) $(CONFIG_HEADER) \
        tags=; \
        here=`pwd`; \
        for subdir in $(SUBDIRS); do \
-         test -f $$subdir/TAGS && { \
-           tags="$$tags -i $$here/$$subdir/TAGS"; \
-         } \
+         test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
        done; \
 ## Make sure we have something to run etags on.
        test -z "$(ETAGS_ARGS)$(CONFIG_HEADER)$(SOURCES)$(HEADERS)$$tags" \
index 3239930..b14501e 100644 (file)
@@ -1,3 +1,7 @@
+Fri Sep 20 09:39:27 1996  Tom Tromey  <tromey@creche.cygnus.com>
+
+       * confsub.test: New file.
+
 Mon Sep 16 00:05:52 1996  Tom Tromey  <tromey@creche.cygnus.com>
 
        * spell2.test: New file.
index 1207bbe..102e9b9 100644 (file)
@@ -14,6 +14,7 @@ error.test colon.test vtexi2.test tags.test comment.test libfiles.test \
 man.test info.test obsolete.test lex.test scripts.test subdir2.test \
 exsource.test canon4.test dup.test defun.test cxxlink.test cxxnoc.test \
 order.test libobj2.test interp.test alllib.test block.test libobj3.test \
-gnits.test interp2.test colneq.test implicit.test spell.test spell2.test
+gnits.test interp2.test colneq.test implicit.test spell.test spell2.test \
+confsub.test
 
 EXTRA_DIST = defs $(TESTS)
index 25cf3a7..c940a5f 100644 (file)
@@ -52,7 +52,8 @@ error.test colon.test vtexi2.test tags.test comment.test libfiles.test \
 man.test info.test obsolete.test lex.test scripts.test subdir2.test \
 exsource.test canon4.test dup.test defun.test cxxlink.test cxxnoc.test \
 order.test libobj2.test interp.test alllib.test block.test libobj3.test \
-gnits.test interp2.test colneq.test implicit.test spell.test spell2.test
+gnits.test interp2.test colneq.test implicit.test spell.test spell2.test \
+confsub.test
 
 EXTRA_DIST = defs $(TESTS)
 mkinstalldirs = $(top_srcdir)/mkinstalldirs
diff --git a/tests/confsub.test b/tests/confsub.test
new file mode 100755 (executable)
index 0000000..0d935d4
--- /dev/null
@@ -0,0 +1,28 @@
+#! /bin/sh
+
+# Test to make sure config.h can be in subdir.
+
+. $srcdir/defs || exit 1
+
+cat > configure.in << 'END'
+AC_PROG_MAKE_SET
+AC_CONFIG_HEADER(subdir/config.h)
+PACKAGE=nonesuch
+VERSION=nonesuch
+AC_ARG_PROGRAM
+AM_PROG_INSTALL
+AC_OUTPUT(Makefile subdir/Makefile)
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = subdir
+END
+
+mkdir subdir
+cat > subdir/Makefile.am << 'END'
+bin_PROGRAMS = fred
+END
+
+: > subdir/config.h.in
+
+$AUTOMAKE
index cc88283..3513c74 100644 (file)
@@ -1,3 +1,3 @@
-@set UPDATED 17 September 1996
+@set UPDATED 20 September 1996
 @set EDITION 1.1f
 @set VERSION 1.1f