Hash :
46dc44f4
Author :
Date :
2002-10-07T09:23:33
* lib/Automake/Conditional.pm: New file. * lib/Automake/Makefile.am (dist_perllib_DATA): Add Conditional.pm. * automake.in: Use Automake::Conditional. (TRUE, FALSE): New constants. (%var_value, %var_location, %var_comment, %var_type, %var_owner, %targets, %target_source, %target_name, %target_owner): Tie to Tie::RefHash::Nestable. (generate_makefile, process_option_list, handle_options, handle_languages, handle_source_transform, handle_compile, handle_libtool, handle_texinfo_helper, handle_dist, handle_subdirs, scan_aclocal_m4, handle_emacs_lisp, handle_python, scan_autoconf_files, variable_assert, define_variable, define_pretty_variable, define_configure_variable, am_install_var, push_dist_common): Use TRUE. (define_objects_from_sources): Fix return value on "recursively-defined" errors. (conditional_string, conditional_true_when, conditional_is_redundant, conditional_implies_any, make_conditions): Remove these functions, obsoleted by Conditional.pm. (cond_stack_if, cond_stack_else, cond_stack_endif): Return an Automake::Conditional instance. (by_condition, conditional_ambiguous_p, variable_not_always_defined_in_cond, macro_define, variable_conditions_recursive, variable_conditions_recursive_sub, variable_conditions_reduce, invert_conditions, variable_conditions_permutations, check_variable_defined_unconditionally, variable_value_as_list, variable_output, variable_pretty_output, rule_define, read_am_file, file_contents_internal, require_variables): Adjust to use Automake::Conditional objects. (handle_footer): Get $(SUFFIXES) in 'all' conditions. * tests/cond12.test: Adjust to use Automake::Conditional objects.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
#! /bin/sh
# Copyright (C) 2001, 2002 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 autoconf; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
# Test behaviour of variable_conditions_reduce()
# This checks the result of variable_conditions_reduce() for a wide variety
# of cases.
. ./defs || exit 1
# FIXME: probably ought to let use override this like we do in `defs'.
amfile=../../automake
sed 1q $amfile >>automake_tmp
cat << 'END' >> automake_tmp
my $failed = 0;
sub check_reduce($$) {
my ($inref, $outref) = @_;
my @inconds = map { new Automake::Conditional $_ } @$inref;
my @outconds = map { (new Automake::Conditional $_)->string } @$outref;
my @res =
map { $_->string } (&Automake::variable_conditions_reduce (@inconds));
my $result = join (",", sort @res);
my $exresult = join (",", @outconds);
if ($result ne $exresult)
{
print '"'.join(",", @$inref) . '" => "' .
$result . '" expected "' .
$exresult . '"' . "\n";
$failed = 1;
}
}
# If no conditions are given, TRUE should be returned
check_reduce([""], ["TRUE"]);
# A single condition should be passed through unchanged
check_reduce(["FOO"], ["FOO"]);
check_reduce(["FALSE"], ["FALSE"]);
check_reduce(["TRUE"], ["TRUE"]);
# TRUE and false should be discarded and overwhelm the result, respectively
check_reduce(["FOO", "TRUE"], ["FOO"]);
check_reduce(["FOO", "FALSE"], ["FALSE"]);
# Repetitions should be removed
check_reduce(["FOO", "FOO"], ["FOO"]);
check_reduce(["TRUE", "FOO", "FOO"], ["FOO"]);
check_reduce(["FOO", "TRUE", "FOO"], ["FOO"]);
check_reduce(["FOO", "FOO", "TRUE"], ["FOO"]);
# Two different conditions should be preserved, but TRUEs should be removed
check_reduce(["FOO", "BAR"], ["BAR,FOO"]);
check_reduce(["TRUE", "FOO", "BAR"], ["BAR,FOO"]);
check_reduce(["FOO", "TRUE", "BAR"], ["BAR,FOO"]);
check_reduce(["FOO", "BAR", "TRUE"], ["BAR,FOO"]);
# A condition implied by another condition should be removed.
check_reduce(["FOO BAR", "BAR"], ["FOO BAR"]);
check_reduce(["BAR", "FOO BAR"], ["FOO BAR"]);
check_reduce(["TRUE", "FOO BAR", "BAR"], ["FOO BAR"]);
check_reduce(["FOO BAR", "TRUE", "BAR"], ["FOO BAR"]);
check_reduce(["FOO BAR", "BAR", "TRUE"], ["FOO BAR"]);
check_reduce(["BAR FOO", "BAR"], ["BAR FOO"]);
check_reduce(["BAR", "BAR FOO"], ["BAR FOO"]);
check_reduce(["TRUE", "BAR FOO", "BAR"], ["BAR FOO"]);
check_reduce(["BAR FOO", "TRUE", "BAR"], ["BAR FOO"]);
check_reduce(["BAR FOO", "BAR", "TRUE"], ["BAR FOO"]);
# Check that reduction happens even when there are two conditionals to remove.
check_reduce(["FOO", "FOO BAR", "BAR"], ["FOO BAR"]);
check_reduce(["FOO", "FOO BAR", "BAZ", "FOO BAZ"], ["FOO BAR", "FOO BAZ"]);
check_reduce(["FOO", "FOO BAR", "BAZ", "FOO BAZ", "FOO BAZ BAR"], ["FOO BAZ BAR"]);
# Duplicated condionals should be removed
check_reduce(["FOO", "BAR", "BAR"], ["BAR,FOO"]);
# Equivalent conditionals in different forms should be reduced: which one is
# left is unfortunately order dependent.
check_reduce(["BAR FOO", "FOO BAR"], ["FOO BAR"]);
check_reduce(["FOO BAR", "BAR FOO"], ["BAR FOO"]);
exit $failed;
END
cat $amfile >>automake_tmp
chmod +x automake_tmp
./automake_tmp