mirror of
https://github.com/mirror/make.git
synced 2025-01-04 01:10:26 +08:00
[SV 28456] Don't override $< when no default rule has been defined
The check for matching a file's command to the default rule's command does not account for null. If no .DEFAULT is defined a rule with no recipe has it's $< variable set to the value of $@. This breaks second expansion, particularly when used with pattern rules. * src/commands.c [set_file_variables]: Check that cmds is set * tests/scripts/features/se_explicit: Test case * tests/scripts/features/se_implicit: Test case Copyright-paperwork-exempt: yes
This commit is contained in:
parent
4d00ceba26
commit
ee167c650e
@ -140,7 +140,7 @@ set_file_variables (struct file *file)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file->cmds == default_file->cmds)
|
if (file->cmds != 0 && file->cmds == default_file->cmds)
|
||||||
/* This file got its commands from .DEFAULT.
|
/* This file got its commands from .DEFAULT.
|
||||||
In this case $< is the same as $@. */
|
In this case $< is the same as $@. */
|
||||||
less = at;
|
less = at;
|
||||||
|
@ -190,4 +190,14 @@ libcat.a: ; @touch $@
|
|||||||
#MAKEFILE#:16: Recipe for 'libcat.a' will be ignored in favor of the one for '-lcat'.!);
|
#MAKEFILE#:16: Recipe for 'libcat.a' will be ignored in favor of the one for '-lcat'.!);
|
||||||
unlink('libcat.a');
|
unlink('libcat.a');
|
||||||
|
|
||||||
|
# SV 28456 : Don't reset $$< for default recipes
|
||||||
|
run_make_test(q!
|
||||||
|
.SECONDEXPANSION:
|
||||||
|
|
||||||
|
.PHONY: biz baz
|
||||||
|
biz: baz ;
|
||||||
|
biz: $$(info $$<)
|
||||||
|
!,
|
||||||
|
'', "baz\n#MAKE#: Nothing to be done for 'biz'.\n");
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# -*-perl-*-
|
# -*-perl-*-
|
||||||
$description = "Test second expansion in ordinary rules.";
|
$description = "Test second expansion in implicit rules.";
|
||||||
|
|
||||||
$details = "";
|
$details = "";
|
||||||
|
|
||||||
@ -24,8 +24,7 @@ foo.%: 1.$$@ \
|
|||||||
$$(addprefix 3.,$$^) \
|
$$(addprefix 3.,$$^) \
|
||||||
$$(addprefix 4.,$$+) \
|
$$(addprefix 4.,$$+) \
|
||||||
5.$$| \
|
5.$$| \
|
||||||
6.$$*
|
6.$$* ; @:
|
||||||
@:
|
|
||||||
|
|
||||||
1.foo.a \
|
1.foo.a \
|
||||||
2.bar \
|
2.bar \
|
||||||
@ -36,8 +35,7 @@ foo.%: 1.$$@ \
|
|||||||
4.baz \
|
4.baz \
|
||||||
4.biz \
|
4.biz \
|
||||||
5.buz \
|
5.buz \
|
||||||
6.a:
|
6.a: ; @echo '$@'
|
||||||
@echo '$@'
|
|
||||||
|
|
||||||
!,
|
!,
|
||||||
'',
|
'',
|
||||||
@ -64,8 +62,7 @@ run_make_test(q!
|
|||||||
.SECONDEXPANSION:
|
.SECONDEXPANSION:
|
||||||
foo.x:
|
foo.x:
|
||||||
|
|
||||||
foo.%: $$(%_a) $$(%_b) bar
|
foo.%: $$(%_a) $$(%_b) bar ; @:
|
||||||
@:
|
|
||||||
|
|
||||||
foo.x: x_a := bar
|
foo.x: x_a := bar
|
||||||
|
|
||||||
@ -137,8 +134,7 @@ $(dir)/tmp/foo/bar.c: ; @echo '$@'
|
|||||||
$(dir)/tmp/bar/bar.c: ; @echo '$@'
|
$(dir)/tmp/bar/bar.c: ; @echo '$@'
|
||||||
foo.h: ; @echo '$@'
|
foo.h: ; @echo '$@'
|
||||||
|
|
||||||
%.o: $$(addsuffix /%.c,foo bar) foo.h
|
%.o: $$(addsuffix /%.c,foo bar) foo.h ; @echo '$@: {$<} $^'
|
||||||
@echo '$@: {$<} $^'
|
|
||||||
!,
|
!,
|
||||||
"dir=$dir", "$dir/tmp/foo/bar.c
|
"dir=$dir", "$dir/tmp/foo/bar.c
|
||||||
$dir/tmp/bar/bar.c
|
$dir/tmp/bar/bar.c
|
||||||
@ -155,8 +151,7 @@ $(dir)/tmp/foo.o: $(dir)/tmp/foo.c
|
|||||||
$(dir)/tmp/foo.c: ; @echo '$@'
|
$(dir)/tmp/foo.c: ; @echo '$@'
|
||||||
bar.h: ; @echo '$@'
|
bar.h: ; @echo '$@'
|
||||||
|
|
||||||
%.o: %.c|bar.h
|
%.o: %.c|bar.h ; @echo '$@: {$<} {$|} $^'
|
||||||
@echo '$@: {$<} {$|} $^'
|
|
||||||
|
|
||||||
!,
|
!,
|
||||||
"dir=$dir", "$dir/tmp/foo.c
|
"dir=$dir", "$dir/tmp/foo.c
|
||||||
@ -172,8 +167,7 @@ run_make_test(q!
|
|||||||
foo.o: foo.c
|
foo.o: foo.c
|
||||||
foo.c: ; @echo '$@'
|
foo.c: ; @echo '$@'
|
||||||
|
|
||||||
%.o:
|
%.o: ; @echo '$@: {$<} $^'
|
||||||
@echo '$@: {$<} $^'
|
|
||||||
!,
|
!,
|
||||||
'', "foo.c\nfoo.o: {foo.c} foo.c\n");
|
'', "foo.c\nfoo.o: {foo.c} foo.c\n");
|
||||||
|
|
||||||
@ -184,11 +178,9 @@ run_make_test(q!
|
|||||||
.SECONDEXPANSION:
|
.SECONDEXPANSION:
|
||||||
foobarbaz:
|
foobarbaz:
|
||||||
|
|
||||||
foo%baz: % $$*.1
|
foo%baz: % $$*.1 ; @echo '$*'
|
||||||
@echo '$*'
|
|
||||||
|
|
||||||
bar bar.1:
|
bar bar.1: ; @echo '$@'
|
||||||
@echo '$@'
|
|
||||||
!,
|
!,
|
||||||
'', "bar\nbar.1\nbar\n");
|
'', "bar\nbar.1\nbar\n");
|
||||||
|
|
||||||
@ -199,11 +191,9 @@ run_make_test(q!
|
|||||||
.SECONDEXPANSION:
|
.SECONDEXPANSION:
|
||||||
foo$$bar:
|
foo$$bar:
|
||||||
|
|
||||||
f%r: % $$*.1
|
f%r: % $$*.1 ; @echo '$*'
|
||||||
@echo '$*'
|
|
||||||
|
|
||||||
oo$$ba oo$$ba.1:
|
oo$$ba oo$$ba.1: ; @echo '$@'
|
||||||
@echo '$@'
|
|
||||||
!,
|
!,
|
||||||
'', 'oo$ba
|
'', 'oo$ba
|
||||||
oo$ba.1
|
oo$ba.1
|
||||||
@ -230,15 +220,12 @@ run_make_test(q!
|
|||||||
sim_base_rgg := just_a_name
|
sim_base_rgg := just_a_name
|
||||||
sim_base_src := a
|
sim_base_src := a
|
||||||
sim_base_f := a a a
|
sim_base_f := a a a
|
||||||
sim_%.f: $${sim_$$*_f}
|
sim_%.f: $${sim_$$*_f} ; echo $@
|
||||||
echo $@
|
sim_%.src: $${sim_$$*_src} ; echo $@
|
||||||
sim_%.src: $${sim_$$*_src}
|
|
||||||
echo $@
|
|
||||||
sim_%: \
|
sim_%: \
|
||||||
$$(if $$(sim_$$*_src),sim_%.src) \
|
$$(if $$(sim_$$*_src),sim_%.src) \
|
||||||
$$(if $$(sim_$$*_f),sim_%.f) \
|
$$(if $$(sim_$$*_f),sim_%.f) \
|
||||||
$$(if $$(sim_$$*_rgg),$$(sim_$$*_rgg).s)
|
$$(if $$(sim_$$*_rgg),$$(sim_$$*_rgg).s) ; echo $@
|
||||||
echo $@
|
|
||||||
!,
|
!,
|
||||||
'-s sim_base', "#MAKE#: *** No rule to make target 'sim_base'. Stop.", 512);
|
'-s sim_base', "#MAKE#: *** No rule to make target 'sim_base'. Stop.", 512);
|
||||||
|
|
||||||
@ -256,5 +243,16 @@ p% : ; : $@
|
|||||||
!,
|
!,
|
||||||
"", ": p1\n: p2\nfoo from p1 and p2\nbar from p1 and p2\n");
|
"", ": p1\n: p2\nfoo from p1 and p2\nbar from p1 and p2\n");
|
||||||
|
|
||||||
|
# SV 28456 : Don't reset $$< for default recipes
|
||||||
|
run_make_test(q!
|
||||||
|
.SECONDEXPANSION:
|
||||||
|
|
||||||
|
.PHONY: foo bar
|
||||||
|
foo: bar
|
||||||
|
foo: $$(info $$<)
|
||||||
|
%oo: ;
|
||||||
|
!,
|
||||||
|
'', "bar\n#MAKE#: Nothing to be done for 'foo'.\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;
|
||||||
|
Loading…
Reference in New Issue
Block a user