From fb4574a6108a97eae581a78d8ff4241886e8b12c Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 9 Nov 2001 17:17:45 +0000 Subject: [PATCH] Fix for distcommon2.test: * automake.in (automake_needs_to_reprocess_all_files): New variable. ("main"): Process all Makefiles a second time if $automake_needs_to_reprocess_all_files is set. (maybe_push_required_file): Return 1 or 0 whether the file is pushed or not. (require_file_internal): Set $automake_needs_to_reprocess_all_files if an added file can't be pushed. * test/distcommon2.test: New file. * test/Makefile.am (TESTS): Add distcommon2.test. From Pavel Roskin. --- ChangeLog | 16 +++++++++++ NEWS | 1 + automake.in | 61 ++++++++++++++++++++++++++++++++++-------- tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/distcommon2.test | 53 ++++++++++++++++++++++++++++++++++++ 6 files changed, 122 insertions(+), 11 deletions(-) create mode 100755 tests/distcommon2.test diff --git a/ChangeLog b/ChangeLog index 3bb5964c..eb022a13 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2001-11-09 Alexandre Duret-Lutz + + Fix for distcommon2.test: + * automake.in (automake_needs_to_reprocess_all_files): New + variable. + ("main"): Process all Makefiles a second time if + $automake_needs_to_reprocess_all_files is set. + (maybe_push_required_file): Return 1 or 0 whether the file is + pushed or not. + (require_file_internal): Set $automake_needs_to_reprocess_all_files + if an added file can't be pushed. + + * test/distcommon2.test: New file. + * test/Makefile.am (TESTS): Add distcommon2.test. + From Pavel Roskin. + 2001-11-09 Alexandre Duret-Lutz * automake.in (exec_dir_p): Remove. Replace by... diff --git a/NEWS b/NEWS index 947bd82e..8c8dfe64 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ New in 1.5a: * Fixed CDPATH portability problems, in particular for MacOS X. * Fixed handling of nobase_ targets. * Fixed support of implicit rules leading to .lo objects. +* Fixed late inclusion of --add-missing files (e.g. depcomp) in DIST_COMMON New in 1.5: * Support for `configure.ac'. diff --git a/automake.in b/automake.in index 0bf5349f..f9d14568 100755 --- a/automake.in +++ b/automake.in @@ -443,6 +443,11 @@ my %required_targets = 'install-man' => 1, ); +# This is set to 1 when Automake needs to be run again. +# (For instance, this happens when an auxiliary file such as +# depcomp is added after the toplevel Makefile.in -- which +# should distribute depcomp -- has been generated.) +my $automake_needs_to_reprocess_all_files = 0; ################################################################ @@ -966,21 +971,36 @@ register_language ('name' => 'java', die "$me: no `Makefile.am' found or specified\n" if ! @input_files; -# Now do all the work on each file. -# This guy must be local otherwise it's private to the loop. -use vars '$am_file'; -local $am_file; -foreach $am_file (@input_files) +my $automake_has_run = 0; + +do { - if (! -f ($am_file . '.am')) + if ($automake_has_run) { - &am_error ("`" . $am_file . ".am' does not exist"); + print "$me: processing Makefiles another time to fix them up.\n"; + &prog_error ("running more than two times should never be needed.") + if $automake_has_run >= 2; } - else + $automake_needs_to_reprocess_all_files = 0; + + # Now do all the work on each file. + # This guy must be local otherwise it's private to the loop. + use vars '$am_file'; + local $am_file; + foreach $am_file (@input_files) { - &generate_makefile ($output_files{$am_file}, $am_file); + if (! -f ($am_file . '.am')) + { + &am_error ("`" . $am_file . ".am' does not exist"); + } + else + { + &generate_makefile ($output_files{$am_file}, $am_file); + } } + ++$automake_has_run; } +while ($automake_needs_to_reprocess_all_files); exit $exit_status; @@ -7574,6 +7594,7 @@ sub maybe_push_required_file if ($dir eq $relative_dir) { push_dist_common ($file); + return 1; } elsif ($relative_dir eq '.' && ! &is_make_dir ($dir)) { @@ -7581,7 +7602,9 @@ sub maybe_push_required_file # subdir which does not have a Makefile, then we distribute it # here. push_dist_common ($fullfile); + return 1; } + return 0; } @@ -7692,8 +7715,24 @@ sub require_file_internal ($$@) } } - maybe_push_required_file (dirname ($errfile), - $file, $errfile); + if (! maybe_push_required_file (dirname ($errfile), + $file, $errfile)) + { + if (! $found_it) + { + # We have added the file but could not push it + # into DIST_COMMON (probably because this is + # an auxiliary file and we are not processing + # the top level Makefile). This is unfortunate, + # since it means we are using a file which is not + # distributed! + + # Get Automake to be run again: on the second + # run the file will be found, and pushed into + # the toplevel DIST_COMMON automatically. + $automake_needs_to_reprocess_all_files = 1; + } + } # Prune the path list. @require_file_paths = &dirname ($errfile); diff --git a/tests/Makefile.am b/tests/Makefile.am index f3b81289..759e5d91 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -117,6 +117,7 @@ depend4.test \ dirname.test \ discover.test \ distcommon.test \ +distcommon2.test \ distdir.test \ distname.test \ double.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index c038afed..a3260711 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -190,6 +190,7 @@ depend4.test \ dirname.test \ discover.test \ distcommon.test \ +distcommon2.test \ distdir.test \ distname.test \ double.test \ diff --git a/tests/distcommon2.test b/tests/distcommon2.test new file mode 100755 index 00000000..de0ce72f --- /dev/null +++ b/tests/distcommon2.test @@ -0,0 +1,53 @@ +#! /bin/sh + +# Test to make sure that depcomp and compile are added to DIST_COMMON +# From Pavel Roskin. + +. $srcdir/defs || exit 1 + +cat > configure.in << 'END' +AM_INIT_AUTOMAKE(nonesuch, nonesuch) +PACKAGE=nonesuch +VERSION=nonesuch +AC_PROG_CC +AC_OUTPUT(Makefile subdir/Makefile) +END + +cat > Makefile.am << 'END' +SUBDIRS = subdir +END + +mkdir subdir +: > subdir/foo.c + +cat > subdir/Makefile.am << 'END' +noinst_PROGRAMS = foo +foo_SOURCES = foo.c +foo_CFLAGS = -DBAR +END + +rm -f compile depcomp + +$ACLOCAL || exit 1 +$AUTOMAKE --add-missing || exit 1 + +test -f compile || exit 1 +test -f depcomp || exit 1 + +sed -n -e '/^DIST_COMMON =.*\\$/ { + :loop + p + n + /\\$/ b loop + p + n + }' -e '/^DIST_COMMON =/ p' Makefile.in | grep compile || exit 1 + +sed -n -e '/^DIST_COMMON =.*\\$/ { + :loop + p + n + /\\$/ b loop + p + n + }' -e '/^DIST_COMMON =/ p' Makefile.in | grep depcomp || exit 1 -- 2.43.5