The promised change in automake that makes it declare more dependencies explicitly in the generated Makefile.in. With these change, all the new introduced tests that was failing with Heirlooom make now passes, and the test `silent5.test' passes too.
A couple of older tests has to be adapted to work with the new automake output, but their changes are minimal and (mostly) straightforward. --- * automake.in (handle_single_transform): Unconditionally emit explict dependencies (but not explicit rules, unless required). * tests/yacc5.test: Adapted to changes in Automake's output. * tests/exeext3.test: Likewise. * tests/suffix3.test: Likewise --- ChangeLog | 8 ++++ automake.in | 114 ++++++++++++++++++++++++++++++++------------------- tests/exeext3.test | 10 +++- tests/suffix3.test | 26 ++++++++---- tests/yacc5.test | 11 ++++- 5 files changed, 112 insertions(+), 57 deletions(-)
From 369c15371c0094a452fdc29eb41945b4c05fdd50 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini <stefano.lattar...@gmail.com> Date: Mon, 26 Apr 2010 21:16:15 +0200 Subject: [PATCH 4/6] automake.in: improve declaration of dependencies in generated Makefile.in * automake.in (handle_single_transform): Unconditionally emit explict dependencies (but not explicit rules, unless required). * tests/yacc5.test: Adapted to changes in Automake's output. * tests/exeext3.test: Likewise. * tests/suffix3.test: Likewise --- ChangeLog | 8 ++++ automake.in | 114 ++++++++++++++++++++++++++++++++------------------- tests/exeext3.test | 10 +++- tests/suffix3.test | 26 ++++++++---- tests/yacc5.test | 11 ++++- 5 files changed, 112 insertions(+), 57 deletions(-) diff --git a/ChangeLog b/ChangeLog index 515c153..a514481 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2010-05-20 Stefano Lattarini <stefano.lattar...@gmail.com> + automake.in: improve declaration of dependencies in generated + Makefile.in files. + * automake.in (handle_single_transform): Unconditionally emit + explict dependencies (but not explicit rules, unless required). + * tests/yacc5.test: Adapted to changes in Automake's output. + * tests/exeext3.test: Likewise. + * tests/suffix3.test: Likewise + Add new tests on Lex and Yacc. * tests/lex7.test: New test. * tests/lex8.test: Likewise. diff --git a/automake.in b/automake.in index 05b8711..592ca3f 100644 --- a/automake.in +++ b/automake.in @@ -1958,51 +1958,71 @@ sub handle_single_transform ($$$$$%) # Using inference rules for subdir-objects has been tested # with GNU make, Solaris make, Ultrix make, BSD make, # HP-UX make, and OSF1 make successfully. - if ($renamed - || ($directory ne '' && ! option 'subdir-objects') + # + # Unfortunately, explicit *dependencies* might still be needed + # in the generated Makefile.in, even when explicit *rules* are + # *not* required. Otherwise, in particular situations, some + # make implementations (e.g. Heirloom make) might end up using + # their built-in implicit rules, rather then the rules' chains + # inferred from Automake-generated generic suffix rules. + # + # An example will help to clarify this. + # + # Let's say we have a C file `foo.c' generated from a Yacc + # input `foo.y'. If the Makefile contains no target which + # depends *explicitly* from foo.c, Heirloom make will end up + # using its builtin `.y => .o' rule (calling $(YACC) and $(CC) + # directly, and obviously ignoring the $(AM_CFLAGS) variable, + # the ylwarp script, etc.), instead of the `.y => .c => .o' + # rule chain generated by Automake (thanks to the two suffix + # rules `.y.c' and `.c.o'). + # + # So, for consistency and simplicity, we always declare + # *explicit* dependencies, while avoiding to output + # unnecessary explicit *rules*. + my $obj_sans_ext = substr ($object, 0, - length ($this_obj_ext)); + my $full_ansi; + if ($directory ne '') + { + $full_ansi = $directory . '/' . $base . $extension; + } + else + { + $full_ansi = $base . $extension; + } + + if ($lang->ansi && option 'ansi2knr') + { + $full_ansi =~ s/$KNOWN_EXTENSIONS_PATTERN$/\$U$&/; + $obj_sans_ext .= '$U'; + } + + my @specifics = ($full_ansi, $obj_sans_ext, + # Only use $this_obj_ext in the derived + # source case because in the other case we + # *don't* want $(OBJEXT) to appear here. + ($derived_source ? $this_obj_ext : '.o'), + $extension); + + # If we renamed the object then we want to use the + # per-executable flag name. But if this is simply a + # subdir build then we still want to use the AM_ flag + # name. + if ($renamed) + { + unshift @specifics, $derived; + $aggregate = $derived; + } + else + { + unshift @specifics, 'AM'; + } + + if ($renamed || ($directory ne '' && ! option 'subdir-objects') # We must also use specific rules for a nodist_ source # if its language requests it. || ($lang->nodist_specific && ! $transform{'DIST_SOURCE'})) - { - my $obj_sans_ext = substr ($object, 0, - - length ($this_obj_ext)); - my $full_ansi; - if ($directory ne '') - { - $full_ansi = $directory . '/' . $base . $extension; - } - else - { - $full_ansi = $base . $extension; - } - - if ($lang->ansi && option 'ansi2knr') - { - $full_ansi =~ s/$KNOWN_EXTENSIONS_PATTERN$/\$U$&/; - $obj_sans_ext .= '$U'; - } - - my @specifics = ($full_ansi, $obj_sans_ext, - # Only use $this_obj_ext in the derived - # source case because in the other case we - # *don't* want $(OBJEXT) to appear here. - ($derived_source ? $this_obj_ext : '.o'), - $extension); - - # If we renamed the object then we want to use the - # per-executable flag name. But if this is simply a - # subdir build then we still want to use the AM_ flag - # name. - if ($renamed) - { - unshift @specifics, $derived; - $aggregate = $derived; - } - else - { - unshift @specifics, 'AM'; - } - + { # Each item on this list is a reference to a list consisting # of four values followed by additional transform flags for # file_contents. The four values are the derived flag prefix @@ -2011,7 +2031,15 @@ sub handle_single_transform ($$$$$%) # the extension for the object file. push (@{$lang_specific_files{$lang->name}}, [...@specifics, %transform]); - } + } + else + { + # FIXME: There is a cleaner way to do this, so that the + # extra dependencies are placed in a "better" position in + # the generated Makefile.in? Note that this is admittedly + # a purely cosmetic issue. + $output_rules .= "$obj_sans_ext$this_obj_ext: $full_ansi\n"; + } } elsif ($extension eq $nonansi_obj) { diff --git a/tests/exeext3.test b/tests/exeext3.test index 28a7d5e..b15b6e7 100755 --- a/tests/exeext3.test +++ b/tests/exeext3.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2007, 2010 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -38,6 +38,10 @@ $ACLOCAL $AUTOMAKE -Wno-override $FGREP 'maude$(EXEEXT):' Makefile.in -test 1 = `grep 'maude.*:' Makefile.in | wc -l` +test 1 = `grep 'maude.*:' Makefile.in \ + | grep -v '^maude\.\$(OBJEXT): *maude.c *$' \ + | wc -l` $FGREP '3dldf$(EXEEXT):' Makefile.in -test 1 = `grep '3dldf.*:' Makefile.in | wc -l` +test 1 = `grep '3dldf.*:' Makefile.in \ + | grep -v '^3dldf\.\$(OBJEXT): *3dldf.c *$' \ + | wc -l` diff --git a/tests/suffix3.test b/tests/suffix3.test index 1e8a00d..e9c91fa 100755 --- a/tests/suffix3.test +++ b/tests/suffix3.test @@ -18,6 +18,8 @@ . ./defs || Exit 1 +set -e + cat >> configure.in << 'END' AC_PROG_CXX END @@ -30,13 +32,19 @@ bin_PROGRAMS = foo foo_SOURCES = foo.zoo END -$ACLOCAL || Exit 1 -$AUTOMAKE || Exit 1 +$ACLOCAL +$AUTOMAKE + +ignore_foodep() { grep -v '^foo\.\$(OBJEXT): *foo\.cc *$' $*; } + +# The foo.cc intermediate step is explicit w.r.t. dependency declaration, +# implicit w.r.t. rule declaration. +ignore_foodep Makefile.in | $FGREP foo.cc && Exit 1 + +# Automake must figure that foo.zoo is eventually transformed into foo.o, +# and use this latter file (to link foo). +ignore_foodep Makefile.in \ + | sed -e 's/^/ /' -e 's/$/ /' \ + | $FGREP ' foo.$(OBJEXT) ' -# The foo.cc intermediate step is implicit, it's a mistake if -# Automake requires this file somewhere. -$FGREP foo.cc Makefile.in && Exit 1 -# However Automake must figure that foo.zoo is eventually -# transformed into foo.o, and use this latter file (to link foo). -$FGREP 'foo.$(OBJEXT)' Makefile.in || Exit 1 -Exit 0 +: diff --git a/tests/yacc5.test b/tests/yacc5.test index 77de2e9..628c66b 100755 --- a/tests/yacc5.test +++ b/tests/yacc5.test @@ -21,6 +21,8 @@ set -e +tab=' ' + cat >> configure.in << 'END' AC_PROG_CC AM_PROG_CC_C_O @@ -39,7 +41,7 @@ mkdir sub $ACLOCAL $AUTOMAKE -a -grep '^maude\.c:' Makefile.in +grep '^maude\.c: *sub/maude.y' Makefile.in ## Try again with subdir-objects. @@ -54,7 +56,12 @@ $ACLOCAL $AUTOMAKE -a # No rule needed, the default .y.c: inference rule is enough. -grep '^sub/maude\.c:' Makefile.in && Exit 1 +# But a dependency without a rule is accepatable, so account +# for that. +grep '^sub/maude\.c:.*;.*' Makefile.in && Exit 1 +sed -n '/^sub\/maude\.c:/{N;p;}' Makefile.in > t +cat t # useful for debugging +grep "^$tab" t && Exit 1 ## Try again with per-exe flags. -- 1.6.5