automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Conditional targets?


From: Alexandre Duret-Lutz
Subject: Re: Conditional targets?
Date: Mon, 12 Jul 2004 00:07:04 +0200
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

>>> "Simon" == Simon Josefsson <address@hidden> writes:
[...]
 Simon> When the JAVA conditional is not defined, the generated Makefile look
 Simon> like:

 Simon> #install-data-local:
 Simon> #       ln -sf libidn-0.4.9.jar $(libidn_jardir)/libidn.jar

 Simon> which I believe is fine.  However, it also reads:

 Simon> install-data-am: install-data-local install-dist_libidn_jarDATA

 Simon> So I typically get an error like:

 Simon> Making install in .
 Simon> make: don't know how to make install-data-local. Stop

 Simon> make: stopped in /tmp/jas/libidn-0.4.9/java
[...]

Thanks for the report.  I'm installing the following fix.

2004-07-11  Alexandre Duret-Lutz  <address@hidden>

        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.

Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.276
diff -u -r1.276 NEWS
--- NEWS        31 May 2004 21:48:25 -0000      1.276
+++ NEWS        11 Jul 2004 22:06:03 -0000
@@ -79,6 +79,8 @@
 
   - 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
Index: THANKS
===================================================================
RCS file: /cvs/automake/automake/THANKS,v
retrieving revision 1.254
diff -u -r1.254 THANKS
--- THANKS      21 May 2004 17:31:48 -0000      1.254
+++ THANKS      11 Jul 2004 22:06:03 -0000
@@ -172,6 +172,7 @@
 Nicholas Wourms                address@hidden
 Nicolas Joly           address@hidden
 Nicolas Thiery         address@hidden
+Nik A. Melchior                address@hidden
 NISHIDA Keisuke                address@hidden
 Noah Friedman          address@hidden
 Norman Gray            address@hidden
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1563
diff -u -r1.1563 automake.in
--- automake.in 22 May 2004 21:55:47 -0000      1.1563
+++ automake.in 11 Jul 2004 22:06:07 -0000
@@ -3353,6 +3353,31 @@
 }
 
 
+# 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 @@
   # 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 @@
                             ? (" \$(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 @@
       }
 
     # 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 @@
 # 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 @@
     {
       # 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"} .=
            ("address@hidden(NORMAL_INSTALL)\n"
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.564
diff -u -r1.564 Makefile.am
--- tests/Makefile.am   22 May 2004 07:19:36 -0000      1.564
+++ tests/Makefile.am   11 Jul 2004 22:06:08 -0000
@@ -130,7 +130,9 @@
 cond34.test \
 cond35.test \
 cond36.test \
+cond37.test \
 condd.test \
+condhook.test \
 condinc.test \
 condinc2.test \
 condlib.test \
Index: tests/cond37.test
===================================================================
RCS file: tests/cond37.test
diff -N tests/cond37.test
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tests/cond37.test   11 Jul 2004 22:06:08 -0000
@@ -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
+
+:
Index: tests/condhook.test
===================================================================
RCS file: tests/condhook.test
diff -N tests/condhook.test
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tests/condhook.test 11 Jul 2004 22:06:08 -0000
@@ -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
-- 
Alexandre Duret-Lutz





reply via email to

[Prev in Thread] Current Thread [Next in Thread]