# rule_define ($TARGET, $SOURCE, $OWNER, $COND, $WHERE)
# -----------------------------------------------------
# Define a new rule. $TARGET is the rule name. $SOURCE
-# si the filename the rule comes from. $OWNER is the
+# is the filename the rule comes from. $OWNER is the
# owener of the rule (TARGET_AUTOMAKE or TARGET_USER).
# $COND is the condition string under which the rule is defined.
# $WHERE is where the rule is defined (file name and/or line number).
$target = $noexe;
+ # A GNU make-style pattern rule has a single "%" in the target name.
+ msg ('portability', $where,
+ "`%'-style pattern rules are a GNU make extension")
+ if $target =~ /^[^%]*%[^%]*$/;
+
# Diagnose target redefinitions.
if (exists $target_source{$target}{$cond})
{
{
if ($oldowner eq TARGET_USER)
{
- msg ('syntax', $where, "redefinition of `$target'$condmsg...");
- msg_cond_target ('syntax', $cond, $target,
- "... `$target' previously defined here.");
+ # Ignore `%'-style pattern rules. We'd need the
+ # dependencies to detect duplicates, and they are
+ # already diagnosed as unportable by -Wportability.
+ if ($target !~ /^[^%]*%[^%]*$/)
+ {
+ ## FIXME: Presently we can't diagnose duplcate user rules
+ ## because we doesn't distinguish rules with commands
+ ## from rules that only add dependencies. E.g.,
+ ## .PHONY: foo
+ ## .PHONY: bar
+ ## is legitimate. (This is phony.test.)
+
+ # msg ('syntax', $where,
+ # "redefinition of `$target'$condmsg...");
+ # msg_cond_target ('syntax', $cond, $target,
+ # "... `$target' previously defined here.");
+ }
+ # Return so we don't redefine the rule in our tables,
+ # don't check for ambiguous conditional, etc. The rule
+ # will be output anyway beauce &read_am_file ignore the
+ # return code.
return ();
}
else
prog_error ("Unreachable place reached.");
}
- # A GNU make-style pattern rule has a single "%" in the target name.
- msg ('portability', $where,
- "`%'-style pattern rules are a GNU make extension")
- if $target =~ /^[^%]*%[^%]*$/;
-
# Conditions for which the rule should be defined.
my @conds = $cond;
# Found a rule.
$prev_state = IN_RULE_DEF;
- # For TARGET_USER rules, rule_define won't reject a rule
- # without diagnosic an error. So we go on and ignore the
- # return value.
+ # For now we have to output all definitions of user rules
+ # and can't diagnose duplicates (see the comment in
+ # rule_define). So we go on and ignore the return value.
rule_define ($1, $amfile, TARGET_USER, $cond || 'TRUE', $here);
check_variable_expansions ($_, $here);
--- /dev/null
+#!/bin/sh
+# Copyright (C) 2002 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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.
+#
+# GNU Automake 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 autoconf; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Another test for -Wportability warning about %-style rules, plus
+# make sure we don't warn about duplicate definition for
+# `${ARCH}/%.$(OBJEXT):'.
+# Report from Ralf Corsepius.
+
+. ./defs
+
+set -e
+
+cat >>Makefile.am << 'EOF'
+${ARCH}/%.$(OBJEXT): %.S
+ test -d ${ARCH} || mkdir ${ARCH}
+ ${CCASCOMPILE} -o $@ -c $<
+
+${ARCH}/%.$(OBJEXT): %.c
+ test -d ${ARCH} || mkdir ${ARCH}
+ ${COMPILE} -o $@ -c $<
+EOF
+
+$ACLOCAL
+$AUTOMAKE 2>stderr && exit 1
+cat stderr
+grep '%.*pattern.*rules' stderr
+
+# No error otherwise.
+$AUTOMAKE -Wno-portability
--- /dev/null
+#!/bin/sh
+# Copyright (C) 2002 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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.
+#
+# GNU Automake 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 autoconf; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Make sure .PHONY can be given depenencies several times.
+# From Ralf Corsepius.
+
+. ./defs
+
+set -e
+
+cat >Makefile.am << 'EOF'
+.PHONY: foo
+.PHONY: bar
+EOF
+
+$ACLOCAL
+$AUTOMAKE