automake-ng
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Automake-NG] [PATCH] [ng] suffix: don't reject old-fashioned suffix rul


From: Stefano Lattarini
Subject: [Automake-NG] [PATCH] [ng] suffix: don't reject old-fashioned suffix rules anymore
Date: Tue, 29 May 2012 14:24:42 +0200

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.

Signed-off-by: Stefano Lattarini <address@hidden>
---
 So we've broken compatibility with mainline automake in one aspect,
 but can recover it in another one.  OK for 'ng/master'?  I will push
 shortly if there is no objection.

 Regards,
   Stefano

 NG-NEWS                         |   12 -------
 automake.in                     |    9 ++---
 lib/Automake/Rule.pm            |   10 ------
 lib/am/footer.am                |    4 +--
 t/suffix-rules-old-fashioned.sh |   72 +++++++++++++++++++++++++++++++++++++++
 t/suffix-rules-reject.sh        |   55 ------------------------------
 6 files changed, 77 insertions(+), 85 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 c464ea3..28c3578 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 0bb6829..473796b 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/lib/Automake/Rule.pm b/lib/Automake/Rule.pm
index d6c73e7..e49e382 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_()address@hidden';
-  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 691b0c4..3a758f5 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 <http://www.gnu.org/licenses/>.
 
-# 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 0000000..8de64ce
--- /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 <http://www.gnu.org/licenses/>.
+
+# 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 a4d6aef..0000000
--- 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 <http://www.gnu.org/licenses/>.
-
-# 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
-
-:
-- 
1.7.9.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]