diff --git a/Configure b/Configure index 7b3e6ccbd3..737a471c1d 100755 --- a/Configure +++ b/Configure @@ -1857,6 +1857,34 @@ if ($builder eq "unified") { } }; + # Support for pushing values on multiple indexes of a given hash + # array. + my $push_to = sub { + my $valueref = shift; + my $index_str = shift; # May be undef or empty + my $attrref = shift; # May be undef + my $attr_str = shift; + my @values = @_; + + if (defined $index_str) { + my @indexes = ( '' ); + if ($index_str !~ m|^\s*$|) { + @indexes = tokenize($index_str); + } + foreach (@indexes) { + push @{$valueref->{$_}}, @values; + if (defined $attrref) { + $handle_attributes->($attr_str, \$$attrref->{$_}, + @values); + } + } + } else { + push @$valueref, @values; + $handle_attributes->($attr_str, $attrref, @values) + if defined $attrref; + } + }; + # We want to detect configdata.pm in the source tree, so we # don't use it if the build tree is different. my $src_configdata = cleanfile($srcdir, "configdata.pm", $blddir); @@ -1937,88 +1965,64 @@ if ($builder eq "unified") { } }, qr/^\s* PROGRAMS ${attribs_re} \s* = ${value_re} $/x - => sub { - if (!@skip || $skip[$#skip] > 0) { - my @p = tokenize($expand_variables->($+{VALUE})); - push @programs, @p; - $handle_attributes->($+{ATTRIBS}, - \$attributes{programs}, - @p); - } - }, + => sub { $push_to->(\@programs, undef, + \$attributes{programs}, $+{ATTRIBS}, + tokenize($expand_variables->($+{VALUE}))) + if !@skip || $skip[$#skip] > 0; }, qr/^\s* LIBS ${attribs_re} \s* = ${value_re} $/x - => sub { - if (!@skip || $skip[$#skip] > 0) { - my @l = tokenize($expand_variables->($+{VALUE})); - push @libraries, @l; - $handle_attributes->($+{ATTRIBS}, - \$attributes{libraries}, - @l); - } - }, + => sub { $push_to->(\@libraries, undef, + \$attributes{libraries}, $+{ATTRIBS}, + tokenize($expand_variables->($+{VALUE}))) + if !@skip || $skip[$#skip] > 0; }, qr/^\s* MODULES ${attribs_re} \s* = ${value_re} $/x - => sub { - if (!@skip || $skip[$#skip] > 0) { - my @m = tokenize($expand_variables->($+{VALUE})); - push @modules, @m; - $handle_attributes->($+{ATTRIBS}, - \$attributes{modules}, - @m); - } - }, + => sub { $push_to->(\@modules, undef, + \$attributes{modules}, $+{ATTRIBS}, + tokenize($expand_variables->($+{VALUE}))) + if !@skip || $skip[$#skip] > 0; }, qr/^\s* SCRIPTS ${attribs_re} \s* = ${value_re} $/x - => sub { - if (!@skip || $skip[$#skip] > 0) { - my @s = tokenize($expand_variables->($+{VALUE})); - push @scripts, @s; - $handle_attributes->($+{ATTRIBS}, - \$attributes{scripts}, - @s); - } - }, + => sub { $push_to->(\@scripts, undef, + \$attributes{scripts}, $+{ATTRIBS}, + tokenize($expand_variables->($+{VALUE}))) + if !@skip || $skip[$#skip] > 0; }, qr/^\s* HTMLDOCS ${index_re} = ${value_re} $/x - => sub { push @{$htmldocs{$expand_variables->($+{INDEX})}}, - tokenize($expand_variables->($+{VALUE})) - if !@skip || $skip[$#skip] > 0 }, + => sub { $push_to->(\%htmldocs, $expand_variables->($+{INDEX}), + undef, undef, + tokenize($expand_variables->($+{VALUE}))) + if !@skip || $skip[$#skip] > 0; }, qr/^\s* MANDOCS ${index_re} = ${value_re} $/x - => sub { push @{$mandocs{$expand_variables->($+{INDEX})}}, - tokenize($expand_variables->($+{VALUE})) - if !@skip || $skip[$#skip] > 0 }, - qr/^\s* ORDINALS ${index_re} = ${value_re} $/x - => sub { push @{$ordinals{$expand_variables->($+{INDEX})}}, - tokenize($expand_variables->($+{VALUE})) - if !@skip || $skip[$#skip] > 0 }, + => sub { $push_to->(\%mandocs, $expand_variables->($+{INDEX}), + undef, undef, + tokenize($expand_variables->($+{VALUE}))) + if !@skip || $skip[$#skip] > 0; }, qr/^\s* SOURCE ${index_re} = ${value_re} $/x - => sub { push @{$sources{$expand_variables->($+{INDEX})}}, - tokenize($expand_variables->($+{VALUE})) - if !@skip || $skip[$#skip] > 0 }, + => sub { $push_to->(\%sources, $expand_variables->($+{INDEX}), + undef, undef, + tokenize($expand_variables->($+{VALUE}))) + if !@skip || $skip[$#skip] > 0; }, qr/^\s* SHARED_SOURCE ${index_re} = ${value_re} $/x - => sub { push @{$shared_sources{$expand_variables->($+{INDEX})}}, - tokenize($expand_variables->($+{VALUE})) - if !@skip || $skip[$#skip] > 0 }, + => sub { $push_to->(\%shared_sources, $expand_variables->($+{INDEX}), + undef, undef, + tokenize($expand_variables->($+{VALUE}))) + if !@skip || $skip[$#skip] > 0; }, qr/^\s* INCLUDE ${index_re} = ${value_re} $/x - => sub { push @{$includes{$expand_variables->($+{INDEX})}}, - tokenize($expand_variables->($+{VALUE})) - if !@skip || $skip[$#skip] > 0 }, + => sub { $push_to->(\%includes, $expand_variables->($+{INDEX}), + undef, undef, + tokenize($expand_variables->($+{VALUE}))) + if !@skip || $skip[$#skip] > 0; }, qr/^\s* DEFINE ${index_re} = ${value_re} $/x - => sub { push @{$defines{$expand_variables->($+{INDEX})}}, - tokenize($expand_variables->($+{VALUE})) - if !@skip || $skip[$#skip] > 0 }, + => sub { $push_to->(\%defines, $expand_variables->($+{INDEX}), + undef, undef, + tokenize($expand_variables->($+{VALUE}))) + if !@skip || $skip[$#skip] > 0; }, qr/^\s* DEPEND ${index_re} ${attribs_re} = ${value_re} $/x - => sub { - if (!@skip || $skip[$#skip] > 0) { - my $i = $expand_variables->($+{INDEX}); - my @d = tokenize($expand_variables->($+{VALUE})); - push @{$depends{$i}}, @d; - $handle_attributes->($+{ATTRIBS}, - \$attributes{depends}->{$i}, - @d); - } - }, + => sub { $push_to->(\%depends, $expand_variables->($+{INDEX}), + \$attributes{depends}, $+{ATTRIBS}, + tokenize($expand_variables->($+{VALUE}))) + if !@skip || $skip[$#skip] > 0; }, qr/^\s* GENERATE ${index_re} = ${value_re} $/x - => sub { push @{$generate{$expand_variables->($+{INDEX})}}, - $+{VALUE} - if !@skip || $skip[$#skip] > 0 }, + => sub { $push_to->(\%generate, $expand_variables->($+{INDEX}), + undef, undef, $+{VALUE}) + if !@skip || $skip[$#skip] > 0; }, qr/^\s* (?:\#.*)? $/x => sub { }, "OTHERWISE" => sub { die "Something wrong with this line:\n$_\nat $sourced/$f" }, "BEFORE" => sub { diff --git a/doc/internal/man7/build.info.pod b/doc/internal/man7/build.info.pod index 2be709f770..c2020a432f 100644 --- a/doc/internal/man7/build.info.pod +++ b/doc/internal/man7/build.info.pod @@ -24,7 +24,7 @@ B I ... B I ... -BIB<]=> I ... +BIB<]=> I ... BIB<]=> I I ... @@ -32,9 +32,9 @@ BIB<]=> I ... BIB<]=> I ... -BIB<]=> I[B<=>I] ... +BIB<]=> I[B<=>I] ... -BIB<]=> I ... +BIB<]=> I ... B<$>IB<=>I @@ -122,7 +122,7 @@ syntax is one of: =item B> B<=> I ... -=item B[>IB<]> B<=> I ... +=item B[>IB<]> B<=> I ... =back @@ -154,8 +154,14 @@ F and F, and that it depends on the library C (in other words, the library will be included when linking that program together). -For any indexed statement for which the item hasn't been specified -through any plain statement, or where the item exists but the indexed +Multiple space separated items are allowed too: + + SOURCE[foo]=foo.c + SOURCE[details]=details.c + DEPEND[foo details]=libcookie + +For any indexed statement for which the items haven't been specified +through any plain statement, or where the items exists but the indexed statement does not apply, the value is simply ignored by the build file generators. @@ -169,7 +175,7 @@ variations on how they are treated. =item B{> I | IB<=>I [,...]B<}> B<=> I ... -=item B[>IB<]{> I | IB<=>I +=item B[>IB<]{> I | IB<=>I [,...]B<}> B<=> I ... =back @@ -411,15 +417,15 @@ C, while the script C will. =over 4 -=item BIB<]> B<=> I ... +=item BIB<]> B<=> I ... -Collects dependencies, where I depends on the given Is. +Collects dependencies, where I depend on the given Is. -As a special case, the I may be empty, for which the build file +As a special case, the I may be empty, for which the build file generators should make the whole build depend on the given Is, -rather than some specific I. +rather than the specific I. -The I may be any program, library, module, script, or any +The I may be any program, library, module, script, or any filename used as a value anywhere. B statements may have attributes, which apply to each @@ -473,19 +479,19 @@ given with B or B. For libraries, the given filenames are only used for their shared form, so if the item is a library name ending with C<.a>, the filenames will be ignored. -=item BIB<]> B<=> I[B<=>I] ... +=item BIB<]> B<=> I[B<=>I] ... Collects I / I pairs (or just I with no defined -value if no I is given) associated with I. +value if no I is given) associated with I. The build file generators will decide what to do with them. For example, these pairs should become C macro definitions whenever a C<.c> file is built into an object file. -=item BIB<]> B<=> I ... +=item BIB<]> B<=> I ... Collects inclusion directories that will be used when building the -I components (object files and whatever else). This is used at +I components (object files and whatever else). This is used at the discretion of the build file generators. =back @@ -568,7 +574,7 @@ the exception of conditional statements and variable assignments. =item "indexed statement" -Any F statement of the form B[>IB<]=>I, +Any F statement of the form B[>IB<]=>I, with the exception of conditional statements. =item "intermediate file"