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-11 Alexandre Duret-Lutz <adl@gnu.org>
+
+ 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 <eggert@cs.ucla.edu>
* doc/automake.texi (Install): Warn that you should create
- 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
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
}
+# 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)
# -------------------------
# 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');
? (" \$(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') || '');
}
}
# 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');
# 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')
{
# 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"
-@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
-@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
cond34.test \
cond35.test \
cond36.test \
+cond37.test \
condd.test \
+condhook.test \
condinc.test \
condinc2.test \
condlib.test \
cond34.test \
cond35.test \
cond36.test \
+cond37.test \
condd.test \
+condhook.test \
condinc.test \
condinc2.test \
condlib.test \
--- /dev/null
+#!/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
+
+:
--- /dev/null
+#!/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