2002-01-13 Tom Tromey <tromey@redhat.com>
authorTom Tromey <tromey@redhat.com>
Mon, 14 Jan 2002 00:29:31 +0000 (00:29 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 14 Jan 2002 00:29:31 +0000 (00:29 +0000)
For PR automake/288:
* automake.in (lang_c_rewrite): Set value for de_ansi_files entry
to directory.
(lang_c_finish): Likewise.  Also, use directory information from
de_ansi_files.

2002-01-13  Kevin Ryde  <user42@zip.com.au>

For PR automake/288:
* tests/Makefile.am (TESTS): Added ansi6.test.
* tests/ansi6.test: New file.

ChangeLog
Makefile.in
automake.in
tests/Makefile.am
tests/Makefile.in
tests/ansi6.test [new file with mode: 0755]

index 8da6948..c4e465d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2002-01-13  Tom Tromey  <tromey@redhat.com>
 
+       For PR automake/288:
+       * automake.in (lang_c_rewrite): Set value for de_ansi_files entry
+       to directory.
+       (lang_c_finish): Likewise.  Also, use directory information from
+       de_ansi_files.
+
+2002-01-13  Kevin Ryde  <user42@zip.com.au>
+
+       For PR automake/288:
+       * tests/Makefile.am (TESTS): Added ansi6.test.
+       * tests/ansi6.test: New file.
+
+2002-01-13  Tom Tromey  <tromey@redhat.com>
+
        For PR automake/287:
        * lib/am/distdir.am (distdir): Use `$$list' trick when looping
        over subdirs.
index afc74d6..5716751 100644 (file)
@@ -375,7 +375,7 @@ distdir: $(DISTFILES)
            || exit 1; \
          fi; \
        done
-       for subdir in $(SUBDIRS); do \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
          if test "$$subdir" = .; then :; else \
            test -d $(distdir)/$$subdir \
            || mkdir $(distdir)/$$subdir \
index 9ff0773..5bef834 100755 (executable)
@@ -585,8 +585,10 @@ my $use_dependencies;
 # This is a list of all targets to run during "make dist".
 my @dist_targets;
 
-# Keys in this hash are the basenames of files which must depend
-# on ansi2knr.
+# Keys in this hash are the basenames of files which must depend on
+# ansi2knr.  Values are either the empty string, or the directory in
+# which the ANSI source file appears; the directory must have a
+# trailing `/'.
 my %de_ansi_files;
 
 # This maps the source extension of a suffix rule to its
@@ -5164,7 +5166,9 @@ sub lang_c_rewrite
        require_conf_file ("$am_file.am", FOREIGN, 'compile');
     }
 
-    $de_ansi_files{$base} = 1;
+    $de_ansi_files{$base} = (($directory eq '.' || $directory eq '')
+                            ? ''
+                            : "$directory/");
     return $r;
 }
 
@@ -5271,7 +5275,9 @@ sub lang_c_finish
     {
        if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
        {
-           $de_ansi_files{$1} = 1;
+           $de_ansi_files{$1} = (($relative_dir eq '.' || $relative_dir eq '')
+                                 ? ''
+                                 : "$relative_dir/");
        }
     }
 
@@ -5287,11 +5293,12 @@ sub lang_c_finish
            # dir (because these files might be auto-generated.  But
            # we can't use $< -- some makes only define $< during a
            # suffix rule.
-           $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
+           my $ansfile = $de_ansi_files{$base} . $base . '.c';
+           $output_rules .= ($base . "_.c: $ansfile \$(ANSI2KNR)\n\t"
                              . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
-                             . '`if test -f $(srcdir)/' . $base . '.c'
-                             . '; then echo $(srcdir)/' . $base . '.c'
-                             . '; else echo ' . $base . '.c; fi` '
+                             . '`if test -f $(srcdir)/' . $ansfile
+                             . '; then echo $(srcdir)/' . $ansfile
+                             . '; else echo ' . $ansfile . '; fi` '
                              . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
                              . '| $(ANSI2KNR) > ' . $base . "_.c"
                              # If ansi2knr fails then we shouldn't
index 0ccf4aa..8af8343 100644 (file)
@@ -24,6 +24,7 @@ ansi2.test \
 ansi3.test \
 ansi4.test \
 ansi5.test \
+ansi6.test \
 ar.test \
 asm.test \
 auxdir.test \
index 082dbf5..ccd4d77 100644 (file)
@@ -96,6 +96,7 @@ ansi2.test \
 ansi3.test \
 ansi4.test \
 ansi5.test \
+ansi6.test \
 ar.test \
 asm.test \
 auxdir.test \
diff --git a/tests/ansi6.test b/tests/ansi6.test
new file mode 100755 (executable)
index 0000000..6177517
--- /dev/null
@@ -0,0 +1,55 @@
+#! /bin/sh
+
+# Check ansi2knr on a source file in subdirectory.
+# From Kevin Ryde.
+
+required=gcc
+. $srcdir/defs || exit 1
+
+cat > configure.in << 'END'
+AC_INIT(ansi6, 1.0)
+AM_INIT_AUTOMAKE
+AC_PROG_CC
+AM_C_PROTOTYPES
+AC_EXEEXT
+AC_OBJEXT
+AC_CONFIG_FILES(Makefile)
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = ansi2knr
+bin_PROGRAMS = hello
+hello_SOURCES = hello.c sub/dir.c
+END
+
+cat > hello.c << 'END'
+#include <stdio.h>
+
+extern int foo ();
+
+int
+main (int argc, char **argv)
+{
+   printf ("%d\n", foo ());
+}
+END
+
+mkdir sub
+
+cat > sub/dir.c << 'END'
+int
+foo ()
+{
+   return 23;
+}
+END
+
+set -e
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure am_cv_prog_cc_stdc=no
+$MAKE