mirror of
https://github.com/mirror/make.git
synced 2025-03-27 20:40:35 +08:00
- Update manual description for pattern rule search algorithm
- Add new "-all" flag to the test suite to run tests that don't pass yet - Add some non-passing tests - Fix from Andreas Buening for OS/2.
This commit is contained in:
parent
f5891a26d8
commit
f907a4d90c
16
ChangeLog
16
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
2009-09-28 Paul Smith <psmith@gnu.org>
|
||||||
|
|
||||||
|
* doc/make.texi (Pattern Intro): Move the match algorithm
|
||||||
|
discussion into the "Pattern Match" node.
|
||||||
|
(Pattern Match): Expand on the pattern rule matching algorithm.
|
||||||
|
|
||||||
|
2009-09-28 Andreas Buening <andreas.buening@nexgo.de>
|
||||||
|
|
||||||
|
* job.c (construct_command_argv_internal) [OS2]: Don't eat too
|
||||||
|
much of the command line on a single pass.
|
||||||
|
|
||||||
2009-09-28 Boris Kolpackov <boris@codesynthesis.com>
|
2009-09-28 Boris Kolpackov <boris@codesynthesis.com>
|
||||||
|
|
||||||
* varible.c (create_pattern_var): Insert variables into the
|
* varible.c (create_pattern_var): Insert variables into the
|
||||||
@ -18,6 +29,11 @@
|
|||||||
|
|
||||||
* NEWS: Add a note about the new behavior.
|
* NEWS: Add a note about the new behavior.
|
||||||
|
|
||||||
|
2009-09-27 Paul Smith <psmith@gnu.org>
|
||||||
|
|
||||||
|
* doc/make.texi (Double-Colon): Mention that pattern rules with
|
||||||
|
double-colons have a different meaning. Savannah bug #27497.
|
||||||
|
|
||||||
2009-09-27 Juan Manuel Guerrero <juan.guerrero@gmx.de>
|
2009-09-27 Juan Manuel Guerrero <juan.guerrero@gmx.de>
|
||||||
|
|
||||||
* configh.dos.template: Remove unconditional definition of
|
* configh.dos.template: Remove unconditional definition of
|
||||||
|
@ -3190,9 +3190,11 @@ to precisely the targets specified.
|
|||||||
@cindex multiple rules for one target (@code{::})
|
@cindex multiple rules for one target (@code{::})
|
||||||
@cindex @code{::} rules (double-colon)
|
@cindex @code{::} rules (double-colon)
|
||||||
|
|
||||||
@dfn{Double-colon} rules are rules written with @samp{::} instead of
|
@dfn{Double-colon} rules are explicit rules written with @samp{::}
|
||||||
@samp{:} after the target names. They are handled differently from
|
instead of @samp{:} after the target names. They are handled
|
||||||
ordinary rules when the same target appears in more than one rule.
|
differently from ordinary rules when the same target appears in more
|
||||||
|
than one rule. Pattern rules with double-colons have an entirely
|
||||||
|
different meaning (@pxref{Match-Anything Rules}).
|
||||||
|
|
||||||
When a target appears in multiple rules, all the rules must be the same
|
When a target appears in multiple rules, all the rules must be the same
|
||||||
type: all ordinary, or all double-colon. If they are double-colon, each
|
type: all ordinary, or all double-colon. If they are double-colon, each
|
||||||
@ -9148,6 +9150,10 @@ in fact any prerequisites at all. Such a rule is effectively a general
|
|||||||
wildcard. It provides a way to make any file that matches the target
|
wildcard. It provides a way to make any file that matches the target
|
||||||
pattern. @xref{Last Resort}.
|
pattern. @xref{Last Resort}.
|
||||||
|
|
||||||
|
More than one pattern rule may match a target. In this case
|
||||||
|
@code{make} will choose the ``best fit'' rule. @xref{Pattern Match,
|
||||||
|
,How Patterns Match}.
|
||||||
|
|
||||||
@c !!! The end of of this paragraph should be rewritten. --bob
|
@c !!! The end of of this paragraph should be rewritten. --bob
|
||||||
Pattern rules may have more than one target. Unlike normal rules,
|
Pattern rules may have more than one target. Unlike normal rules,
|
||||||
this does not act as many different rules with the same prerequisites
|
this does not act as many different rules with the same prerequisites
|
||||||
@ -9163,33 +9169,6 @@ updated themselves.
|
|||||||
@cindex multiple targets, in pattern rule
|
@cindex multiple targets, in pattern rule
|
||||||
@cindex target, multiple in pattern rule
|
@cindex target, multiple in pattern rule
|
||||||
|
|
||||||
It is possible that several pattern rules can be used to update a
|
|
||||||
target. In this case @code{make} considers rules which produce
|
|
||||||
shorter stems first. This results in more specific rules being
|
|
||||||
preferred to the more generic ones, for example:
|
|
||||||
|
|
||||||
@example
|
|
||||||
%.o: %.c
|
|
||||||
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@@
|
|
||||||
|
|
||||||
lib/%.o: lib/%.c
|
|
||||||
$(CC) -fPIC -c $(CFLAGS) $(CPPFLAGS) $< -o $@@
|
|
||||||
|
|
||||||
all: foo.o lib/bar.o
|
|
||||||
@end example
|
|
||||||
|
|
||||||
In this example the second rule will be used to update @file{lib/bar.o}
|
|
||||||
even though the first rule can also be used.
|
|
||||||
|
|
||||||
Pattern rules which result in the same stem length are considered in
|
|
||||||
the order in which they appear in the makefile. Of equally applicable
|
|
||||||
rules, only the first one found is used. The rules you write take
|
|
||||||
precedence over those that are built in. Note however, that a rule whose
|
|
||||||
prerequisites actually exist or are mentioned always takes priority over a
|
|
||||||
rule with prerequisites that must be made by chaining other implicit rules.
|
|
||||||
@cindex pattern rules, order of
|
|
||||||
@cindex order of pattern rules
|
|
||||||
|
|
||||||
@node Pattern Examples, Automatic Variables, Pattern Intro, Pattern Rules
|
@node Pattern Examples, Automatic Variables, Pattern Intro, Pattern Rules
|
||||||
@subsection Pattern Rule Examples
|
@subsection Pattern Rule Examples
|
||||||
|
|
||||||
@ -9502,6 +9481,50 @@ rest of the stem is substituted for the @samp{%}. The stem
|
|||||||
@samp{src/a} with a prerequisite pattern @samp{c%r} gives the file name
|
@samp{src/a} with a prerequisite pattern @samp{c%r} gives the file name
|
||||||
@file{src/car}.@refill
|
@file{src/car}.@refill
|
||||||
|
|
||||||
|
@cindex pattern rules, order of
|
||||||
|
@cindex order of pattern rules
|
||||||
|
A pattern rule can be used to build a given file only if there is a
|
||||||
|
target pattern that matches the file name, @emph{and} all
|
||||||
|
prerequisites in that rule either exist or can be built. The rules
|
||||||
|
you write take precedence over those that are built in. Note however,
|
||||||
|
that a rule whose prerequisites actually exist or are mentioned always
|
||||||
|
takes priority over a rule with prerequisites that must be made by
|
||||||
|
chaining other implicit rules.
|
||||||
|
|
||||||
|
@cindex stem, shortest
|
||||||
|
It is possible that more than one pattern rule will meet these
|
||||||
|
criteria. In that case, @code{make} will choose the rule with the
|
||||||
|
shortest stem (that is, the pattern that matches most specifically).
|
||||||
|
If more than one pattern rule has the shortest stem, @code{make} will
|
||||||
|
choose the first one found in the makefile.
|
||||||
|
|
||||||
|
This algorithm results in more specific rules being preferred over
|
||||||
|
more generic ones; for example:
|
||||||
|
|
||||||
|
@example
|
||||||
|
%.o: %.c
|
||||||
|
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@@
|
||||||
|
|
||||||
|
%.o : %.f
|
||||||
|
$(COMPILE.F) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
|
lib/%.o: lib/%.c
|
||||||
|
$(CC) -fPIC -c $(CFLAGS) $(CPPFLAGS) $< -o $@@
|
||||||
|
@end example
|
||||||
|
|
||||||
|
Given these rules and asked to build @file{bar.o} where both
|
||||||
|
@file{bar.c} and @file{bar.f} exist, @code{make} will choose the first
|
||||||
|
rule and compile @file{bar.c} into @file{bar.o}. In the same
|
||||||
|
situation where @file{bar.c} does not exist, then @code{make} will
|
||||||
|
choose the second rule and compile @file{bar.f} into @file{bar.o}.
|
||||||
|
|
||||||
|
If @code{make} is asked to build @file{lib/bar.o} and both
|
||||||
|
@file{lib/bar.c} and @file{lib/bar.f} exist, then the third rule will
|
||||||
|
be chosen since the stem for this rule (@samp{bar}) is shorter than
|
||||||
|
the stem for the first rule (@samp{lib/bar}). If @file{lib/bar.c}
|
||||||
|
does not exist then the third rule is not eligible and the second rule
|
||||||
|
will be used, even though the stem is longer.
|
||||||
|
|
||||||
@node Match-Anything Rules, Canceling Rules, Pattern Match, Pattern Rules
|
@node Match-Anything Rules, Canceling Rules, Pattern Match, Pattern Rules
|
||||||
@subsection Match-Anything Pattern Rules
|
@subsection Match-Anything Pattern Rules
|
||||||
|
|
||||||
|
7
job.c
7
job.c
@ -2845,8 +2845,11 @@ construct_command_argv_internal (char *line, char **restp, char *shell,
|
|||||||
char *p = new_line;
|
char *p = new_line;
|
||||||
char *q = new_line;
|
char *q = new_line;
|
||||||
memcpy (new_line, line, line_len + 1);
|
memcpy (new_line, line, line_len + 1);
|
||||||
/* replace all backslash-newline combination and also following tabs */
|
/* Replace all backslash-newline combination and also following tabs.
|
||||||
while (*q != '\0')
|
Important: stop at the first '\n' because that's what the loop above
|
||||||
|
did. The next line starting at restp[0] will be executed during the
|
||||||
|
next call of this function. */
|
||||||
|
while (*q != '\0' && *q != '\n')
|
||||||
{
|
{
|
||||||
if (q[0] == '\\' && q[1] == '\n')
|
if (q[0] == '\\' && q[1] == '\n')
|
||||||
q += 2; /* remove '\\' and '\n' */
|
q += 2; /* remove '\\' and '\n' */
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
2009-09-28 Paul Smith <psmith@gnu.org>
|
||||||
|
|
||||||
|
* scripts/functions/shell: Add regression test for Savannah bug
|
||||||
|
#20513 (still open).
|
||||||
|
|
||||||
|
* scripts/features/se_explicit: Add regression tests for Savannah
|
||||||
|
bug #25780 (still open).
|
||||||
|
|
||||||
|
* run_make_tests.pl (valid_option): Add a new flag, -all([-_]?tests)?
|
||||||
|
that runs tests we know will fail. This allows us to add
|
||||||
|
regression tests to the test suite for bugs that haven't been
|
||||||
|
fixed yet.
|
||||||
|
|
||||||
2009-09-28 Boris Kolpackov <boris@codesynthesis.com>
|
2009-09-28 Boris Kolpackov <boris@codesynthesis.com>
|
||||||
|
|
||||||
* scripts/features/patspecific_vars: Add a test for the shortest
|
* scripts/features/patspecific_vars: Add a test for the shortest
|
||||||
|
@ -37,6 +37,8 @@ $pure_log = undef;
|
|||||||
|
|
||||||
$command_string = '';
|
$command_string = '';
|
||||||
|
|
||||||
|
$all_tests = 0;
|
||||||
|
|
||||||
require "test_driver.pl";
|
require "test_driver.pl";
|
||||||
|
|
||||||
# Some target systems might not have the POSIX module...
|
# Some target systems might not have the POSIX module...
|
||||||
@ -48,15 +50,18 @@ sub valid_option
|
|||||||
{
|
{
|
||||||
local($option) = @_;
|
local($option) = @_;
|
||||||
|
|
||||||
if ($option =~ /^-make([-_]?path)?$/)
|
if ($option =~ /^-make([-_]?path)?$/i) {
|
||||||
{
|
$make_path = shift @argv;
|
||||||
$make_path = shift @argv;
|
if (!-f $make_path) {
|
||||||
if (!-f $make_path)
|
print "$option $make_path: Not found.\n";
|
||||||
{
|
exit 0;
|
||||||
print "$option $make_path: Not found.\n";
|
}
|
||||||
exit 0;
|
return 1;
|
||||||
}
|
}
|
||||||
return 1;
|
|
||||||
|
if ($option =~ /^-all([-_]?tests)?$/i) {
|
||||||
|
$all_tests = 1;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($option =~ /^-(valgrind|memcheck)$/i) {
|
if ($option =~ /^-(valgrind|memcheck)$/i) {
|
||||||
|
@ -130,5 +130,32 @@ endef
|
|||||||
!,
|
!,
|
||||||
'', "#MAKE#: *** prerequisites cannot be defined in recipes. Stop.\n", 512);
|
'', "#MAKE#: *** prerequisites cannot be defined in recipes. Stop.\n", 512);
|
||||||
|
|
||||||
|
|
||||||
|
if ($all_tests) {
|
||||||
|
# Automatic $$+ variable expansion issue. Savannah bug #25780
|
||||||
|
run_make_test(q!
|
||||||
|
all : foo foo
|
||||||
|
.SECONDEXPANSION:
|
||||||
|
all : $$+ ; @echo '$+'
|
||||||
|
foo : ;
|
||||||
|
!,
|
||||||
|
'', "foo foo foo foo\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($all_tests) {
|
||||||
|
# Automatic $$+ variable expansion issue. Savannah bug #25780
|
||||||
|
run_make_test(q!
|
||||||
|
all : bar bar
|
||||||
|
bar : ;
|
||||||
|
q%x : ;
|
||||||
|
.SECONDEXPANSION:
|
||||||
|
a%l: q1x $$+ q2x ; @echo '$+'
|
||||||
|
!,
|
||||||
|
'', "q1x bar bar q2x bar bar\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# This tells the test driver that the perl test script executed properly.
|
# This tells the test driver that the perl test script executed properly.
|
||||||
1;
|
1;
|
||||||
|
@ -11,6 +11,15 @@ all: ; @echo $(shell echo hi)
|
|||||||
','','hi');
|
','','hi');
|
||||||
|
|
||||||
|
|
||||||
|
# Test unescaped comment characters in shells. Savannah bug #20513
|
||||||
|
if ($all_tests) {
|
||||||
|
run_make_test(q!
|
||||||
|
FOO := $(shell echo '#')
|
||||||
|
foo: ; echo '$(FOO)'
|
||||||
|
!,
|
||||||
|
'', "#\n");
|
||||||
|
}
|
||||||
|
|
||||||
# Test shells inside exported environment variables.
|
# Test shells inside exported environment variables.
|
||||||
# This is the test that fails if we try to put make exported variables into
|
# This is the test that fails if we try to put make exported variables into
|
||||||
# the environment for a $(shell ...) call.
|
# the environment for a $(shell ...) call.
|
||||||
|
@ -461,6 +461,7 @@ sub run_each_test
|
|||||||
# Run the actual test!
|
# Run the actual test!
|
||||||
$tests_run = 0;
|
$tests_run = 0;
|
||||||
$tests_passed = 0;
|
$tests_passed = 0;
|
||||||
|
|
||||||
$code = do $perl_testname;
|
$code = do $perl_testname;
|
||||||
|
|
||||||
$total_tests_run += $tests_run;
|
$total_tests_run += $tests_run;
|
||||||
|
Loading…
Reference in New Issue
Block a user