automake
[Top][All Lists]
Advanced

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

Re: 12-true-and-false.patch


From: Akim Demaille
Subject: Re: 12-true-and-false.patch
Date: 23 Mar 2001 17:30:49 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Cuyahoga Valley)

>>>>> "Tom" == Tom Tromey <address@hidden> writes:

Tom> Could you add this to your to-do list, or submit a PR or
Tom> something?

Here is what I actually applied.

2001-03-23  Akim Demaille  <address@hidden>

        * automake.in (read_am_file): TRUE and FALSE are predefined
        conditionals.
        (&by_condition): Adjust.
        (&conditional_string): Recognize `TRUE' and `FALSE'.
        (&make_condition): Use it.
        * m4/cond.m4: Reject TRUE and FALSE as conditionals.
        * automake.texi (Conditionals): Adjust.
        * tests/cond9.test: s/FALSE/WRONG/.

Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.978
diff -u -u -r1.978 automake.in
--- automake.in 2001/03/12 11:15:11 1.978
+++ automake.in 2001/03/23 16:15:16
@@ -5482,10 +5482,11 @@
 # Correctly returns the empty string when there are no conditions.
 sub make_condition
 {
-    my $res = join ('@@', @_);
-    return ''
-      unless $res;
+    my $res = conditional_string (@_);
 
+    return $res
+      if $res eq '' or $res eq '#' ;
+
     $res = '@' . $res . '@';
     $res =~ s/ /@@/g;
 
@@ -5527,7 +5528,7 @@
     }
   else
     {
-      return join (' ', uniq (sort (grep (!/^TRUE$/, @stack))));
+      return join (' ', uniq sort grep (!/^TRUE$/, @stack));
     }
 }
 
@@ -5668,8 +5669,8 @@
 # If the variable is defined in terms of any variables which are
 # defined conditionally, then this returns a full set of permutations
 # of the subvariable conditions.  For example, if the variable is
-# defined in terms of a variable which is defined for @COND_TRUE@,
-# then this returns both @COND_TRUE@ and @address@hidden  This is
+# defined in terms of a variable which is defined for COND_TRUE,
+# then this returns both COND_TRUE and COND_FALSE.  This is
 # because we will need to define the variable under both conditions.
 
 sub variable_conditions
@@ -5824,10 +5825,11 @@
 # Issue them in alphabetical order, foo_TRUE before foo_FALSE.
 sub by_condition
 {
+    # Be careful we might be comparing `' or `#'.
     $a =~ /^(.*)_(TRUE|FALSE)$/;
-    my ($aname, $abool) = ($1, $2);
+    my ($aname, $abool) = ($1 || '', $2 || '');
     $b =~ /^(.*)_(TRUE|FALSE)$/;
-    my ($bname, $bbool) = ($1, $2);
+    my ($bname, $bbool) = ($1 || '', $2 || '');
     return ($aname cmp $bname
            # Don't bother with IFs, given that TRUE is after FALSE
            # just cmp in the reverse order.
@@ -6276,9 +6278,11 @@
        }
        elsif (/$IF_PATTERN/o)
        {
-           &am_line_error ($., "$1 does not appear in AM_CONDITIONAL")
-               if (! $configure_cond{$1});
-           push (@conditional_stack, "$1_TRUE");
+           my $cond = $1;
+           &am_line_error ($., "$cond does not appear in AM_CONDITIONAL")
+               if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/;
+           push (@conditional_stack,
+                 ($cond =~ /^TRUE|FALSE$/) ? "$cond" : "${cond}_TRUE");
        }
        elsif (/$ELSE_PATTERN/o)
        {
@@ -6286,14 +6290,14 @@
            {
                &am_line_error ($., "else without if");
            }
-           elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE$/)
+           elsif ($conditional_stack[$#conditional_stack] =~ /^(.*_)?FALSE$/)
            {
                &am_line_error ($., "else after else");
            }
            else
            {
                $conditional_stack[$#conditional_stack]
-                   =~ s/_TRUE$/_FALSE/;
+                   =~ s/TRUE$/FALSE/;
            }
        }
        elsif (/$ENDIF_PATTERN/o)
Index: automake.texi
===================================================================
RCS file: /cvs/automake/automake/automake.texi,v
retrieving revision 1.198
diff -u -u -r1.198 automake.texi
--- automake.texi 2001/02/26 09:48:38 1.198
+++ automake.texi 2001/03/23 16:15:58
@@ -3352,15 +3352,16 @@
 @cvindex AM_CONDITIONAL
 Before using a conditional, you must define it by using
 @code{AM_CONDITIONAL} in the @code{configure.in} file (@pxref{Macros}).
-The @code{AM_CONDITIONAL} macro takes two arguments.
 
-The first argument to @code{AM_CONDITIONAL} is the name of the
-conditional.  This should be a simple string starting with a letter and
-containing only letters, digits, and underscores.
address@hidden AM_CONDITIONAL (@var{conditional}, @var{condition})
+The conditional name, @var{conditional}, should be a simple string
+starting with a letter and containing only letters, digits, and
+underscores.  It must be different from @samp{TRUE} and @samp{FALSE}
+which are reserved by Automake.
 
-The second argument to @code{AM_CONDITIONAL} is a shell condition,
-suitable for use in a shell @code{if} statement.  The condition is
-evaluated when @code{configure} is run.
+The shell @var{condition} (suitable for use in a shell @code{if}
+statement) is evaluated when @code{configure} is run.
address@hidden defmac
 
 @cindex --enable-debug, example
 @cindex Example conditional --enable-debug
Index: configure
===================================================================
RCS file: /cvs/automake/automake/configure,v
retrieving revision 1.79
diff -u -u -r1.79 configure
--- configure 2001/02/18 00:35:18 1.79
+++ configure 2001/03/23 16:16:25
@@ -544,51 +544,6 @@
 ac_config_sub=$ac_aux_dir/config.sub
 ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
 
-
-# Make sure we can run config.sub.
-if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
-else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
-fi
-
-echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:555: checking host system type" >&5
-
-host_alias=$host
-case "$host_alias" in
-NONE)
-  case $nonopt in
-  NONE)
-    if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
-    else { echo "configure: error: can not guess host type; you must specify 
one" 1>&2; exit 1; }
-    fi ;;
-  *) host_alias=$nonopt ;;
-  esac ;;
-esac
-
-host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
-host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
Index: m4/cond.m4
===================================================================
RCS file: /cvs/automake/automake/m4/cond.m4,v
retrieving revision 1.3
diff -u -u -r1.3 cond.m4
--- m4/cond.m4 2001/01/16 11:04:35 1.3
+++ m4/cond.m4 2001/03/23 16:16:29
@@ -1,10 +1,21 @@
-# serial 2
+# serial 3
 
 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
 # -------------------------------------
 # Define a conditional.
+#
+# FIXME: Once using 2.50, use this:
+# m4_match([$1], [^TRUE\|FALSE$], [AC_FATAL([$0: invalid condition: $1])])dnl
 AC_DEFUN([AM_CONDITIONAL],
-[AC_SUBST([$1_TRUE])
+[ifelse([$1], [TRUE],
+        [errprint(__file__:__line__: [$0: invalid condition: $1
+])dnl
+m4exit(1)])dnl
+ifelse([$1], [FALSE],
+       [errprint(__file__:__line__: [$0: invalid condition: $1
+])dnl
+m4exit(1)])dnl
+AC_SUBST([$1_TRUE])
 AC_SUBST([$1_FALSE])
 if $2; then
   $1_TRUE=
Index: tests/cond9.test
===================================================================
RCS file: /cvs/automake/automake/tests/cond9.test,v
retrieving revision 1.2
diff -u -u -r1.2 cond9.test
--- tests/cond9.test 2001/01/26 14:21:37 1.2
+++ tests/cond9.test 2001/03/23 16:16:29
@@ -7,12 +7,12 @@
 cat > configure.in << 'END'
 AC_INIT(Makefile.am)
 AM_INIT_AUTOMAKE(foo,0.0)
-AM_CONDITIONAL(FALSE, [test x = y])
+AM_CONDITIONAL(WRONG, [test x = y])
 AC_OUTPUT(Makefile)
 END
 
 cat > Makefile.am << 'END'
-if FALSE
+if WRONG
 this=
 else
 this=is_something_interesting




reply via email to

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