From 23db04b702434dbead62151ad78b711c46019638 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 14 Jan 2002 00:29:16 +0000 Subject: [PATCH] 2002-01-13 Tom Tromey 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 For PR automake/288: * tests/Makefile.am (TESTS): Added ansi6.test. * tests/ansi6.test: New file. --- ChangeLog | 14 ++++++++++++ Makefile.in | 2 +- automake.in | 23 +++++++++++++------- tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/ansi6.test | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 87 insertions(+), 9 deletions(-) create mode 100755 tests/ansi6.test diff --git a/ChangeLog b/ChangeLog index 8da69483..c4e465d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2002-01-13 Tom Tromey + + 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 + + For PR automake/288: + * tests/Makefile.am (TESTS): Added ansi6.test. + * tests/ansi6.test: New file. + 2002-01-13 Tom Tromey For PR automake/287: diff --git a/Makefile.in b/Makefile.in index afc74d60..57167515 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 \ diff --git a/automake.in b/automake.in index 9ff0773b..5bef8344 100755 --- a/automake.in +++ b/automake.in @@ -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 diff --git a/tests/Makefile.am b/tests/Makefile.am index 0ccf4aad..8af8343b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -24,6 +24,7 @@ ansi2.test \ ansi3.test \ ansi4.test \ ansi5.test \ +ansi6.test \ ar.test \ asm.test \ auxdir.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 082dbf5f..ccd4d770 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -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 index 00000000..61775177 --- /dev/null +++ b/tests/ansi6.test @@ -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 + +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 -- 2.43.5