From: Alexandre Duret-Lutz Date: Thu, 19 Sep 2002 08:59:48 +0000 (+0000) Subject: * automake.in (rule_define): Don't diagnose duplicate user rules. X-Git-Tag: Release-1-6f~7 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=9e116fe8b9f5560e8bbc5b69a3fe2db0afcd5b73;p=automake.git * automake.in (rule_define): Don't diagnose duplicate user rules. * tests/phony.test, tests/percent2.test: New files. * tests/Makefile.am (TESTS): Add them. --- diff --git a/ChangeLog b/ChangeLog index 9dccc4eb..62aa813f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2002-09-19 Alexandre Duret-Lutz + * automake.in (rule_define): Don't diagnose duplicate user rules. + * tests/phony.test, tests/percent2.test: New files. + * tests/Makefile.am (TESTS): Add them. + * automake.in (require_variables): Search variable definitions in any condition implied by $cond. * tests/cond25.test: New file. diff --git a/automake.in b/automake.in index 2e882062..a8c9800b 100755 --- a/automake.in +++ b/automake.in @@ -7382,7 +7382,7 @@ sub register_suffix_rule ($$$) # 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). @@ -7413,6 +7413,11 @@ sub rule_define ($$$$$) $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}) { @@ -7433,9 +7438,27 @@ sub rule_define ($$$$$) { 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 @@ -7477,11 +7500,6 @@ sub rule_define ($$$$$) 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; @@ -7751,9 +7769,9 @@ sub read_am_file ($) # 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); diff --git a/tests/Makefile.am b/tests/Makefile.am index ef561ae7..333ef33d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -274,6 +274,8 @@ output5.test \ package.test \ parse.test \ percent.test \ +percent2.test \ +phony.test \ pluseq.test \ pluseq2.test \ pluseq3.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index fba36737..c961b33e 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -365,6 +365,8 @@ output5.test \ package.test \ parse.test \ percent.test \ +percent2.test \ +phony.test \ pluseq.test \ pluseq2.test \ pluseq3.test \ diff --git a/tests/percent2.test b/tests/percent2.test new file mode 100755 index 00000000..c8b62736 --- /dev/null +++ b/tests/percent2.test @@ -0,0 +1,46 @@ +#!/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 diff --git a/tests/phony.test b/tests/phony.test new file mode 100755 index 00000000..16af5ebd --- /dev/null +++ b/tests/phony.test @@ -0,0 +1,34 @@ +#!/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