From d90fca070656c1da148a4619e05f764345d206dd Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Tue, 29 May 2012 13:45:46 +0200 Subject: [PATCH] [ng] suffix: don't reject old-fashioned suffix rules anymore Now that, after today's commit 'v1.12-331-g645bb21', Automake-NG does not follow the chain of user-defined pattern rules anymore, there's no need to treat such rules preferentially, nor to reject old-fashioned suffix rules. This will help interoperability with tools like Gnulib, which generated Makefile.am fragments that still uses old-fashioned suffix rules (since they are targeted to mainline Automake). * automake.in (handle_footer): Do not reject the '.SUFFIXES:' rule nor the 'SUFFIXES' variable. Add a "FIXME" comment about why we still support the 'SUFFIXES' variable. * lib/Automake/Rule.pm: Do not error out if an old-fashioned suffix rule is seen. * lib/am/footer.am (.SUFFIXES): Depend on '$(SUFFIXES)', if that's non-empty. * t/suffix-rules-reject.sh: Remove. * t/suffix-rules-old-fashioned.sh: New. * NG-NEWS: Adjust. * doc/automake-ng.texi (Suffixes): Do not state that Automake-NG rejects attempts to define old-fashioned suffix rules. Signed-off-by: Stefano Lattarini --- NG-NEWS | 12 ------ automake.in | 9 ++--- doc/automake-ng.texi | 6 --- lib/Automake/Rule.pm | 10 ----- lib/am/footer.am | 4 +- t/suffix-rules-old-fashioned.sh | 72 +++++++++++++++++++++++++++++++++ t/suffix-rules-reject.sh | 55 ------------------------- 7 files changed, 77 insertions(+), 91 deletions(-) create mode 100755 t/suffix-rules-old-fashioned.sh delete mode 100755 t/suffix-rules-reject.sh diff --git a/NG-NEWS b/NG-NEWS index c464ea305..28c35788c 100644 --- a/NG-NEWS +++ b/NG-NEWS @@ -166,18 +166,6 @@ Parallel testsuite harness for suffix-less tests). -Pattern rules and suffix rules -============================== - -* Old-fashioned suffix rules are not supported anymore; Automake-NG will - error out if you try to use them. Use pattern rules instead, as - advised in the GNU make manual itself. - -* The .SUFFIXES: special target and the SUFFIXES special variable are - not supported anymore either; Automake-NG will error out if you try - to define them. - - Distribution ============ diff --git a/automake.in b/automake.in index 0bb68298f..473796b4b 100644 --- a/automake.in +++ b/automake.in @@ -4222,12 +4222,9 @@ sub handle_gettext # Handle footer elements. sub handle_footer { - # Automake used to have special support for old-fashioned suffix - # rules, but Automake-NG favors the use of GNU make pattern rules. - reject_rule '.SUFFIXES', - "use pattern rules, not old-fashioned suffix rules"; - reject_var 'SUFFIXES', - "use pattern rules, not old-fashioned suffix rules"; + # FIXME: maybe display a warning if the obsolescent $(SUFFIXES) + # FIXME: variable is used? Currently, we don't do that, to preserve + # FIXME: better compatibility with mainline Automake. $output_trailer .= file_contents ('footer', new Automake::Location); } diff --git a/doc/automake-ng.texi b/doc/automake-ng.texi index 80db240ad..6571eb8b3 100644 --- a/doc/automake-ng.texi +++ b/doc/automake-ng.texi @@ -10334,12 +10334,6 @@ doit_SOURCES = doit.foo Note that the above only works with suffixes that start with a dot. -Also note that Automake-NG does not support old-fashioned suffix rules -(@pxref{Suffix Rules, ,Old-fashioned Suffix Rules, make, The GNU make -Manual}), since they are obsoleted by the GNU make pattern rules. In -fact, Automake-NG will error out an any attempt to use old-fashioned -suffix rules. - @node Include @chapter Include diff --git a/lib/Automake/Rule.pm b/lib/Automake/Rule.pm index d6c73e7e4..e49e3828a 100644 --- a/lib/Automake/Rule.pm +++ b/lib/Automake/Rule.pm @@ -625,16 +625,6 @@ sub define ($$$$$;$) $rule->set ($c, $def); } - my $chars_rx = '[a-zA-Z0-9_(){}$+@\-]+'; - my $suffix_rule_rx = "^(\\.$chars_rx+)(\\.$chars_rx+)(?:\\s|\$)"; - - # We don't support old-fashioned suffix rules anymore, but want to - # report them as errors. - if ($target =~ /$suffix_rule_rx/o) - { - error $where, "use pattern rules, not old-fashioned suffix rules"; - } - return @conds; } diff --git a/lib/am/footer.am b/lib/am/footer.am index 691b0c4e8..3a758f5c1 100644 --- a/lib/am/footer.am +++ b/lib/am/footer.am @@ -14,8 +14,8 @@ ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . -# Neutralize the default suffix rules. -.SUFFIXES: +# For better compatibility with mainline Automake. +$(if $(SUFFIXES),$(eval .SUFFIXES: $$(SUFFIXES))) # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/t/suffix-rules-old-fashioned.sh b/t/suffix-rules-old-fashioned.sh new file mode 100755 index 000000000..8de64ce54 --- /dev/null +++ b/t/suffix-rules-old-fashioned.sh @@ -0,0 +1,72 @@ +#! /bin/sh +# Copyright (C) 2012 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 +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Automake-NG still accepts old-fashioned suffix rules. + +. ./defs || Exit 1 + +cat >> configure.ac << 'END' +AC_CONFIG_FILES([sub/Makefile]) +AC_OUTPUT +END + +cat > Makefile.am << 'END' +SUBDIRS = sub +foobar: ; cp $< $@ +.mu.um: + cp $< $@ +.SUFFIXES: foo bar .mu .um +data_DATA = xbar question.um +END + +mkdir sub +cat > sub/Makefile.am << 'END' +SUFFIXES = .1 2 .3 4 +.1.3 24: + sed 's/@/O/' $< >$@ +all-local: bar.3 bar4 +END + +$ACLOCAL +$AUTOMAKE + +grep SUFFIXES Makefile.in sub/Makefile.in # For debugging. + +$AUTOCONF +echo foofoofoo > xfoo +echo 'What is the sound of one hand?' > question.mu +echo '@NE' > sub/bar.1 +echo 'TW@' > sub/bar2 + +mkdir build +cd build +../configure +$MAKE +diff ../xfoo xbar +diff ../question.mu question.um +test "$(cat sub/bar.3)" = ONE +test "$(cat sub/bar4)" = TWO + +cd .. +./configure +$MAKE + +diff xfoo xbar +diff question.mu question.um +test "$(cat sub/bar.3)" = ONE +test "$(cat sub/bar4)" = TWO + +: diff --git a/t/suffix-rules-reject.sh b/t/suffix-rules-reject.sh deleted file mode 100755 index a4d6aef08..000000000 --- a/t/suffix-rules-reject.sh +++ /dev/null @@ -1,55 +0,0 @@ -#! /bin/sh -# Copyright (C) 1999-2012 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 -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Automake-NG should reject suffix rules in favor of pattern rules. - -. ./defs || Exit 1 - -$ACLOCAL - -cat > Makefile.am << 'END' -.SUFFIXES: .w -END - -cat > Makefile2.am <<'END' -## Dummy comments ... -## ... whose only purpose is ... -## ... to alter ... -## ... the line count. -SUFFIXES = .w -END - -cat > Makefile3.am << 'END' -.foo.bar: ; cp $< $@ -.mu.um: - cp $< $@ -.1.2 .3.4: - who cares -END - -msg='use pattern rules, not old-fashioned suffix rules' - -AUTOMAKE_fails -Wno-error -Wnone Makefile -grep "^Makefile\\.am:1:.*$msg" stderr -AUTOMAKE_fails -Wno-error -Wnone Makefile2 -grep "^Makefile2\\.am:5:.*$msg" stderr -AUTOMAKE_fails -Wno-error -Wnone Makefile3 -grep "^Makefile3\\.am:1:.*$msg" stderr -grep "^Makefile3\\.am:2:.*$msg" stderr -grep "^Makefile3\\.am:4:.*$msg" stderr -test `grep -c "$msg" stderr` -eq 3 - -: -- 2.47.2