]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
For PR automake/428:
authorAlexandre Duret-Lutz <adl@gnu.org>
Sun, 11 Jul 2004 22:07:25 +0000 (22:07 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Sun, 11 Jul 2004 22:07:25 +0000 (22:07 +0000)
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.

ChangeLog
NEWS
THANKS
automake.in
doc/stamp-vti
doc/version.texi
tests/Makefile.am
tests/Makefile.in
tests/cond37.test [new file with mode: 0755]
tests/condhook.test [new file with mode: 0755]

index 35c6ff9fbc9cfe8c337d74265ed941e38039ea6b..0825fce6a662eb63f6ad33a7d6240bea40604909 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+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
diff --git a/NEWS b/NEWS
index e8cf0fc51b3699aabbd4dc63ea614fe5c856936a..60c4ddb1931a60aa6207b636f95254e36674e287 100644 (file)
--- 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 d1517501d92b0daff3ffea7ce3ad3e0c8f60e837..d6ba56bca75867d6dd537e48cdcf32530e24c103 100644 (file)
--- 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
index 9a64d6e3ad56158985fe5ee8b87294f4d6f22a51..66f2a0230fefdba2d0b19d856db1f67cb4454aba 100755 (executable)
@@ -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"
index 7a46574b978a73cb526671dac147b5c100f7a2df..58f3d2872ffc08d83d6fff6d75047f7ad480473d 100644 (file)
@@ -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
index 7a46574b978a73cb526671dac147b5c100f7a2df..58f3d2872ffc08d83d6fff6d75047f7ad480473d 100644 (file)
@@ -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
index 93e54b45d6c163d01b5fd7ca469393b05615f68c..12fabd94aa06350dd426222796516f3c76f1ee29 100644 (file)
@@ -130,7 +130,9 @@ cond33.test \
 cond34.test \
 cond35.test \
 cond36.test \
+cond37.test \
 condd.test \
+condhook.test \
 condinc.test \
 condinc2.test \
 condlib.test \
index 7e6931c98fc07208686e64eb57507be272c35368..5fb7e4d027d832171ece853337ca7d81fdc6d023 100644 (file)
@@ -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 (executable)
index 0000000..ba3802a
--- /dev/null
@@ -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 (executable)
index 0000000..55f1b83
--- /dev/null
@@ -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