summaryrefslogtreecommitdiff
path: root/lib/Automake
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Automake')
-rw-r--r--lib/Automake/ChannelDefs.pm55
-rw-r--r--lib/Automake/Channels.pm28
-rw-r--r--lib/Automake/Condition.pm27
-rw-r--r--lib/Automake/Configure_ac.pm25
-rw-r--r--lib/Automake/Location.pm72
-rw-r--r--lib/Automake/Makefile.am9
-rw-r--r--lib/Automake/Options.pm89
-rw-r--r--lib/Automake/Rule.pm13
-rw-r--r--lib/Automake/RuleDef.pm29
-rw-r--r--lib/Automake/VarDef.pm4
-rw-r--r--lib/Automake/Variable.pm16
-rw-r--r--lib/Automake/Wrap.pm16
-rw-r--r--lib/Automake/XFile.pm112
-rw-r--r--lib/Automake/tests/Cond2.pl22
-rw-r--r--lib/Automake/tests/Cond3.pl22
-rw-r--r--lib/Automake/tests/Condition-t.pl57
-rw-r--r--lib/Automake/tests/Condition.pl46
-rw-r--r--lib/Automake/tests/DisjCon2.pl24
-rw-r--r--lib/Automake/tests/DisjCon3.pl23
-rw-r--r--lib/Automake/tests/DisjConditions-t.pl38
-rw-r--r--lib/Automake/tests/DisjConditions.pl32
-rw-r--r--lib/Automake/tests/Makefile.am30
-rw-r--r--lib/Automake/tests/Version.pl42
-rw-r--r--lib/Automake/tests/Version2.pl20
-rw-r--r--lib/Automake/tests/Version3.pl20
-rw-r--r--lib/Automake/tests/Wrap.pl44
26 files changed, 725 insertions, 190 deletions
diff --git a/lib/Automake/ChannelDefs.pm b/lib/Automake/ChannelDefs.pm
index aaca97920..3e9fd1bac 100644
--- a/lib/Automake/ChannelDefs.pm
+++ b/lib/Automake/ChannelDefs.pm
@@ -44,7 +44,7 @@ Automake::ChannelDefs - channel definitions for Automake and helper functions
verb ($MESSAGE, [%OPTIONS]);
switch_warning ($CATEGORY);
parse_WARNINGS ();
- parse_warning ($OPTION, $ARGUMENT);
+ parse_warnings ($OPTION, $ARGUMENT);
Automake::ChannelDefs::set_strictness ($STRICTNESS_NAME);
=head1 DESCRIPTION
@@ -115,6 +115,10 @@ variables (silent by default).
Warnings about non-portable constructs.
+=item C<extra-portability>
+
+Extra warnings about non-portable constructs covering obscure tools.
+
=item C<syntax>
Warnings about weird syntax, unused variables, typos...
@@ -151,6 +155,7 @@ register_channel 'automake', type => 'fatal', backtrace => 1,
footer => "\nPlease contact <$PACKAGE_BUGREPORT>.",
uniq_part => UP_NONE, ordered => 0;
+register_channel 'extra-portability', type => 'warning', silent => 1;
register_channel 'gnu', type => 'warning';
register_channel 'obsolete', type => 'warning', silent => 1;
register_channel 'override', type => 'warning', silent => 1;
@@ -163,6 +168,10 @@ register_channel 'verb', type => 'debug', silent => 1, uniq_part => UP_NONE,
ordered => 0;
register_channel 'note', type => 'debug', silent => 0;
+setup_channel_type 'warning', header => 'warning: ';
+setup_channel_type 'error', header => 'error: ';
+setup_channel_type 'fatal', header => 'error: ';
+
=head2 FUNCTIONS
=over 4
@@ -180,6 +189,7 @@ sub usage ()
`obsolete' obsolete features or constructions
`override' user redefinitions of Automake rules or variables
`portability' portability issues (default in gnu and gnits modes)
+ `extra-portability' extra portability issues related to obscure tools
`syntax' dubious syntactic constructs (default)
`unsupported' unsupported or incomplete features (default)
`all' all the warnings
@@ -282,8 +292,38 @@ sub switch_warning ($)
elsif (channel_type ($cat) eq 'warning')
{
setup_channel $cat, silent => $has_no;
- setup_channel 'portability-recursive', silent => $has_no
- if $cat eq 'portability';
+ #
+ # Handling of portability warnings is trickier. For relevant tests,
+ # see `dollarvar2', `extra-portability' and `extra-portability3'.
+ #
+ # -Wportability-recursive and -Wno-portability-recursive should not
+ # have any effect on other 'portability' or 'extra-portability'
+ # warnings, so there's no need to handle them separately or ad-hoc.
+ #
+ if ($cat eq 'extra-portability' && ! $has_no) # -Wextra-portability
+ {
+ # -Wextra-portability must enable 'portability' and
+ # 'portability-recursive' warnings.
+ setup_channel 'portability', silent => 0;
+ setup_channel 'portability-recursive', silent => 0;
+ }
+ if ($cat eq 'portability') # -Wportability or -Wno-portability
+ {
+ if ($has_no) # -Wno-portability
+ {
+ # -Wno-portability must disable 'extra-portability' and
+ # 'portability-recursive' warnings.
+ setup_channel 'portability-recursive', silent => 1;
+ setup_channel 'extra-portability', silent => 1;
+ }
+ else # -Wportability
+ {
+ # -Wportability must enable 'portability-recursive'
+ # warnings. But it should have no influence over the
+ # 'extra-portability' warnings.
+ setup_channel 'portability-recursive', silent => 0;
+ }
+ }
}
else
{
@@ -308,7 +348,7 @@ sub parse_WARNINGS ()
}
}
-=item C<parse_warning ($OPTION, $ARGUMENT)>
+=item C<parse_warnings ($OPTION, $ARGUMENT)>
Parse the argument of C<--warning=CATEGORY> or C<-WCATEGORY>.
@@ -345,6 +385,7 @@ sub set_strictness ($)
setup_channel 'error-gnu/warn', silent => 0, type => 'error';
setup_channel 'error-gnits', silent => 1;
setup_channel 'portability', silent => 0;
+ setup_channel 'extra-portability', silent => 1;
setup_channel 'gnu', silent => 0;
}
elsif ($name eq 'gnits')
@@ -353,6 +394,7 @@ sub set_strictness ($)
setup_channel 'error-gnu/warn', silent => 0, type => 'error';
setup_channel 'error-gnits', silent => 0;
setup_channel 'portability', silent => 0;
+ setup_channel 'extra-portability', silent => 1;
setup_channel 'gnu', silent => 0;
}
elsif ($name eq 'foreign')
@@ -361,11 +403,12 @@ sub set_strictness ($)
setup_channel 'error-gnu/warn', silent => 0, type => 'warning';
setup_channel 'error-gnits', silent => 1;
setup_channel 'portability', silent => 1;
+ setup_channel 'extra-portability', silent => 1;
setup_channel 'gnu', silent => 1;
}
else
{
- prog_error "level `$name' not recognized\n";
+ prog_error "level `$name' not recognized";
}
}
@@ -381,6 +424,8 @@ Written by Alexandre Duret-Lutz E<lt>F<adl@gnu.org>E<gt>.
=cut
+1;
+
### Setup "GNU" style for perl-mode and cperl-mode.
## Local Variables:
## perl-indent-level: 2
diff --git a/lib/Automake/Channels.pm b/lib/Automake/Channels.pm
index 9a2732c89..06f044362 100644
--- a/lib/Automake/Channels.pm
+++ b/lib/Automake/Channels.pm
@@ -164,7 +164,7 @@ functions. The possible keys, with their default value are:
The type of the channel. One of C<'debug'>, C<'warning'>, C<'error'>, or
C<'fatal'>. Fatal messages abort the program when they are output.
Error messages update the exit status. Debug and warning messages are
-harmless, except that warnings can be treated as errors of
+harmless, except that warnings are treated as errors if
C<$warnings_are_errors> is set.
=item C<exit_code =E<gt> 1>
@@ -204,10 +204,14 @@ C<US_LOCAL>, and C<US_GLOBAL> constants above.
=item C<header =E<gt> ''>
A string to prepend to each message emitted through this channel.
+With partial messages, only the first part will have C<header>
+prepended.
=item C<footer =E<gt> ''>
A string to append to each message emitted through this channel.
+With partial messages, only the final part will have C<footer>
+appended.
=item C<backtrace =E<gt> 0>
@@ -399,20 +403,24 @@ sub _format_sub_message ($$)
return $leader . join ("\n" . $leader, split ("\n", $message)) . "\n";
}
+# Store partial messages here. (See the 'partial' option.)
+use vars qw ($partial);
+$partial = '';
+
# _format_message ($LOCATION, $MESSAGE, %OPTIONS)
# -----------------------------------------------
# Format the message. Return a string ready to print.
sub _format_message ($$%)
{
my ($location, $message, %opts) = @_;
- my $msg = '';
+ my $msg = ($partial eq '' ? $opts{'header'} : '') . $message
+ . ($opts{'partial'} ? '' : $opts{'footer'});
if (ref $location)
{
# If $LOCATION is a reference, assume it's an instance of the
# Automake::Location class and display contexts.
my $loc = $location->get || $me;
- $msg = _format_sub_message ("$loc: ", $opts{'header'}
- . $message . $opts{'footer'});
+ $msg = _format_sub_message ("$loc: ", $msg);
for my $pair ($location->get_contexts)
{
$msg .= _format_sub_message ($pair->[0] . ": ", $pair->[1]);
@@ -421,8 +429,7 @@ sub _format_message ($$%)
else
{
$location ||= $me;
- $msg = _format_sub_message ("$location: ", $opts{'header'}
- . $message . $opts{'footer'});
+ $msg = _format_sub_message ("$location: ", $msg);
}
return $msg;
}
@@ -484,10 +491,6 @@ sub _dequeue ($)
}
-# Store partial messages here. (See the 'partial' option.)
-use vars qw ($partial);
-$partial = '';
-
# _print_message ($LOCATION, $MESSAGE, %OPTIONS)
# ----------------------------------------------
# Format the message, check duplicates, and print it.
@@ -511,6 +514,9 @@ sub _print_message ($$%)
$partial = '';
}
+ msg ('note', '', 'warnings are treated as errors', uniq_scope => US_GLOBAL)
+ if ($opts{'type'} eq 'warning' && $warnings_are_errors);
+
# Check for duplicate message if requested.
my $to_filter;
if ($opts{'uniq_part'} ne UP_NONE)
@@ -674,7 +680,7 @@ Override the options of C<$channel> with those specified by C<%options>.
sub setup_channel ($%)
{
my ($name, %opts) = @_;
- confess "channel $name doesn't exist" unless exists $channels{$name};
+ confess "unknown channel $name" unless exists $channels{$name};
_merge_options %{$channels{$name}}, %opts;
}
diff --git a/lib/Automake/Condition.pm b/lib/Automake/Condition.pm
index 2d649f686..5c54b8beb 100644
--- a/lib/Automake/Condition.pm
+++ b/lib/Automake/Condition.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 1997, 2001, 2002, 2003, 2006, 2008 Free Software
+# Copyright (C) 1997, 2001, 2002, 2003, 2006, 2008, 2009 Free Software
# Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
@@ -180,18 +180,21 @@ sub new ($;@)
};
bless $self, $class;
- # Accept strings like "FOO BAR" as shorthand for ("FOO", "BAR").
- @conds = map { split (' ', $_) } @conds;
-
for my $cond (@conds)
{
- next if $cond eq 'TRUE';
-
# Catch some common programming errors:
# - A Condition passed to new
confess "`$cond' is a reference, expected a string" if ref $cond;
# - A Condition passed as a string to new
confess "`$cond' does not look like a condition" if $cond =~ /::/;
+ }
+
+ # Accept strings like "FOO BAR" as shorthand for ("FOO", "BAR").
+ @conds = map { split (' ', $_) } @conds;
+
+ for my $cond (@conds)
+ {
+ next if $cond eq 'TRUE';
# Detect cases when @conds can be simplified to FALSE.
if (($cond eq 'FALSE' && $#conds > 0)
@@ -250,7 +253,7 @@ except those of C<$minuscond>. This is the opposite of C<merge>.
sub strip ($$)
{
my ($self, $minus) = @_;
- my @res = grep { not $minus->has ($_) } $self->conds;
+ my @res = grep { not $minus->_has ($_) } $self->conds;
return new Automake::Condition @res;
}
@@ -274,7 +277,7 @@ sub conds ($ )
}
# Undocumented, shouldn't be needed outside of this class.
-sub has ($$)
+sub _has ($$)
{
my ($self, $cond) = @_;
return exists $self->{'hash'}{$cond};
@@ -289,7 +292,7 @@ Return 1 iff this condition is always false.
sub false ($ )
{
my ($self) = @_;
- return $self->has ('FALSE');
+ return $self->_has ('FALSE');
}
=item C<$cond-E<gt>true>
@@ -426,7 +429,7 @@ sub true_when ($$)
# exists in $WHEN.
foreach my $cond ($self->conds)
{
- return 0 unless $when->has ($cond);
+ return 0 unless $when->_has ($cond);
}
return 1;
}
@@ -518,6 +521,8 @@ sub multiply ($@)
return (values %res);
}
+=back
+
=head2 Other helper functions
=over 4
@@ -615,6 +620,8 @@ sub conditional_negate ($)
return $cond;
}
+=back
+
=head1 SEE ALSO
L<Automake::DisjConditions>.
diff --git a/lib/Automake/Configure_ac.pm b/lib/Automake/Configure_ac.pm
index e2bebef77..357403545 100644
--- a/lib/Automake/Configure_ac.pm
+++ b/lib/Automake/Configure_ac.pm
@@ -1,4 +1,5 @@
-# Copyright (C) 2003, 2005, 2006, 2010 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2005, 2006, 2009, 2010 Free Software Foundation,
+# Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -49,6 +50,20 @@ Automake::Configure_ac - Locate configure.ac or configure.in.
my $file_name = find_configure_ac ($dir);
my $file_name = require_configure_ac ($dir);
+=over 4
+
+=back
+
+=head2 Functions
+
+=over 4
+
+=item C<$configure_ac = find_configure_ac ([$directory])>
+
+Find a F<configure.ac> or F<configure.in> file in C<$directory>,
+defaulting to the current directory. Complain if both files are present.
+Return the name of the file found, or the former if neither is present.
+
=cut
sub find_configure_ac (;@)
@@ -66,7 +81,7 @@ sub find_configure_ac (;@)
{
msg ('unsupported',
"`$configure_ac' and `$configure_in' both present.\n"
- . "proceeding with `$configure_ac'.");
+ . "proceeding with `$configure_ac'");
}
return $configure_ac
}
@@ -78,6 +93,12 @@ sub find_configure_ac (;@)
}
+=item C<$configure_ac = require_configure_ac ([$directory])>
+
+Like C<find_configure_ac>, but fail if neither is present.
+
+=cut
+
sub require_configure_ac (;$)
{
my $res = find_configure_ac (@_);
diff --git a/lib/Automake/Location.pm b/lib/Automake/Location.pm
index 613dc80ab..1dc81dc7a 100644
--- a/lib/Automake/Location.pm
+++ b/lib/Automake/Location.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2002, 2003, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2008, 2009 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -50,7 +50,7 @@ Automake::Location - a class for location tracking, with a stack of contexts
...
}
- # Pop a context, and reset the location from the previous context.
+ # Pop a context, and reset the location to the previous context.
$where->pop_context;
# Clone a Location. Use this when storing the state of a location
@@ -84,6 +84,16 @@ You can pass a C<Location> to C<Automake::Channels::msg>.
=cut
+=head2 Methods
+
+=over
+
+=item C<$where = new Automake::Location ([$position])>
+
+Create and return a new Location object.
+
+=cut
+
sub new ($;$)
{
my ($class, $position) = @_;
@@ -95,18 +105,36 @@ sub new ($;$)
return $self;
}
+=item C<$location-E<gt>set ($position)>
+
+Change the location to be C<$position>.
+
+=cut
+
sub set ($$)
{
my ($self, $position) = @_;
$self->{'position'} = $position;
}
+=item C<$location-E<gt>get>
+
+Get the location (without context).
+
+=cut
+
sub get ($)
{
my ($self) = @_;
return $self->{'position'};
}
+=item C<$location-E<gt>push_context ($context)>
+
+Push a context to the location.
+
+=cut
+
sub push_context ($$)
{
my ($self, $context) = @_;
@@ -114,6 +142,12 @@ sub push_context ($$)
$self->set (undef);
}
+=item C<$where = $location-E<gt>pop_context ($context)>
+
+Pop a context, and reset the location to the previous context.
+
+=cut
+
sub pop_context ($)
{
my ($self) = @_;
@@ -122,12 +156,25 @@ sub pop_context ($)
return @{$pair};
}
+=item C<@contexts = $location-E<gt>get_contexts>
+
+Return the array of contexts.
+
+=cut
+
sub get_contexts ($)
{
my ($self) = @_;
return @{$self->{'contexts'}};
}
+=item C<$location = $location-E<gt>clone>
+
+Clone a Location. Use this when storing the state of a location
+that would otherwise be modified.
+
+=cut
+
sub clone ($)
{
my ($self) = @_;
@@ -140,6 +187,12 @@ sub clone ($)
return $other;
}
+=item C<$res = $location-E<gt>dump>
+
+Print the location and the stack of context (for debugging).
+
+=cut
+
sub dump ($)
{
my ($self) = @_;
@@ -152,6 +205,13 @@ sub dump ($)
return $res;
}
+=item C<@array = $location-E<gt>serialize>
+
+Serialize a Location object (for passing through a thread queue,
+for example).
+
+=cut
+
sub serialize ($)
{
my ($self) = @_;
@@ -166,6 +226,12 @@ sub serialize ($)
return @serial;
}
+=item C<new Automake::Location::deserialize ($queue)>
+
+De-serialize: recreate a Location object from a queue.
+
+=cut
+
sub deserialize ($)
{
my ($queue) = @_;
@@ -179,6 +245,8 @@ sub deserialize ($)
return $self;
}
+=back
+
=head1 SEE ALSO
L<Automake::Channels>
diff --git a/lib/Automake/Makefile.am b/lib/Automake/Makefile.am
index 0858b6875..e4c2572f1 100644
--- a/lib/Automake/Makefile.am
+++ b/lib/Automake/Makefile.am
@@ -64,10 +64,9 @@ do_subst = in=`echo $@ | sed 's/\.[^.]*$$//'`; sed \
## $(datadir) or other do_subst'ituted variables change.
## Use chmod a-w to prevent people from editing the wrong file by accident.
Config.pm: Config.in Makefile
- rm -f Config.tmp Config.pm
- $(do_subst) $(srcdir)/Config.in >Config.tmp
- chmod +x Config.tmp
- chmod a-w Config.tmp
- mv -f Config.tmp Config.pm
+ $(AM_V_GEN)rm -f Config.tmp Config.pm
+ $(AM_V_at)$(do_subst) $(srcdir)/Config.in >Config.tmp
+ $(AM_V_at)chmod a-w Config.tmp
+ $(AM_V_at)mv -f Config.tmp Config.pm
EXTRA_DIST = Config.in
diff --git a/lib/Automake/Options.pm b/lib/Automake/Options.pm
index e3d23ae46..34c026c28 100644
--- a/lib/Automake/Options.pm
+++ b/lib/Automake/Options.pm
@@ -71,11 +71,16 @@ F<Makefile.am>s.
=cut
-# Values are the Automake::Location of the definition, except
-# for 'ansi2knr' whose value is a pair [filename, Location].
+# Values are the Automake::Location of the definition.
use vars '%_options'; # From AUTOMAKE_OPTIONS
use vars '%_global_options'; # from AM_INIT_AUTOMAKE or the command line.
+# Whether process_option_list has already been called for the current
+# Makefile.am.
+use vars '$_options_processed';
+# Whether process_global_option_list has already been called.
+use vars '$_global_options_processed';
+
=head2 Constants
=over 4
@@ -135,6 +140,7 @@ previous F<Makefile.am>.
sub reset ()
{
+ $_options_processed = 0;
%_options = %_global_options;
# The first time we are run,
# remember the current setting as the default.
@@ -222,29 +228,39 @@ sub unset_global_option ($)
}
-=item C<process_option_list ($where, @options)>
+=item C<process_option_list (@list)>
+
+=item C<process_global_option_list (@list)>
-=item C<process_global_option_list ($where, @options)>
+Process Automake's option lists. C<@list> should be a list of hash
+references with keys C<option> and C<where>, where C<option> is an
+option as they occur in C<AUTOMAKE_OPTIONS> or C<AM_INIT_AUTOMAKE>,
+and C<where> is the location where that option occurred.
-Process Automake's option lists. C<@options> should be a list of
-words, as they occur in C<AUTOMAKE_OPTIONS> or C<AM_INIT_AUTOMAKE>.
+These functions should be called at most once for each set of options
+having the same precedence; i.e., do not call it twice for two options
+from C<AM_INIT_AUTOMAKE>.
Return 1 on error, 0 otherwise.
=cut
# $BOOL
-# _process_option_list (\%OPTIONS, $WHERE, @OPTIONS)
-# --------------------------------------------------
-# Process a list of options. Return 1 on error, 0 otherwise.
-# \%OPTIONS is the hash to fill with options data, $WHERE is
-# the location where @OPTIONS occurred.
-sub _process_option_list (\%$@)
+# _process_option_list (\%OPTIONS, @LIST)
+# ------------------------------------------
+# Process a list of options. \%OPTIONS is the hash to fill with options
+# data. @LIST is a list of options as get passed to public subroutines
+# process_option_list() and process_global_option_list() (see POD
+# documentation above).
+sub _process_option_list (\%@)
{
- my ($options, $where, @list) = @_;
+ my ($options, @list) = @_;
+ my @warnings = ();
- foreach (@list)
+ foreach my $h (@list)
{
+ local $_ = $h->{'option'};
+ my $where = $h->{'where'};
$options->{$_} = $where;
if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
{
@@ -252,14 +268,9 @@ sub _process_option_list (\%$@)
}
elsif (/^(.*\/)?ansi2knr$/)
{
- # This feature is deprecated, will be removed in the next
- # Automake major release.
- msg 'obsolete', $where,
- "automatic de-ANSI-fication support is deprecated\n";
- # An option like "../lib/ansi2knr" is allowed. With no
- # path prefix, we assume the required programs are in this
- # directory. We save the actual option for later.
- $options->{'ansi2knr'} = [$_, $where];
+ # Obsolete (and now removed) de-ANSI-fication support.
+ error ($where,
+ "automatic de-ANSI-fication support has been removed");
}
elsif ($_ eq 'dist-lzma')
{
@@ -325,11 +336,8 @@ sub _process_option_list (\%$@)
}
elsif (/^(?:--warnings=|-W)(.*)$/)
{
- foreach my $cat (split (',', $1))
- {
- msg 'unsupported', $where, "unknown warning category `$cat'"
- if switch_warning $cat;
- }
+ my @w = map { { cat => $_, loc => $where} } split (',', $1);
+ push @warnings, @w;
}
else
{
@@ -338,19 +346,32 @@ sub _process_option_list (\%$@)
return 1;
}
}
+ # We process warnings here, so that any explicitly-given warning setting
+ # will take precedence over warning settings defined implicitly by the
+ # strictness.
+ foreach my $w (@warnings)
+ {
+ msg 'unsupported', $w->{'loc'},
+ "unknown warning category `$w->{'cat'}'"
+ if switch_warning $w->{cat};
+ }
return 0;
}
-sub process_option_list ($@)
+sub process_option_list (@)
{
- my ($where, @list) = @_;
- return _process_option_list (%_options, $where, @list);
+ prog_error "local options already processed"
+ if $_options_processed;
+ return _process_option_list (%_options, @_);
+ $_options_processed = 1;
}
-sub process_global_option_list ($@)
+sub process_global_option_list (@)
{
- my ($where, @list) = @_;
- return _process_option_list (%_global_options, $where, @list);
+ prog_error "global options already processed"
+ if $_global_options_processed;
+ return _process_option_list (%_global_options, @_);
+ $_global_options_processed = 1;
}
=item C<set_strictness ($name)>
@@ -381,7 +402,7 @@ sub set_strictness ($)
}
else
{
- prog_error "level `$strictness_name' not recognized\n";
+ prog_error "level `$strictness_name' not recognized";
}
}
diff --git a/lib/Automake/Rule.pm b/lib/Automake/Rule.pm
index 3184b24d2..6d437eda5 100644
--- a/lib/Automake/Rule.pm
+++ b/lib/Automake/Rule.pm
@@ -616,7 +616,8 @@ sub define ($$$$$)
msg ('obsolete', $tdef->location,
"deprecated feature: target `$noexe' overrides "
. "`$noexe\$(EXEEXT)'\n"
- . "change your target to read `$noexe\$(EXEEXT)'");
+ . "change your target to read `$noexe\$(EXEEXT)'",
+ partial => 1);
msg ('obsolete', $where, "target `$target' was defined here");
}
# Don't `return ()' now, as this might hide target clashes
@@ -658,7 +659,7 @@ sub define ($$$$$)
## is legitimate. (This is phony.test.)
# msg ('syntax', $where,
- # "redefinition of `$target'$condmsg...", partial => 1);
+ # "redefinition of `$target'$condmsg ...", partial => 1);
# msg_cond_rule ('syntax', $cond, $target,
# "... `$target' previously defined here");
}
@@ -694,7 +695,7 @@ sub define ($$$$$)
msg_cond_rule ('override', $cond, $target,
"user target `$target' defined here"
- . "$condmsg...", partial => 1);
+ . "$condmsg ...", partial => 1);
msg ('override', $where,
"... overrides Automake target `$oldname' defined here",
partial => $hint);
@@ -718,7 +719,7 @@ sub define ($$$$$)
my $oldsource = $tdef->source;
return () if $source eq $oldsource && $target eq $oldname;
- msg ('syntax', $where, "redefinition of `$target'$condmsg...",
+ msg ('syntax', $where, "redefinition of `$target'$condmsg ...",
partial => 1);
msg_cond_rule ('syntax', $cond, $target,
"... `$oldname' previously defined here");
@@ -726,7 +727,7 @@ sub define ($$$$$)
}
}
# Never reached.
- prog_error ("Unreachable place reached.");
+ prog_error ("unreachable place reached");
}
# Conditions for which the rule should be defined.
@@ -818,7 +819,7 @@ sub define ($$$$$)
# definitions of multiple inference rules. It's also
# disallowed to mix plain targets with inference rules.
msg ('portability', $where,
- "Inference rules can have only one target before the colon (POSIX).")
+ "inference rules can have only one target before the colon (POSIX)")
if $inference_rule_count > 0 && $target_count > 1;
return @conds;
diff --git a/lib/Automake/RuleDef.pm b/lib/Automake/RuleDef.pm
index 20bc10637..3bd506df2 100644
--- a/lib/Automake/RuleDef.pm
+++ b/lib/Automake/RuleDef.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2003 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2009 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -36,6 +36,7 @@ Automake::RuleDef - a class for rule definitions
=head1 DESCRIPTION
This class gathers data related to one Makefile-rule definition.
+It shouldn't be needed outside of F<Rule.pm>.
=head2 Constants
@@ -50,6 +51,20 @@ Possible owners for rules.
use constant RULE_AUTOMAKE => 0; # Rule defined by Automake.
use constant RULE_USER => 1; # Rule defined in the user's Makefile.am.
+=back
+
+=head2 Methods
+
+=over 4
+
+=item C<new Automake::RuleDef ($name, $comment, $location, $owner, $source)>
+
+Create a new rule definition with target C<$name>, with associated comment
+C<$comment>, Location C<$location> and owner C<$owner>, defined in file
+C<$source>.
+
+=cut
+
sub new ($$$$$)
{
my ($class, $name, $comment, $location, $owner, $source) = @_;
@@ -60,12 +75,24 @@ sub new ($$$$$)
return $self;
}
+=item C<$source = $rule-E<gt>source>
+
+Return the source of the rule.
+
+=cut
+
sub source ($)
{
my ($self) = @_;
return $self->{'source'};
}
+=item C<$name = $rule-E<gt>name>
+
+Return the name of the rule.
+
+=cut
+
sub name ($)
{
my ($self) = @_;
diff --git a/lib/Automake/VarDef.pm b/lib/Automake/VarDef.pm
index 568c82afa..033aa05d2 100644
--- a/lib/Automake/VarDef.pm
+++ b/lib/Automake/VarDef.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2004, 2006, 2009 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -195,6 +195,8 @@ sub append ($$$)
=item C<$def-E<gt>value>
+=item C<$def-E<gt>raw_value>
+
=item C<$def-E<gt>type>
=item C<$def-E<gt>pretty>
diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm
index 686847d4f..cd57877ae 100644
--- a/lib/Automake/Variable.pm
+++ b/lib/Automake/Variable.pm
@@ -156,7 +156,6 @@ my %_gen_varname_n = ();
# Macros accessible via aclocal.
my %_am_macro_for_var =
(
- ANSI2KNR => 'AM_C_PROTOTYPES',
CCAS => 'AM_PROG_AS',
CCASFLAGS => 'AM_PROG_AS',
EMACS => 'AM_PATH_LISPDIR',
@@ -169,7 +168,6 @@ my %_am_macro_for_var =
pyexecdir => 'AM_PATH_PYTHON',
PYTHON => 'AM_PATH_PYTHON',
pythondir => 'AM_PATH_PYTHON',
- U => 'AM_C_PROTOTYPES',
);
# Macros shipped with Autoconf.
@@ -470,7 +468,7 @@ sub _check_ambiguous_condition ($$$)
# We allow silent variables to be overridden silently,
# by either silent or non-silent variables.
my $def = $self->def ($ambig_cond);
- if ($message && !($def && $def->pretty == VAR_SILENT))
+ if ($message && $def->pretty != VAR_SILENT)
{
msg 'syntax', $where, "$message ...", partial => 1;
msg_var ('syntax', $var, "... `$var' previously defined here");
@@ -881,10 +879,10 @@ sub define ($$$$$$$$)
{
error ($def->location,
"Automake variable `$var' was set with `"
- . $def->type . "=' here...", partial => 1);
+ . $def->type . "=' here ...", partial => 1);
error ($where, "... and is now set with `$type=' here.");
prog_error ("Automake variable assignments should be consistently\n"
- . "defined with the same sign.");
+ . "defined with the same sign");
}
# If Automake tries to override a value specified by the user,
@@ -896,7 +894,7 @@ sub define ($$$$$$$$)
my $condmsg = ($cond == TRUE
? '' : (" in condition `" . $cond->human . "'"));
msg_cond_var ('override', $cond, $var,
- "user variable `$var' defined here$condmsg...",
+ "user variable `$var' defined here$condmsg ...",
partial => 1);
msg ('override', $where,
"... overrides Automake variable `$var' defined here");
@@ -996,10 +994,10 @@ sub define ($$$$$$$$)
if (! $undef_cond->false)
{
error ($where,
- "Cannot apply `+=' because `$var' is not defined "
+ "cannot apply `+=' because `$var' is not defined "
. "in\nthe following conditions:\n "
. join ("\n ", map { $_->human } $undef_cond->conds)
- . "\nEither define `$var' in these conditions,"
+ . "\neither define `$var' in these conditions,"
. " or use\n`+=' in the same conditions as"
. " the definitions.");
}
@@ -1078,7 +1076,7 @@ For debugging.
sub variables_dump ()
{
- my $text = "All variables:\n{\n";
+ my $text = "all variables:\n{\n";
foreach my $var (sort { $a->name cmp $b->name } variables)
{
$text .= $var->dump;
diff --git a/lib/Automake/Wrap.pm b/lib/Automake/Wrap.pm
index 66213d1ee..59b3e5ac9 100644
--- a/lib/Automake/Wrap.pm
+++ b/lib/Automake/Wrap.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2006, 2009 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -48,10 +48,10 @@ maximum length allowed. (Ticket #17141, fixed in Perl 5.8.0.)
=cut
-# tab_length ($TXT)
-# -----------------
+# _tab_length ($TXT)
+# ------------------
# Compute the length of TXT, counting tab characters as 8 characters.
-sub tab_length($)
+sub _tab_length($)
{
my ($txt) = @_;
my $len = length ($txt);
@@ -78,16 +78,16 @@ sub wrap($$$$@)
my ($head, $fill, $eol, $max_len, @values) = @_;
my $result = $head;
- my $column = tab_length ($head);
+ my $column = _tab_length ($head);
- my $fill_len = tab_length ($fill);
- my $eol_len = tab_length ($eol);
+ my $fill_len = _tab_length ($fill);
+ my $eol_len = _tab_length ($eol);
my $not_first_word = 0;
foreach (@values)
{
- my $len = tab_length ($_);
+ my $len = _tab_length ($_);
# See if the new variable fits on this line.
# (The + 1 is for the space we add in front of the value.).
diff --git a/lib/Automake/XFile.pm b/lib/Automake/XFile.pm
index 46483e65a..4ba84ce02 100644
--- a/lib/Automake/XFile.pm
+++ b/lib/Automake/XFile.pm
@@ -68,18 +68,6 @@ methods C<close>, C<lock> (corresponding to C<flock>), C<new>,
C<open>, C<seek>, and C<truncate>. It also overrides the C<getline>
and C<getlines> methods to translate C<\r\n> to C<\n>.
-=head1 SEE ALSO
-
-L<perlfunc>,
-L<perlop/"I/O Operators">,
-L<IO::File>
-L<IO::Handle>
-L<IO::Seekable>
-
-=head1 HISTORY
-
-Derived from IO::File.pm by Akim Demaille E<lt>F<akim@freefriends.org>E<gt>.
-
=cut
require 5.000;
@@ -110,12 +98,16 @@ eval {
push (@EXPORT, @O);
};
-# Used in croak error messages.
-my $me = basename ($0);
+=head2 Methods
+
+=over
+
+=item C<$fh = new Automake::XFile ([$expr, ...]>
-################################################
-## Constructor
-##
+Constructor a new XFile object. Additional arguments
+are passed to C<open>, if any.
+
+=cut
sub new
{
@@ -129,9 +121,12 @@ sub new
$fh;
}
-################################################
-## Open
-##
+=item C<$fh-E<gt>open ([$file, ...])>
+
+Open a file, passing C<$file> and further arguments to C<IO::File::open>.
+Die if opening fails. Store the name of the file. Use binmode for writing.
+
+=cut
sub open
{
@@ -156,9 +151,11 @@ sub open
binmode $fh if $file =~ /^\s*>/;
}
-################################################
-## Close
-##
+=item C<$fh-E<gt>close>
+
+Close the file, handling errors.
+
+=cut
sub close
{
@@ -172,9 +169,12 @@ sub close
}
}
-################################################
-## Getline
-##
+=item C<$line = $fh-E<gt>getline>
+
+Read and return a line from the file. Ensure C<\r\n> is translated to
+C<\n> on input files.
+
+=cut
# Some Win32/perl installations fail to translate \r\n to \n on input
# so we do that here.
@@ -187,9 +187,11 @@ sub getline
return $_;
}
-################################################
-## Getlines
-##
+=item C<@lines = $fh-E<gt>getlines>
+
+Slurp lines from the files.
+
+=cut
sub getlines
{
@@ -199,9 +201,11 @@ sub getlines
return @res;
}
-################################################
-## Name
-##
+=item C<$name = $fh-E<gt>name>
+
+Return the name of the file.
+
+=cut
sub name
{
@@ -209,9 +213,13 @@ sub name
return ${*$fh}{'autom4te_xfile_file'};
}
-################################################
-## Lock
-##
+=item C<$fh-E<gt>lock>
+
+Lock the file using C<flock>. If locking fails for reasons other than
+C<flock> being unsupported, then error out if C<$ENV{'MAKEFLAGS'}> indicates
+that we are spawned from a parallel C<make>.
+
+=cut
sub lock
{
@@ -243,9 +251,11 @@ sub lock
}
}
-################################################
-## Seek
-##
+=item C<$fh-E<gt>seek ($position, [$whence])>
+
+Seek file to C<$position>. Die if seeking fails.
+
+=cut
sub seek
{
@@ -254,13 +264,15 @@ sub seek
if (!seek ($fh, $_[0], $_[1]))
{
my $file = $fh->name;
- fatal "$me: cannot rewind $file with @_: $!";
+ fatal "cannot rewind $file with @_: $!";
}
}
-################################################
-## Truncate
-##
+=item C<$fh-E<gt>truncate ($len)>
+
+Truncate the file to length C<$len>. Die on failure.
+
+=cut
sub truncate
{
@@ -272,6 +284,22 @@ sub truncate
}
}
+=back
+
+=head1 SEE ALSO
+
+L<perlfunc>,
+L<perlop/"I/O Operators">,
+L<IO::File>
+L<IO::Handle>
+L<IO::Seekable>
+
+=head1 HISTORY
+
+Derived from IO::File.pm by Akim Demaille E<lt>F<akim@freefriends.org>E<gt>.
+
+=cut
+
1;
### Setup "GNU" style for perl-mode and cperl-mode.
diff --git a/lib/Automake/tests/Cond2.pl b/lib/Automake/tests/Cond2.pl
new file mode 100644
index 000000000..94caa8976
--- /dev/null
+++ b/lib/Automake/tests/Cond2.pl
@@ -0,0 +1,22 @@
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Catch common programming error:
+# A Condition passed as a string to 'new'.
+
+use Automake::Condition;
+
+my $cond = new Automake::Condition ('TRUE');
+new Automake::Condition ($cond);
diff --git a/lib/Automake/tests/Cond3.pl b/lib/Automake/tests/Cond3.pl
new file mode 100644
index 000000000..e010e4f0b
--- /dev/null
+++ b/lib/Automake/tests/Cond3.pl
@@ -0,0 +1,22 @@
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Catch common programming error:
+# A Condition passed as a string to 'new'.
+
+use Automake::Condition;
+
+my $cond = new Automake::Condition ("COND1_TRUE");
+new Automake::Condition ("$cond");
diff --git a/lib/Automake/tests/Condition-t.pl b/lib/Automake/tests/Condition-t.pl
index 06eb34e92..752d340c2 100644
--- a/lib/Automake/tests/Condition-t.pl
+++ b/lib/Automake/tests/Condition-t.pl
@@ -1,13 +1,12 @@
-# Copyright (C) 2001, 2002, 2003, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2008, 2009, 2011 Free Software
+# Foundation, Inc.
#
-# This file is part of GNU Automake.
-#
-# GNU Automake is free software; you can redistribute it and/or modify
+# This program 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,
+# This program 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.
@@ -18,7 +17,8 @@
BEGIN {
use Config;
if (eval { require 5.007_002; } # for CLONE support
- && $Config{useithreads})
+ && $Config{useithreads}
+ && !$ENV{WANT_NO_THREADS})
{
require threads;
import threads;
@@ -32,15 +32,15 @@ use Automake::Condition qw/TRUE FALSE/;
sub test_basics ()
{
- my @tests = (# [[Conditions], is_true?, is_false?, string, subst-string]
- [[], 1, 0, 'TRUE', ''],
- [['TRUE'], 1, 0, 'TRUE', ''],
- [['FALSE'], 0, 1, 'FALSE', '#'],
- [['A_TRUE'], 0, 0, 'A_TRUE', '@A_TRUE@'],
+ my @tests = (# [[Conditions], is_true?, is_false?, string, subst-string, human]
+ [[], 1, 0, 'TRUE', '', 'TRUE'],
+ [['TRUE'], 1, 0, 'TRUE', '', 'TRUE'],
+ [['FALSE'], 0, 1, 'FALSE', '#', 'FALSE'],
+ [['A_TRUE'], 0, 0, 'A_TRUE', '@A_TRUE@', 'A'],
[['A_TRUE', 'B_FALSE'],
- 0, 0, 'A_TRUE B_FALSE', '@A_TRUE@@B_FALSE@'],
- [['B_TRUE', 'FALSE'], 0, 1, 'FALSE', '#'],
- [['B_TRUE', 'B_FALSE'], 0, 1, 'FALSE', '#']);
+ 0, 0, 'A_TRUE B_FALSE', '@A_TRUE@@B_FALSE@', 'A and !B'],
+ [['B_TRUE', 'FALSE'], 0, 1, 'FALSE', '#', 'FALSE'],
+ [['B_TRUE', 'B_FALSE'], 0, 1, 'FALSE', '#', 'FALSE']);
for (@tests)
{
@@ -53,6 +53,7 @@ sub test_basics ()
return 1 if $_->[2] != ($a == FALSE);
return 1 if $_->[3] ne $a->string;
return 1 if $_->[4] ne $a->subst_string;
+ return 1 if $_->[5] ne $a->human;
})->join;
}
return 0;
@@ -281,7 +282,33 @@ sub test_reduce_or ()
return $failed;
}
-exit (test_basics || test_true_when || test_reduce_and || test_reduce_or);
+sub test_merge ()
+{
+ my $cond = new Automake::Condition "COND1_TRUE", "COND2_FALSE";
+ return threads->new(sub {
+ my $other = new Automake::Condition "COND3_FALSE";
+ return threads->new(sub {
+ my $both = $cond->merge ($other);
+ return threads->new(sub {
+ my $both2 = $cond->merge_conds ("COND3_FALSE");
+ return threads->new(sub {
+ $cond = $both->strip ($other);
+ my @conds = $cond->conds;
+ return 1 if $both->string ne "COND1_TRUE COND2_FALSE COND3_FALSE";
+ return 1 if $cond->string ne "COND1_TRUE COND2_FALSE";
+ return 1 if $both != $both2;
+ })->join;
+ })->join;
+ })->join;
+ })->join;
+ return 0;
+}
+
+exit (test_basics
+ || test_true_when
+ || test_reduce_and
+ || test_reduce_or
+ || test_merge);
### Setup "GNU" style for perl-mode and cperl-mode.
## Local Variables:
diff --git a/lib/Automake/tests/Condition.pl b/lib/Automake/tests/Condition.pl
index 86f174564..1c6548412 100644
--- a/lib/Automake/tests/Condition.pl
+++ b/lib/Automake/tests/Condition.pl
@@ -1,13 +1,12 @@
-# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2008, 2009, 2011 Free Software
+# Foundation, Inc.
#
-# This file is part of GNU Automake.
-#
-# GNU Automake is free software; you can redistribute it and/or modify
+# This program 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,
+# This program 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.
@@ -19,15 +18,15 @@ use Automake::Condition qw/TRUE FALSE/;
sub test_basics ()
{
- my @tests = (# [[Conditions], is_true?, is_false?, string, subst-string]
- [[], 1, 0, 'TRUE', ''],
- [['TRUE'], 1, 0, 'TRUE', ''],
- [['FALSE'], 0, 1, 'FALSE', '#'],
- [['A_TRUE'], 0, 0, 'A_TRUE', '@A_TRUE@'],
+ my @tests = (# [[Conditions], is_true?, is_false?, string, subst-string, human]
+ [[], 1, 0, 'TRUE', '', 'TRUE'],
+ [['TRUE'], 1, 0, 'TRUE', '', 'TRUE'],
+ [['FALSE'], 0, 1, 'FALSE', '#', 'FALSE'],
+ [['A_TRUE'], 0, 0, 'A_TRUE', '@A_TRUE@', 'A'],
[['A_TRUE', 'B_FALSE'],
- 0, 0, 'A_TRUE B_FALSE', '@A_TRUE@@B_FALSE@'],
- [['B_TRUE', 'FALSE'], 0, 1, 'FALSE', '#'],
- [['B_TRUE', 'B_FALSE'], 0, 1, 'FALSE', '#']);
+ 0, 0, 'A_TRUE B_FALSE', '@A_TRUE@@B_FALSE@', 'A and !B'],
+ [['B_TRUE', 'FALSE'], 0, 1, 'FALSE', '#', 'FALSE'],
+ [['B_TRUE', 'B_FALSE'], 0, 1, 'FALSE', '#', 'FALSE']);
for (@tests)
{
@@ -38,6 +37,7 @@ sub test_basics ()
return 1 if $_->[2] != ($a == FALSE);
return 1 if $_->[3] ne $a->string;
return 1 if $_->[4] ne $a->subst_string;
+ return 1 if $_->[5] ne $a->human;
}
return 0;
}
@@ -240,7 +240,25 @@ sub test_reduce_or ()
return $failed;
}
-exit (test_basics || test_true_when || test_reduce_and || test_reduce_or);
+sub test_merge ()
+{
+ my $cond = new Automake::Condition "COND1_TRUE", "COND2_FALSE";
+ my $other = new Automake::Condition "COND3_FALSE";
+ my $both = $cond->merge ($other);
+ my $both2 = $cond->merge_conds ("COND3_FALSE");
+ $cond = $both->strip ($other);
+ my @conds = $cond->conds;
+ return 1 if $both->string ne "COND1_TRUE COND2_FALSE COND3_FALSE";
+ return 1 if $cond->string ne "COND1_TRUE COND2_FALSE";
+ return 1 if $both != $both2;
+ return 0;
+}
+
+exit (test_basics
+ || test_true_when
+ || test_reduce_and
+ || test_reduce_or
+ || test_merge);
### Setup "GNU" style for perl-mode and cperl-mode.
## Local Variables:
diff --git a/lib/Automake/tests/DisjCon2.pl b/lib/Automake/tests/DisjCon2.pl
new file mode 100644
index 000000000..37d886a73
--- /dev/null
+++ b/lib/Automake/tests/DisjCon2.pl
@@ -0,0 +1,24 @@
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Catch common programming error:
+# A non-Condition reference passed to new.
+
+use Automake::Condition;
+use Automake::DisjConditions;
+
+my $cond = new Automake::Condition ('TRUE');
+my $cond2 = new Automake::DisjConditions ($cond);
+new Automake::DisjConditions ($cond2);
diff --git a/lib/Automake/tests/DisjCon3.pl b/lib/Automake/tests/DisjCon3.pl
new file mode 100644
index 000000000..c0e840dd1
--- /dev/null
+++ b/lib/Automake/tests/DisjCon3.pl
@@ -0,0 +1,23 @@
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Catch common programming error:
+# A non-reference passed to new.
+
+use Automake::Condition qw/TRUE FALSE/;
+use Automake::DisjConditions;
+
+my $cond = new Automake::Condition ("COND1_TRUE");
+new Automake::DisjConditions ("$cond");
diff --git a/lib/Automake/tests/DisjConditions-t.pl b/lib/Automake/tests/DisjConditions-t.pl
index 2fe275beb..4acaed85c 100644
--- a/lib/Automake/tests/DisjConditions-t.pl
+++ b/lib/Automake/tests/DisjConditions-t.pl
@@ -1,13 +1,12 @@
-# Copyright (C) 2001, 2002, 2003, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2008, 2009, 2011 Free Software
+# Foundation, Inc.
#
-# This file is part of GNU Automake.
-#
-# GNU Automake is free software; you can redistribute it and/or modify
+# This program 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,
+# This program 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.
@@ -18,7 +17,8 @@
BEGIN {
use Config;
if (eval { require 5.007_002; } # for CLONE support
- && $Config{useithreads})
+ && $Config{useithreads}
+ && !$ENV{WANT_NO_THREADS})
{
require threads;
import threads;
@@ -33,18 +33,44 @@ use Automake::DisjConditions;
sub test_basics ()
{
+ my $true = new Automake::DisjConditions TRUE;
+ my $false = new Automake::DisjConditions FALSE;
my $cond = new Automake::Condition "COND1_TRUE", "COND2_FALSE";
return threads->new (sub {
my $other = new Automake::Condition "COND3_FALSE";
+ my $another = new Automake::Condition "COND3_TRUE", "COND4_FALSE";
return threads->new (sub {
my $set1 = new Automake::DisjConditions $cond, $other;
return threads->new (sub {
my $set2 = new Automake::DisjConditions $other, $cond;
+ my $set3 = new Automake::DisjConditions FALSE, $another;
return 1 unless $set1 == $set2;
return 1 if $set1->false;
return 1 if $set1->true;
return 1 unless (new Automake::DisjConditions)->false;
return 1 if (new Automake::DisjConditions)->true;
+ return 1 unless $true->human eq 'TRUE';
+ return 1 unless $false->human eq 'FALSE';
+ return 1 unless $set1->human eq "(COND1 and !COND2) or (!COND3)";
+ return 1 unless $set2->human eq "(COND1 and !COND2) or (!COND3)";
+ my $one_cond_human = $set1->one_cond->human;
+ return 1 unless $one_cond_human eq "!COND3"
+ || $one_cond_human eq "COND1 and !COND2";
+ return 1 unless $set1->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE";
+
+ my $merged1 = $set1->merge ($set2);
+ my $merged2 = $set1->merge ($cond);
+ my $mult1 = $set1->multiply ($set3);
+ return threads->new (sub {
+ my $mult2 = $set1->multiply ($another);
+ return threads->new (sub {
+ return 1 unless $merged1->simplify->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE";
+ return 1 unless $merged2->simplify->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE";
+ return 1 unless $mult1->string eq "COND1_TRUE COND2_FALSE COND3_TRUE COND4_FALSE";
+ return 1 unless $mult1 == $mult2;
+ return 0;
+ })->join;
+ })->join;
})->join;
})->join;
})->join;
diff --git a/lib/Automake/tests/DisjConditions.pl b/lib/Automake/tests/DisjConditions.pl
index 47dea8399..b60907b34 100644
--- a/lib/Automake/tests/DisjConditions.pl
+++ b/lib/Automake/tests/DisjConditions.pl
@@ -1,13 +1,12 @@
-# Copyright (C) 2001, 2002, 2003, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2008, 2009, 2011 Free Software
+# Foundation, Inc.
#
-# This file is part of GNU Automake.
-#
-# GNU Automake is free software; you can redistribute it and/or modify
+# This program 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,
+# This program 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.
@@ -20,15 +19,38 @@ use Automake::DisjConditions;
sub test_basics ()
{
+ my $true = new Automake::DisjConditions TRUE;
+ my $false = new Automake::DisjConditions FALSE;
my $cond = new Automake::Condition "COND1_TRUE", "COND2_FALSE";
my $other = new Automake::Condition "COND3_FALSE";
+ my $another = new Automake::Condition "COND3_TRUE", "COND4_FALSE";
my $set1 = new Automake::DisjConditions $cond, $other;
my $set2 = new Automake::DisjConditions $other, $cond;
+ my $set3 = new Automake::DisjConditions FALSE, $another;
return 1 unless $set1 == $set2;
return 1 if $set1->false;
return 1 if $set1->true;
return 1 unless (new Automake::DisjConditions)->false;
return 1 if (new Automake::DisjConditions)->true;
+ return 1 unless $true->human eq 'TRUE';
+ return 1 unless $false->human eq 'FALSE';
+ return 1 unless $set1->human eq "(COND1 and !COND2) or (!COND3)";
+ return 1 unless $set2->human eq "(COND1 and !COND2) or (!COND3)";
+ my $one_cond_human = $set1->one_cond->human;
+ return 1 unless $one_cond_human eq "!COND3"
+ || $one_cond_human eq "COND1 and !COND2";
+ return 1 unless $set1->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE";
+
+ my $merged1 = $set1->merge ($set2);
+ my $merged2 = $set1->merge ($cond);
+ my $mult1 = $set1->multiply ($set3);
+ my $mult2 = $set1->multiply ($another);
+ return 1 unless $merged1->simplify->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE";
+ return 1 unless $merged2->simplify->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE";
+ return 1 unless $mult1->string eq "COND1_TRUE COND2_FALSE COND3_TRUE COND4_FALSE";
+ return 1 unless $mult1 == $mult2;
+
+ return 0;
}
sub build_set (@)
diff --git a/lib/Automake/tests/Makefile.am b/lib/Automake/tests/Makefile.am
index c5e53d2cf..2c33a76e2 100644
--- a/lib/Automake/tests/Makefile.am
+++ b/lib/Automake/tests/Makefile.am
@@ -1,6 +1,7 @@
## Process this file with automake to create Makefile.in
-# Copyright (C) 2002, 2003, 2008, 2009 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,15 +17,40 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
PL_LOG_COMPILER = $(PERL)
-AM_PL_LOG_FLAGS = -Mstrict -I ../.. -I $(top_srcdir)/lib -w
+AM_TESTS_ENVIRONMENT = \
+ case $$am_running_installcheck in \
+ yes) am_pl_I_flags='-I $(pkgvdatadir)';; \
+ *) am_pl_I_flags='-I ../.. -I $(top_srcdir)/lib';; \
+ esac;
+AM_PL_LOG_FLAGS = -Mstrict -w $$am_pl_I_flags
TEST_EXTENSIONS = .pl
TESTS = \
Condition.pl \
Condition-t.pl \
+Cond2.pl \
+Cond3.pl \
DisjConditions.pl \
DisjConditions-t.pl \
+DisjCon2.pl \
+DisjCon3.pl \
Version.pl \
+Version2.pl \
+Version3.pl \
Wrap.pl
+XFAIL_TESTS = \
+Cond2.pl \
+Cond3.pl \
+DisjCon2.pl \
+DisjCon3.pl \
+Version2.pl \
+Version3.pl
+
EXTRA_DIST = $(TESTS)
+
+include $(top_srcdir)/CheckListOfTests.am
+
+# Run the testsuite with the installed aclocal and automake.
+installcheck-local:
+ am_running_installcheck=yes $(MAKE) $(AM_MAKEFLAGS) check
diff --git a/lib/Automake/tests/Version.pl b/lib/Automake/tests/Version.pl
index e49643519..eec0c8ed5 100644
--- a/lib/Automake/tests/Version.pl
+++ b/lib/Automake/tests/Version.pl
@@ -1,13 +1,11 @@
-# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2009, 2011 Free Software Foundation, Inc.
#
-# This file is part of GNU Automake.
-#
-# GNU Automake is free software; you can redistribute it and/or modify
+# This program 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,
+# This program 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.
@@ -42,6 +40,29 @@ sub test_version_compare
print "compare (\"$left\", \"$right\") = $res! (not $result?)\n";
$failed = 1;
}
+
+ my $check_expected = ($result == 0 || $result == 1) ? 0 : 1;
+ # Exception for 'foo' fork.
+ $check_expected = 1
+ if ($right =~ /foo/ && !($left =~ /foo/));
+
+ my $check = Automake::Version::check ($left, $right);
+ if ($check != $check_expected)
+ {
+ print "check (\"$left\", \"$right\") = $check! (not $check_expected?)\n";
+ $failed = 1;
+ }
+}
+
+sub test_bad_versions
+{
+ my ($ver) = @_;
+ my @version = Automake::Version::split ($ver);
+ if ($#version != -1)
+ {
+ print "shouldn't grok \"$ver\"\n";
+ $failed = 1;
+ }
}
my @tests = (
@@ -69,15 +90,24 @@ my @tests = (
['1.5a', '1.5.1f', 1],
['1.5', '1.5.1a', -1],
['1.5.1a', '1.5.1f', -1],
+ ['1.5.1f', '1.5.1a', 1],
+ ['1.5.1f', '1.5.1f', 0],
# special exceptions
['1.6-p5a', '1.6.5a', 0],
['1.6', '1.6-p5a', -1],
['1.6-p4b', '1.6-p5a', -1],
['1.6-p4b', '1.6-foo', 1],
- ['1.6-p4b', '1.6a-foo', -1]
+ ['1.6-p4b', '1.6a-foo', -1],
+ ['1.6-p5', '1.6.5', 0],
+ ['1.6a-foo', '1.6a-foo', 0],
+);
+
+my @bad_versions = (
+ '', 'a', '1', '1a', '1.2.3.4', '-1.2'
);
test_version_compare (@{$_}) foreach @tests;
+test_bad_versions ($_) foreach @bad_versions;
exit $failed;
diff --git a/lib/Automake/tests/Version2.pl b/lib/Automake/tests/Version2.pl
new file mode 100644
index 000000000..c1981a09a
--- /dev/null
+++ b/lib/Automake/tests/Version2.pl
@@ -0,0 +1,20 @@
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+# prog_error due to invalid $VERSION.
+
+use Automake::Version;
+
+Automake::Version::check ('', '1.2.3');
diff --git a/lib/Automake/tests/Version3.pl b/lib/Automake/tests/Version3.pl
new file mode 100644
index 000000000..7c45dc948
--- /dev/null
+++ b/lib/Automake/tests/Version3.pl
@@ -0,0 +1,20 @@
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+# prog_error due to invalid $REQUIRED.
+
+use Automake::Version;
+
+Automake::Version::check ('1.2.3', '');
diff --git a/lib/Automake/tests/Wrap.pl b/lib/Automake/tests/Wrap.pl
index 8d840fc30..79b8d3286 100644
--- a/lib/Automake/tests/Wrap.pl
+++ b/lib/Automake/tests/Wrap.pl
@@ -1,13 +1,11 @@
-# Copyright (C) 2003 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2009, 2011 Free Software Foundation, Inc.
#
-# This file is part of GNU Automake.
-#
-# GNU Automake is free software; you can redistribute it and/or modify
+# This program 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,
+# This program 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.
@@ -15,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-use Automake::Wrap 'wrap';
+use Automake::Wrap qw/wrap makefile_wrap/;
my $failed = 0;
@@ -31,6 +29,18 @@ sub test_wrap
}
}
+sub test_makefile_wrap
+{
+ my ($in, $exp_out) = @_;
+
+ my $out = &makefile_wrap (@$in);
+ if ($out ne $exp_out)
+ {
+ print STDERR "For: @$in\nGot:\n$out\nInstead of:\n$exp_out\n---\n";
+ ++$failed;
+ }
+}
+
my @tests = (
[["HEAD:", "NEXT:", "CONT", 13, "v" ,"a", "l", "ue", "s", "values"],
"HEAD:v aCONT
@@ -55,10 +65,32 @@ big continuation:diag3
"big header: END
cont: word1 END
cont: word2
+"],
+ [["big header:", "", " END", 16, "w1", "w2 ", "w3"],
+"big header: END
+w1 w2 w3
"]);
+my @makefile_tests = (
+ [["target:"],
+"target:
+"],
+ [["target:", "\t"],
+"target:
+"],
+ [["target:", "\t", "prereq1", "prereq2"],
+"target: prereq1 prereq2
+"],
+ [["target: ", "\t", "this is a long list of prerequisites ending in space",
+ "so that there is no need for another space before the backslash",
+ "unlike in the second line"],
+"target: this is a long list of prerequisites ending in space \\
+\tso that there is no need for another space before the backslash \\
+\tunlike in the second line
+"]);
test_wrap (@{$_}) foreach @tests;
+test_makefile_wrap (@{$_}) foreach @makefile_tests;
exit $failed;