if (! vardef ($silent_var, TRUE))
{
Automake::Variable::define ($silent_var, VAR_AUTOMAKE, '', TRUE,
- $val, '', INTERNAL, VAR_ASIS);
+ $val, '', INTERNAL);
}
}
if $dsubdirs;
$output_rules .= &file_contents ('subdirs', new Automake::Location);
- rvar ('RECURSIVE_TARGETS')->rdef (TRUE)->{'pretty'} = VAR_PRETTY; # Gross!
}
# be defined conditionally. The second argument is the condition
# under which the value should be defined; this should be the empty
# string to define the variable unconditionally. The third argument
-# is a list holding the values to use for the variable. The value is
-# pretty printed in the output file.
+# is a list holding the values to use for the variable.
sub define_pretty_variable ($$$@)
{
my ($var, $cond, $where, @value) = @_;
if (! vardef ($var, $cond))
{
Automake::Variable::define ($var, VAR_AUTOMAKE, '', $cond, "@value",
- '', $where, VAR_PRETTY);
+ '', $where);
rvar ($var)->rdef ($cond)->set_seen;
}
}
# substituted as `\`.
return if exists $ignored_configure_vars{$var};
Automake::Variable::define ($var, VAR_CONFIGURE, '', TRUE, subst $var,
- '', $configure_vars{$var}, VAR_ASIS);
+ '', $configure_vars{$var});
}
my $comment = '';
my $blank = 0;
my $saw_bk = 0;
- my $var_look = VAR_ASIS;
use constant IN_VAR_DEF => 0;
use constant IN_RULE_DEF => 1;
Automake::Variable::define ($last_var_name, VAR_MAKEFILE,
$last_var_type, $cond,
$last_var_value, $comment,
- $last_where, VAR_ASIS)
+ $last_where)
if $cond != FALSE;
$comment = $spacing = '';
}
# 'sed's.
$last_var_value = $3 . "\n";
}
- # Normally we try to output variable definitions in the
- # same format they were input. However, POSIX compliant
- # systems are not required to support lines longer than
- # 2048 bytes (most notably, some sed implementation are
- # limited to 4000 bytes, and sed is used by config.status
- # to rewrite Makefile.in into Makefile). Moreover nobody
- # would really write such long lines by hand since it is
- # hardly maintainable. So if a line is longer that 1000
- # bytes (an arbitrary limit), assume it has been
- # automatically generated by some tools, and flatten the
- # variable definition. Otherwise, keep the variable as it
- # as been input.
- $var_look = VAR_PRETTY if length ($last_var_value) >= 1000;
if (!/\\$/)
{
Automake::Variable::define ($last_var_name, VAR_MAKEFILE,
$last_var_type, $cond,
$last_var_value, $comment,
- $last_where, $var_look)
+ $last_where)
if $cond != FALSE;
$comment = $spacing = '';
- $var_look = VAR_ASIS;
}
}
elsif (/$INCLUDE_PATTERN/o)
Automake::Variable::define ($var,
$is_am ? VAR_AUTOMAKE : VAR_MAKEFILE,
- $type, $cond, $val, $comment, $where,
- VAR_ASIS)
+ $type, $cond, $val, $comment, $where)
if $cond != FALSE;
$comment = $spacing = '';
require Exporter;
use vars '@ISA', '@EXPORT';
@ISA = qw/Automake::ItemDef Exporter/;
-@EXPORT = qw (&VAR_AUTOMAKE &VAR_CONFIGURE &VAR_MAKEFILE
- &VAR_ASIS &VAR_PRETTY);
+@EXPORT = qw (&VAR_AUTOMAKE &VAR_CONFIGURE &VAR_MAKEFILE);
=head1 NAME
my $loc = new Automake::Location 'Makefile.am:2';
my $def = new Automake::VarDef ('foo', 'bar # more comment',
'# any comment',
- $loc, '', VAR_MAKEFILE, VAR_ASIS);
+ $loc, '', VAR_MAKEFILE);
# Appending to a definition.
$def->append ('value to append', 'comment to append');
my $location = $def->location;
my $type = $def->type;
my $owner = $def->owner;
- my $pretty = $def->pretty;
# Changing owner.
$def->set_owner (VAR_CONFIGURE,
use constant VAR_CONFIGURE => 1;# Variable defined in configure.ac.
use constant VAR_MAKEFILE => 2; # Variable defined in Makefile.am.
-=item C<VAR_ASIS>, C<VAR_PRETTY>
-
-Possible print styles. C<VAR_ASIS> variables should be output as-is.
-C<VAR_PRETTY> variables are wrapped on multiple lines if they cannot
-fit on one.
-
-=cut
-
-# Possible values for pretty.
-use constant VAR_ASIS => 0; # Output as-is.
-use constant VAR_PRETTY => 1; # Pretty printed on output.
-
=back
=head2 Methods
=over 4
-=item C<my $def = new Automake::VarDef ($varname, $value, $comment, $location, $type, $owner, $pretty)>
+=item C<my $def = new Automake::VarDef ($varname, $value, $comment, $location, $type, $owner)>
Create a new Makefile-variable definition. C<$varname> is the name of
the variable being defined and C<$value> its value.
C<VAR_AUTOMAKE>, C<VAR_CONFIGURE>, or C<VAR_MAKEFILE> (see these
definitions).
-Finally, C<$pretty> tells how the variable should be output, and can
-be one of C<VAR_ASIS>, C<VAR_PRETTY>.
-
=cut
-sub new ($$$$$$$$$)
+sub new ($$$$$$$$)
{
my ($class, $var, $value, $comment, $cond, $location, $type,
- $owner, $pretty) = @_;
+ $owner) = @_;
# A user variable must be set by either '=' or ':=', and later
# promoted to '+='.
my $self = Automake::ItemDef::new ($class, $location, $owner);
$self->{'value_list'} = [ { value => $value, cond => $cond } ];
$self->{'type'} = $type;
- $self->{'pretty'} = $pretty;
$self->{'seen'} = 0;
$self->{'comment_list'} = [ { text => $comment, cond => $cond } ];
return $self;
push @{$self->{'comment_list'}}, { text => $comment, cond => $cond };
push @{$self->{'value_list'}}, { value => $value, cond => $cond };
- # Turn ASIS appended variables into PRETTY variables. This is to
- # cope with 'make' implementation that cannot read very long lines.
- $self->{'pretty'} = VAR_PRETTY if $self->{'pretty'} == VAR_ASIS;
}
=item C<$def-E<gt>value>
=item C<$def-E<gt>type>
-=item C<$def-E<gt>pretty>
-
Accessors to the various constituents of a C<VarDef>. See the
documentation of C<new>'s arguments for a description of these.
return $self->{'type'};
}
-sub pretty ($)
-{
- my ($self) = @_;
- return $self->{'pretty'};
-}
-
=item C<$def-E<gt>set_owner ($owner, $location)>
Change the owner of a definition. This usually happens because
# Defining a variable.
Automake::Variable::define($varname, $owner, $type,
$cond, $value, $comment,
- $where, $pretty)
+ $where)
# Looking up a variable.
my $var = var $varname;
}
}
+sub _has_line_too_long ($)
+{
+ my ($text) = @_;
+ foreach my $line (split "\n", $text)
+ {
+ return 1 if length ($line) >= 1000 ;
+ }
+ return 0;
+}
+
=item C<$str = $var-E<gt>output ([@conds])>
Format all the definitions of C<$var> if C<@cond> is not specified,
my $val = $def->raw_value;
my $equals = $def->type eq ':' ? ':=' : '=';
my $str = $cond->subst_string;
-
-
- if ($def->pretty == VAR_ASIS)
- {
- my $output_var = "$name $equals $val";
- $output_var =~ s/^/$str/meg;
- $res .= "$output_var\n";
- }
- elsif ($def->pretty == VAR_PRETTY)
- {
- # Suppress escaped new lines. &makefile_wrap will
- # add them back, maybe at other places.
- $val =~ s/\\$//mg;
- my $wrap = makefile_wrap ("$str$name $equals", "$str\t",
- split (' ', $val));
-
- # If the last line of the definition is made only of
- # @substitutions@, append an empty variable to make sure it
- # cannot be substituted as a blank line (that would confuse
- # HP-UX Make).
- $wrap = makefile_wrap ("$str$name $equals", "$str\t",
- split (' ', $val), '$(am__empty)')
- if $wrap =~ /\n(\s*@\w+@)+\s*$/;
-
- $res .= $wrap;
- }
+ my $output_var;
+ # Definition of variables whose value contains unescaped newlines
+ # (likely as a result of a "+=" appending) cannot be output as-is;
+ # we need to wrap their definition. We also wrap the definition if
+ # the length of any line is too big, since POSIX-compliant systems
+ # are not required to support lines longer than 2048 bytes (most
+ # notably, some sed implementation are limited to 4000 bytes, and
+ # sed is used by config.status to rewrite Makefile.in into Makefile).
+ if (_has_line_too_long ($val) or $val =~ /(:?\\\\)*[^\\]\n./)
+ {
+ $val =~ s/\\$//mg;
+ $output_var = makefile_wrap ("$str$name $equals", "$str\t",
+ split (' ', $val));
+ }
else
- {
- prog_error ("unknonw variable type '$def->pretty'");
- }
+ {
+ $val =~ s/^[ \t]*//;
+ $output_var = "$name $equals $val";
+ $output_var =~ s/^/$str/meg;
+ }
+ $res .= "$output_var\n";
}
return $res;
}
=over 4
-=item C<Automake::Variable::define($varname, $owner, $type, $cond, $value, $comment, $where, $pretty)>
+=item C<Automake::Variable::define($varname, $owner, $type, $cond, $value, $comment, $where)>
Define or append to a new variable.
C<$where>: the C<Location> of the assignment.
-C<$pretty>: whether C<$value> should be pretty printed (one of C<VAR_ASIS>
-or C<VAR_PRETTY> defined by L<Automake::VarDef>).
-C<$pretty> applies only to real assignments. I.e., it does not apply to
-a C<+=> assignment (except when part of it is being done as a conditional
-C<=> assignment).
-
=cut
-sub define ($$$$$$$$)
+sub define ($$$$$$$)
{
- my ($var, $owner, $type, $cond, $value, $comment, $where, $pretty) = @_;
+ my ($var, $owner, $type, $cond, $value, $comment, $where) = @_;
prog_error "$cond is not a reference"
unless ref $cond;
prog_error "$where is not a reference"
unless ref $where;
- prog_error "pretty argument missing"
- unless defined $pretty && ($pretty == VAR_ASIS
- || $pretty == VAR_PRETTY);
-
# If there's a comment, make sure it is \n-terminated.
if ($comment)
{
my $num = ++$_appendvar;
my $hvar = "am__append_$num";
&define ($hvar, VAR_AUTOMAKE, '+',
- $cond, $value, $comment, $where, $pretty);
+ $cond, $value, $comment, $where);
# Now HVAR is to be added to VAR.
$comment = '';
$value = "\$($hvar)";
}
else
{
- &define ($var, $owner, '+', $vcond, $value, $comment,
- $where, $pretty);
+ &define ($var, $owner, '+', $vcond, $value, $comment, $where);
}
}
}
# locations for '+='. Ideally I suppose we would associate
# line numbers with random bits of text.
$def = new Automake::VarDef ($var, $value, $comment, $cond,
- $where->clone, $type, $owner, $pretty);
+ $where->clone, $type, $owner);
$self->set ($cond, $def);
push @_var_order, $var;
}
foreach (@conds)
{
define ($varname, VAR_AUTOMAKE, '', $_, "@result",
- '', $where, VAR_PRETTY);
+ '', $where);
}
}
}
$EGREP '^check:.* check-am( |$)' dir/Makefile.in
# Make sure subrun.sh is still on its line as above. This means Automake
-# hasn't rewritten the TESTS line unnecessarily (we can tell, because all
-# Automake variables are reformatted by VAR_PRETTY).
+# hasn't rewritten the TESTS line unnecessarily.
grep '^ subrun\.sh$' Makefile.in
:
# Test to make sure that if an auxfile (here depcomp) is required
# by a subdir Makefile.am, it is distributed by that Makefile.am.
+required=cc
. ./defs || Exit 1
cat >> configure.ac << 'END'
cat > Makefile.am << 'END'
SUBDIRS = subdir
+test-distdir: distdir
+ test -f $(distdir)/depcomp
+.PHONY: test-distdir
+check-local: test-distdir
END
rm -f depcomp
mkdir subdir
cat > subdir/Makefile.am << 'END'
-.PHONY: test-distcommon
-test-distcommon:
+.PHONY: test-distcom
+test-distcom:
echo ' ' $(am__dist_common) ' ' | $(FGREP) ' $(top_srcdir)/depcomp '
END
cat >> subdir/Makefile.am << 'END'
bin_PROGRAMS = foo
+.PHONY: test-distcom
+test-distcom:
+ echo ' ' $(am__dist_common) ' ' | $(FGREP) ' $(top_srcdir)/depcomp '
+check-local: test-distcom
END
-: > subdir/foo.c
+cat > subdir/foo.c <<'END'
+int main (void)
+{
+ return 0;
+}
+END
$AUTOMAKE -a subdir/Makefile
test -f depcomp
+
./configure
-(cd subdir && $MAKE test-distcommon)
-$MAKE distdir
-test -f $distdir/depcomp
+(cd subdir && $MAKE test-distcom)
+$MAKE test-distdir
+
+$MAKE distcheck
:
test -f depcomp
for dir in . subdir; do
- # FIXME: the logic of this check and other similar ones in other
- # FIXME: 'distcom*.test' files should be factored out in a common
- # FIXME: subroutine in 'defs'...
- sed -n -e "
- /^am__dist_common =.*\\\\$/ {
- :loop
- p
- n
- t clear
- :clear
- s/\\\\$/\\\\/
- t loop
- s/$/ /
- s/[$tab ][$tab ]*/ /g
- p
- n
- }" $dir/Makefile.in > $dir/dc.txt
+ sed -n 's/^am__dist_common = *\(.*\)$/ \1 /p' \
+ <$dir/Makefile.in >$dir/dc.txt
done
cat dc.txt # For debugging.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Long lines of += should be wrapped.
+# Long lines of = and += should be wrapped.
# Report from Simon Josefsson.
. ./defs || Exit 1
-(echo DUMMY = some_long_filename_1;
-for i in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20;
-do
- echo DUMMY += some_long_filename_$i
-done) > Makefile.am
+i=0
+while test $i -lt 30; do
+ echo some_very_very_long_variable_content_$i
+ i=$((i + 1))
+done > t
+
+{ echo "DUMMY =" && sed 's/^/DUMMY +=/' t; } > Makefile.am
+{ echo "ZARDOZ =" && cat t; } | tr '\012\015' ' ' >> Makefile.am
$ACLOCAL
$AUTOMAKE
+grep long_variable Makefile.in # For debugging.
test 80 -ge `grep DUMMY Makefile.in | wc -c`
+test 80 -ge `grep ZARDOZ Makefile.in | wc -c`
+
+:
$AUTOMAKE
grep '^@CHECK_TRUE@data_DATA = zarrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr \\$' Makefile.in
-grep "^@CHECK_TRUE@${tab}doz$" Makefile.in
+grep "^@CHECK_TRUE@[ $tab]*doz$" Makefile.in
grep '^@CHECK_FALSE@data_DATA = dog$' Makefile.in
END
cat > lib/foo.c << 'END'
-int foo () {}
+int foo (void) { return 0; }
END
cat > src/Makefile.am << 'END'
$ACLOCAL
$AUTOMAKE --gnu
-# Make sure that depcomp is *not* included in the definition
-# of am__dist_common in lib/Makefile.in. If you change this test
-# so that more files are included in lib's am__dist_common definition,
-# then you must handle the case in which depcomp is listed on a
-# continued line.
-grep '^am__dist_common.*depcomp' lib/Makefile.in && Exit 1
-
:
+++ /dev/null
-#! /bin/sh
-# Copyright (C) 2003-2012 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/>.
-
-# If the last line of a automake-rewritten definition is made only of
-# @substitutions@, automake should take care of appending an empty
-# variable to make sure that line cannot end up substituted as a blank
-# line (that would confuse HP-UX Make).
-# These checks have been introduced in commit 'Release-1-9-254-g9d0eaef'
-# into the former test 'subst2.test'.
-
-. ./defs || Exit 1
-
-# These are deliberately quite long, so that the xxx_PROGRAMS definition
-# in Makefile.am below will be split on multiple lines, with the last
-# line containing only @substituted@ stuff that expands to empty (this is
-# required to expose the bug we are testing).
-v1=ABCDEFGHIJKLMNOPQRSTUVWX
-v2=ABCDEFGHIJKLMNOPQRSTUVWXY
-v3=ABCDEFGHIJKLMNOPQRSTUVWXYZ
-
-# Literal backslash for use by grep.
-bs='\\'
-
-cat >> configure.ac <<END
-AC_SUBST([A], [''])
-AC_SUBST([$v1], [''])
-AC_SUBST([$v2], [''])
-AC_SUBST([$v3], [''])
-AC_OUTPUT
-END
-
-cat >Makefile.am <<END
-AUTOMAKE_OPTIONS = no-dependencies
-CC = false
-EXEEXT =
-
-## The "x" and "zardoz" strings and the use of '+=' are there to ensure
-## that these variables get rewritten by Automake.
-noinst_PROGRAMS = x @$v1@ @$v2@ @$v3@
-bin_PROGRAMS = @A@
-bin_PROGRAMS += @$v1@ @$v2@ @$v3@
-check_PROGRAMS = zardoz \$(noinst_PROGRAMS)
-
-## Required whenever there are @substituted@ values in the
-## PROGRAMS primary, otherwise automake will complain.
-EXTRA_PROGRAMS =
-
-print-programs:
- @echo BEG1: \$(noinst_PROGRAMS) :END1
- @echo BEG2: \$(bin_PROGRAMS) :END2
- @echo BEG3: \$(check_PROGRAMS) :END3
-END
-
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE
-# For debugging.
-$EGREP -n 'ABCD|am__empty' Makefile.in
-# Sanity check.
-test `$EGREP -c "^[ $tab]*@$v2@ @$v3@[ $tab]*$bs?$" Makefile.in` -eq 3
-
-./configure
-{
- sed -n '/^noinst_PROGRAMS *=/,/[^\\]$/p' Makefile
- sed -n '/^bin_PROGRAMS *=/,/[^\\]$/p' Makefile
- sed -n '/^check_PROGRAMS *=/,/[^\\]$/p' Makefile
- sed -n '/^am__EXEEXT.*=/,/[^\\]$/p' Makefile
-} >t-programs
-cat t-programs
-grep '^ *$' t-programs && Exit 1
-
-$MAKE print-programs >stdout || { cat stdout; Exit 1; }
-cat stdout
-grep '^BEG1: x :END1$' stdout
-grep '^BEG2: :END2$' stdout
-grep '^BEG3: zardoz x :END3$' stdout
-
-$MAKE am__empty=X print-programs >stdout || { cat stdout; Exit 1; }
-cat stdout
-grep '^BEG1: x X :END1$' stdout
-grep '^BEG2: X :END2$' stdout
-grep '^BEG3: zardoz x X :END3$' stdout
-
-: