From: Alexandre Duret-Lutz Date: Sun, 11 Jul 2004 22:07:25 +0000 (+0000) Subject: For PR automake/428: X-Git-Tag: Release-1-8d~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68acb54a58e22f4ad83ed9de1b885b9c78bd9b1a;p=thirdparty%2Fautomake.git For PR automake/428: Support for conditionally defined -hook and -local rules. * automake.in (user_phony_rule): New function. (handle_dist, handle_install, handle_all, do_check_merge_target, handle_factored_dependencies): Use user_phony_rule before adding a user -hook or -local rule as a dependency to ensure it is always defined an phony. * tests/cond37.test, tests/condhook.test: New files. * tests/Makefile.am (TESTS): Add them. Report from Simon Josefsson and Nik A. Melchior. --- diff --git a/ChangeLog b/ChangeLog index 35c6ff9fb..0825fce6a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2004-07-11 Alexandre Duret-Lutz + + For PR automake/428: + Support for conditionally defined -hook and -local rules. + * automake.in (user_phony_rule): New function. + (handle_dist, handle_install, handle_all, do_check_merge_target, + handle_factored_dependencies): Use user_phony_rule before + adding a user -hook or -local rule as a dependency to ensure + it is always defined an phony. + * tests/cond37.test, tests/condhook.test: New files. + * tests/Makefile.am (TESTS): Add them. + Report from Simon Josefsson and Nik A. Melchior. + 2004-07-05 Paul Eggert * doc/automake.texi (Install): Warn that you should create diff --git a/NEWS b/NEWS index e8cf0fc51..60c4ddb19 100644 --- a/NEWS +++ b/NEWS @@ -79,6 +79,8 @@ New in 1.8c: - Support for conditional _LISP. + - Support for conditional -hook and -local rules (PR/428). + - Diagnose AC_CONFIG_AUX_DIR calls following AM_INIT_AUTOMAKE. (PR/49) - Automake will not write any Makefile.ins after the first error it diff --git a/THANKS b/THANKS index d1517501d..d6ba56bca 100644 --- a/THANKS +++ b/THANKS @@ -172,6 +172,7 @@ Nelson H. F. Beebe beebe@math.utah.edu Nicholas Wourms nwourms@netscape.net Nicolas Joly njoly@pasteur.fr Nicolas Thiery nthiery@Icare.mines.edu +Nik A. Melchior nam1@cse.wustl.edu NISHIDA Keisuke knishida@nn.iij4u.or.jp Noah Friedman friedman@gnu.ai.mit.edu Norman Gray norman@astro.gla.ac.uk diff --git a/automake.in b/automake.in index 9a64d6e3a..66f2a0230 100755 --- a/automake.in +++ b/automake.in @@ -3353,6 +3353,31 @@ sub handle_multilib } +# user_phony_rule ($NAME) +# ----------------------- +# Return false if rule $NAME does not exist. Otherwise, +# declare it as phony, complete its definition (in case it is +# conditional), and return its Automake::Rule instance. +sub user_phony_rule ($) +{ + my ($name) = @_; + my $rule = rule $name; + if ($rule) + { + depend ('.PHONY', $name); + # Define $NAME in all condition where it is not already defined, + # so that it is always OK to depend on $NAME. + for my $c ($rule->not_always_defined_in_cond (TRUE)->conds) + { + Automake::Rule::define ($name, 'internal', RULE_AUTOMAKE, + $c, INTERNAL); + $output_rules .= $c->subst_string . "$name:\n"; + } + } + return $rule; +} + + # $BOOLEAN # &for_dist_common ($A, $B) # ------------------------- @@ -3535,7 +3560,7 @@ sub handle_dist () # allows users to do random weird things to the distribution # before it is packaged up. push (@dist_targets, 'dist-hook') - if rule 'dist-hook'; + if user_phony_rule 'dist-hook'; $transform{'DIST-TARGETS'} = join (' ', @dist_targets); my $flm = option ('filename-length-max'); @@ -4150,7 +4175,7 @@ sub handle_install () ? (" \$(BUILT_SOURCES)\n" . "\t\$(MAKE) \$(AM_MAKEFLAGS)") : ''), - 'installdirs-local' => (rule 'installdirs-local' + 'installdirs-local' => (user_phony_rule 'installdirs-local' ? ' installdirs-local' : ''), am__installdirs => variable_value ('am__installdirs') || ''); } @@ -4176,11 +4201,8 @@ sub handle_all ($) } # Install `all' hooks. - if (rule "all-local") - { - push (@all, "all-local"); - &depend ('.PHONY', "all-local"); - } + push (@all, "all-local") + if user_phony_rule "all-local"; &pretty_print_rule ("all-am:", "\t\t", @all); &depend ('.PHONY', 'all-am', 'all'); @@ -4225,12 +4247,9 @@ sub handle_all ($) # Handle check merge target specially. sub do_check_merge_target () { - if (rule 'check-local') - { - # User defined local form of target. So include it. - push @check_tests, 'check-local'; - depend '.PHONY', 'check-local'; - } + # Include user-defined local form of target. + push @check_tests, 'check-local' + if user_phony_rule 'check-local'; # In --cygnus mode, check doesn't depend on all. if (option 'cygnus') @@ -4358,18 +4377,15 @@ sub handle_factored_dependencies { # Hooks are installed on the -am targets. s/-am$// or next; - if (rule "$_-local") - { - depend ("$_-am", "$_-local"); - depend ('.PHONY', "$_-local"); - } + depend ("$_-am", "$_-local") + if user_phony_rule "$_-local"; } # Install the -hook hooks. # FIXME: Why not be as liberal as we are with -local hooks? foreach ('install-exec', 'install-data', 'uninstall') { - if (rule ("$_-hook")) + if (user_phony_rule "$_-hook") { $actions{"$_-am"} .= ("\t\@\$(NORMAL_INSTALL)\n" diff --git a/doc/stamp-vti b/doc/stamp-vti index 7a46574b9..58f3d2872 100644 --- a/doc/stamp-vti +++ b/doc/stamp-vti @@ -1,4 +1,4 @@ -@set UPDATED 16 June 2004 -@set UPDATED-MONTH June 2004 +@set UPDATED 11 July 2004 +@set UPDATED-MONTH July 2004 @set EDITION 1.8c @set VERSION 1.8c diff --git a/doc/version.texi b/doc/version.texi index 7a46574b9..58f3d2872 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 16 June 2004 -@set UPDATED-MONTH June 2004 +@set UPDATED 11 July 2004 +@set UPDATED-MONTH July 2004 @set EDITION 1.8c @set VERSION 1.8c diff --git a/tests/Makefile.am b/tests/Makefile.am index 93e54b45d..12fabd94a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -130,7 +130,9 @@ cond33.test \ cond34.test \ cond35.test \ cond36.test \ +cond37.test \ condd.test \ +condhook.test \ condinc.test \ condinc2.test \ condlib.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 7e6931c98..5fb7e4d02 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -247,7 +247,9 @@ cond33.test \ cond34.test \ cond35.test \ cond36.test \ +cond37.test \ condd.test \ +condhook.test \ condinc.test \ condinc2.test \ condlib.test \ diff --git a/tests/cond37.test b/tests/cond37.test new file mode 100755 index 000000000..ba3802abc --- /dev/null +++ b/tests/cond37.test @@ -0,0 +1,63 @@ +#!/bin/sh +# Copyright (C) 2004 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 Automake; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# Check conditional local rules. +# Report from Simon Josefsson. + +. ./defs + +set -e + +cat >>configure.in <<'EOF' +AM_CONDITIONAL([CASE_A], test -n "$case_A") +AC_OUTPUT +EOF + +cat >>Makefile.am <<'EOF' +if CASE_A +check-local: + @echo GrepMe1 +else +install-data-local: + @echo GrepMe2 +endif +EOF + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure +$MAKE check >stdout +cat stdout +grep GrepMe1 stdout && exit 1 +$MAKE install >stdout +cat stdout +grep GrepMe2 stdout + +./configure case_A=1 +$MAKE check >stdout +cat stdout +grep GrepMe1 stdout +$MAKE install >stdout +cat stdout +grep GrepMe2 stdout && exit 1 + +: diff --git a/tests/condhook.test b/tests/condhook.test new file mode 100755 index 000000000..55f1b83bb --- /dev/null +++ b/tests/condhook.test @@ -0,0 +1,47 @@ +#!/bin/sh +# Copyright (C) 2004 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 Automake; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# Test install when a conditional install-*-hook is not defined. +# Report by Nik A. Melchior (PR/428). + +. ./defs || exit 1 + +set -e + +cat >> configure.in << 'END' +AM_CONDITIONAL(TEST, false) +AC_OUTPUT +END + +cat > Makefile.am << 'END' +sysconf_DATA = mumble +if TEST +install-data-hook: + echo foo +endif +END + +: > mumble + +$ACLOCAL +$AUTOCONF +$AUTOMAKE +./configure --prefix `pwd`/inst +$MAKE install