diff -p -u -r automake_patch1/ChangeLog automake_patch2/ChangeLog --- automake_patch1/ChangeLog Thu Aug 16 20:59:00 2001 +++ automake_patch2/ChangeLog Thu Aug 16 20:56:13 2001 @@ -1,5 +1,14 @@ 2001-08-16 Richard Boulton + * automake.in (handle_dist): Out of date comment removed. + (variable_conditionally_defined): Updated to recurse itself, + rather than calling variable_conditions_recursive(): removes an + exponential complexity issue. Also, fix comment defining method + and arguments. + (variable_conditionally_defined_sub): New function. + +2001-08-16 Richard Boulton + * automake.in (extract_variable_reference): New function, containing functionality which was previously repeated several times. diff -p -u -r automake_patch1/automake.in automake_patch2/automake.in --- automake_patch1/automake.in Thu Aug 16 20:59:00 2001 +++ automake_patch2/automake.in Thu Aug 16 20:41:45 2001 @@ -3552,10 +3552,6 @@ sub handle_dist # to all possible directories, and use it. If DIST_SUBDIRS is # defined, just use it. my $dist_subdir_name; - # Note that we check DIST_SUBDIRS first on purpose. At least - # one project uses so many conditional subdirectories that - # calling variable_conditionally_defined on SUBDIRS will cause - # automake to grow to 150Mb. Sigh. if (&variable_defined ('DIST_SUBDIRS') || variable_conditionally_defined ('SUBDIRS')) { @@ -6055,16 +6051,56 @@ sub variable_conditions ($) # $BOOLEAN -# &variable_conditionally_defined ($VAR) -# -------------------------------------- +# variable_conditionally_defined ($VAR) +# ------------------------------------- +# Determines whether the variable $VAR is defined conditionally. +# Returns true if the variable or a sub variable is defined conditionally. sub variable_conditionally_defined ($) { my ($var) = @_; - foreach my $cond (variable_conditions_recursive ($var)) - { + %vars_scanned = (); + return variable_conditionally_defined_sub ($var, $var); +} + +# $BOOLEAN +# variable_conditionally_defined_sub ($VAR, $PARENT) +# -------------------------------------------------- +# Do the work for variable_conditionally_defined. +# Check if the variable +# +# Arguments: +# $VAR is the variable to check for conditional definition. +# $PARENT is the parent variable, used only for error messages. +# +# Returns true if the variable or a sub variable is defined conditionally. +sub variable_conditionally_defined_sub ($$) +{ + my ($var, $parent) = @_; + + if (defined $vars_scanned{$var}) + { + &am_line_error ($var, "variable `$var' recursively defined"); + return 0; + } + $vars_scanned{$var} = 1; + + foreach my $cond (&variable_conditions ($var)) + { return 1 unless $cond =~ /^TRUE|FALSE$/; - } + + foreach my $val (&variable_value_as_list ($var, $cond, $parent)) + { + my ($isvar, $subvar) = extract_variable_reference($val); + if ($isvar) + { + # Handle a sub variable + next if ! defined $subvar; + return 1 + if variable_conditionally_defined_sub($subvar, $var); + } + } + } return 0; }