2005-02-27 21:40:23 +00:00
|
|
|
# -*-perl-*-
|
2019-07-12 01:08:38 +00:00
|
|
|
$description = "Test second expansion in implicit rules.";
|
2005-02-27 21:40:23 +00:00
|
|
|
|
|
|
|
$details = "";
|
|
|
|
|
|
|
|
use Cwd;
|
|
|
|
|
|
|
|
$dir = cwd;
|
|
|
|
$dir =~ s,.*/([^/]+)$,../$1,;
|
|
|
|
|
|
|
|
|
|
|
|
# Test #1: automatic variables.
|
|
|
|
#
|
2009-09-24 02:41:44 +00:00
|
|
|
run_make_test(q!
|
2005-12-11 15:41:17 +00:00
|
|
|
.SECONDEXPANSION:
|
2009-09-24 02:41:44 +00:00
|
|
|
.DEFAULT: ; @echo '$@'
|
2005-02-27 21:40:23 +00:00
|
|
|
|
|
|
|
foo.a: bar baz
|
|
|
|
|
|
|
|
foo.a: biz | buz
|
|
|
|
|
|
|
|
foo.%: 1.$$@ \
|
|
|
|
2.$$< \
|
|
|
|
$$(addprefix 3.,$$^) \
|
|
|
|
$$(addprefix 4.,$$+) \
|
|
|
|
5.$$| \
|
2019-07-12 01:08:38 +00:00
|
|
|
6.$$* ; @:
|
2005-02-27 21:40:23 +00:00
|
|
|
|
|
|
|
1.foo.a \
|
|
|
|
2.bar \
|
|
|
|
3.bar \
|
|
|
|
3.baz \
|
|
|
|
3.biz \
|
|
|
|
4.bar \
|
|
|
|
4.baz \
|
|
|
|
4.biz \
|
|
|
|
5.buz \
|
2019-07-12 01:08:38 +00:00
|
|
|
6.a: ; @echo '$@'
|
2005-02-27 21:40:23 +00:00
|
|
|
|
2009-09-24 02:41:44 +00:00
|
|
|
!,
|
2005-02-27 21:40:23 +00:00
|
|
|
'',
|
|
|
|
'1.foo.a
|
|
|
|
2.bar
|
|
|
|
3.bar
|
|
|
|
3.baz
|
|
|
|
3.biz
|
|
|
|
4.bar
|
|
|
|
4.baz
|
|
|
|
4.biz
|
|
|
|
5.buz
|
|
|
|
6.a
|
|
|
|
bar
|
|
|
|
baz
|
|
|
|
biz
|
|
|
|
buz
|
|
|
|
');
|
|
|
|
|
|
|
|
|
|
|
|
# Test #2: target/pattern -specific variables.
|
|
|
|
#
|
2009-09-24 02:41:44 +00:00
|
|
|
run_make_test(q!
|
2005-12-11 15:41:17 +00:00
|
|
|
.SECONDEXPANSION:
|
2005-02-27 21:40:23 +00:00
|
|
|
foo.x:
|
|
|
|
|
2019-07-12 01:08:38 +00:00
|
|
|
foo.%: $$(%_a) $$(%_b) bar ; @:
|
2005-02-27 21:40:23 +00:00
|
|
|
|
|
|
|
foo.x: x_a := bar
|
|
|
|
|
|
|
|
%.x: x_b := baz
|
|
|
|
|
2009-09-24 02:41:44 +00:00
|
|
|
bar baz: ; @echo '$@'
|
|
|
|
!,
|
|
|
|
'', "bar\nbaz\n");
|
2005-02-27 21:40:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Test #3: order of prerequisites.
|
|
|
|
#
|
2009-09-24 02:41:44 +00:00
|
|
|
run_make_test(q!
|
2005-12-11 15:41:17 +00:00
|
|
|
.SECONDEXPANSION:
|
2009-09-24 02:41:44 +00:00
|
|
|
.DEFAULT: ; @echo '$@'
|
2005-02-27 21:40:23 +00:00
|
|
|
|
|
|
|
all: foo bar baz
|
|
|
|
|
|
|
|
|
|
|
|
# Subtest #1
|
|
|
|
#
|
|
|
|
%oo: %oo.1; @:
|
|
|
|
|
|
|
|
foo: foo.2
|
|
|
|
|
|
|
|
foo: foo.3
|
|
|
|
|
2009-09-24 02:41:44 +00:00
|
|
|
foo.1: ; @echo '$@'
|
2005-02-27 21:40:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Subtest #2
|
|
|
|
#
|
|
|
|
bar: bar.2
|
|
|
|
|
|
|
|
%ar: %ar.1; @:
|
|
|
|
|
|
|
|
bar: bar.3
|
|
|
|
|
2009-09-24 02:41:44 +00:00
|
|
|
bar.1: ; @echo '$@'
|
2005-02-27 21:40:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Subtest #3
|
|
|
|
#
|
|
|
|
baz: baz.1
|
|
|
|
|
|
|
|
baz: baz.2
|
|
|
|
|
|
|
|
%az: ; @:
|
2009-09-24 02:41:44 +00:00
|
|
|
!,
|
|
|
|
'',
|
2005-02-27 21:40:23 +00:00
|
|
|
'foo.1
|
|
|
|
foo.2
|
|
|
|
foo.3
|
|
|
|
bar.1
|
|
|
|
bar.2
|
|
|
|
bar.3
|
|
|
|
baz.1
|
|
|
|
baz.2
|
|
|
|
');
|
|
|
|
|
|
|
|
|
|
|
|
# Test #4: stem splitting logic.
|
|
|
|
#
|
2009-09-24 02:41:44 +00:00
|
|
|
run_make_test(q!
|
2005-12-11 15:41:17 +00:00
|
|
|
.SECONDEXPANSION:
|
2005-02-27 21:40:23 +00:00
|
|
|
$(dir)/tmp/bar.o:
|
|
|
|
|
2009-09-24 02:41:44 +00:00
|
|
|
$(dir)/tmp/foo/bar.c: ; @echo '$@'
|
|
|
|
$(dir)/tmp/bar/bar.c: ; @echo '$@'
|
|
|
|
foo.h: ; @echo '$@'
|
2005-02-27 21:40:23 +00:00
|
|
|
|
2019-07-12 01:08:38 +00:00
|
|
|
%.o: $$(addsuffix /%.c,foo bar) foo.h ; @echo '$@: {$<} $^'
|
2009-09-24 02:41:44 +00:00
|
|
|
!,
|
|
|
|
"dir=$dir", "$dir/tmp/foo/bar.c
|
2005-02-27 21:40:23 +00:00
|
|
|
$dir/tmp/bar/bar.c
|
|
|
|
foo.h
|
|
|
|
$dir/tmp/bar.o: {$dir/tmp/foo/bar.c} $dir/tmp/foo/bar.c $dir/tmp/bar/bar.c foo.h
|
|
|
|
");
|
|
|
|
|
|
|
|
|
|
|
|
# Test #5: stem splitting logic and order-only prerequisites.
|
|
|
|
#
|
2009-09-24 02:41:44 +00:00
|
|
|
run_make_test(q!
|
2005-12-11 15:41:17 +00:00
|
|
|
.SECONDEXPANSION:
|
2005-02-27 21:40:23 +00:00
|
|
|
$(dir)/tmp/foo.o: $(dir)/tmp/foo.c
|
2009-09-24 02:41:44 +00:00
|
|
|
$(dir)/tmp/foo.c: ; @echo '$@'
|
|
|
|
bar.h: ; @echo '$@'
|
2005-02-27 21:40:23 +00:00
|
|
|
|
2019-07-12 01:08:38 +00:00
|
|
|
%.o: %.c|bar.h ; @echo '$@: {$<} {$|} $^'
|
2005-02-27 21:40:23 +00:00
|
|
|
|
2009-09-24 02:41:44 +00:00
|
|
|
!,
|
|
|
|
"dir=$dir", "$dir/tmp/foo.c
|
2005-02-27 21:40:23 +00:00
|
|
|
bar.h
|
|
|
|
$dir/tmp/foo.o: {$dir/tmp/foo.c} {bar.h} $dir/tmp/foo.c
|
|
|
|
");
|
|
|
|
|
|
|
|
|
|
|
|
# Test #6: lack of implicit prerequisites.
|
|
|
|
#
|
2009-09-24 02:41:44 +00:00
|
|
|
run_make_test(q!
|
2005-12-11 15:41:17 +00:00
|
|
|
.SECONDEXPANSION:
|
2005-02-27 21:40:23 +00:00
|
|
|
foo.o: foo.c
|
2009-09-24 02:41:44 +00:00
|
|
|
foo.c: ; @echo '$@'
|
2005-02-27 21:40:23 +00:00
|
|
|
|
2019-07-12 01:08:38 +00:00
|
|
|
%.o: ; @echo '$@: {$<} $^'
|
2009-09-24 02:41:44 +00:00
|
|
|
!,
|
|
|
|
'', "foo.c\nfoo.o: {foo.c} foo.c\n");
|
2005-02-27 21:40:23 +00:00
|
|
|
|
|
|
|
|
2005-03-03 17:39:48 +00:00
|
|
|
# Test #7: Test stem from the middle of the name.
|
|
|
|
#
|
2009-09-24 02:41:44 +00:00
|
|
|
run_make_test(q!
|
2005-12-11 15:41:17 +00:00
|
|
|
.SECONDEXPANSION:
|
2005-03-03 17:39:48 +00:00
|
|
|
foobarbaz:
|
|
|
|
|
2019-07-12 01:08:38 +00:00
|
|
|
foo%baz: % $$*.1 ; @echo '$*'
|
2005-03-03 17:39:48 +00:00
|
|
|
|
2019-07-12 01:08:38 +00:00
|
|
|
bar bar.1: ; @echo '$@'
|
2009-09-24 02:41:44 +00:00
|
|
|
!,
|
|
|
|
'', "bar\nbar.1\nbar\n");
|
2005-03-03 17:39:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Test #8: Make sure stem triple-expansion does not happen.
|
|
|
|
#
|
2009-09-24 02:41:44 +00:00
|
|
|
run_make_test(q!
|
2005-12-11 15:41:17 +00:00
|
|
|
.SECONDEXPANSION:
|
2005-03-03 17:39:48 +00:00
|
|
|
foo$$bar:
|
|
|
|
|
2019-07-12 01:08:38 +00:00
|
|
|
f%r: % $$*.1 ; @echo '$*'
|
2005-03-03 17:39:48 +00:00
|
|
|
|
2019-07-12 01:08:38 +00:00
|
|
|
oo$$ba oo$$ba.1: ; @echo '$@'
|
2009-09-24 02:41:44 +00:00
|
|
|
!,
|
|
|
|
'', 'oo$ba
|
2005-03-03 17:39:48 +00:00
|
|
|
oo$ba.1
|
|
|
|
oo$ba
|
|
|
|
');
|
|
|
|
|
2009-09-24 20:59:22 +00:00
|
|
|
# Test #9: Check the value of $^
|
|
|
|
run_make_test(q!
|
|
|
|
.SECONDEXPANSION:
|
|
|
|
|
|
|
|
%.so: | $$(extra) ; @echo $^
|
|
|
|
|
|
|
|
foo.so: extra := foo.o
|
|
|
|
foo.so:
|
|
|
|
foo.o:
|
|
|
|
!,
|
|
|
|
'', "\n");
|
2005-02-27 21:40:23 +00:00
|
|
|
|
2013-07-09 23:14:40 +00:00
|
|
|
# Test #10: Test second expansion with second expansion prerequisites
|
|
|
|
# Ensures pattern_search() recurses with SE prereqs.
|
|
|
|
touch('a');
|
|
|
|
run_make_test(q!
|
|
|
|
.SECONDEXPANSION:
|
|
|
|
sim_base_rgg := just_a_name
|
|
|
|
sim_base_src := a
|
|
|
|
sim_base_f := a a a
|
2019-07-12 01:08:38 +00:00
|
|
|
sim_%.f: $${sim_$$*_f} ; echo $@
|
|
|
|
sim_%.src: $${sim_$$*_src} ; echo $@
|
2013-07-09 23:14:40 +00:00
|
|
|
sim_%: \
|
2019-07-12 01:08:38 +00:00
|
|
|
$$(if $$(sim_$$*_src),sim_%.src) \
|
|
|
|
$$(if $$(sim_$$*_f),sim_%.f) \
|
|
|
|
$$(if $$(sim_$$*_rgg),$$(sim_$$*_rgg).s) ; echo $@
|
2013-07-09 23:14:40 +00:00
|
|
|
!,
|
|
|
|
'-s sim_base', "#MAKE#: *** No rule to make target 'sim_base'. Stop.", 512);
|
|
|
|
|
|
|
|
unlink('a');
|
|
|
|
|
2013-09-22 20:59:04 +00:00
|
|
|
# Ensure that order-only tokens embedded in second expansions are parsed
|
|
|
|
run_make_test(q!
|
|
|
|
.SECONDEXPANSION:
|
|
|
|
PREREQS=p1|p2
|
|
|
|
P2=p2
|
|
|
|
all : foo bar
|
|
|
|
f%o: $$(PREREQS) ; @echo '$@' from '$^' and '$|'
|
|
|
|
b%r: p1|$$(P2) ; @echo '$@' from '$^' and '$|'
|
|
|
|
p% : ; : $@
|
|
|
|
!,
|
|
|
|
"", ": p1\n: p2\nfoo from p1 and p2\nbar from p1 and p2\n");
|
|
|
|
|
2019-07-12 01:08:38 +00:00
|
|
|
# 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");
|
|
|
|
|
2019-10-26 10:24:15 +00:00
|
|
|
# SV 54161: Expand $$* properly when it contains a path
|
|
|
|
|
|
|
|
run_make_test(q!
|
|
|
|
.SECONDEXPANSION:
|
|
|
|
%x: $$(info $$*); @echo '$*'
|
|
|
|
!,
|
|
|
|
'q/ux', "q/u\nq/u\n");
|
|
|
|
|
2005-02-27 21:40:23 +00:00
|
|
|
# This tells the test driver that the perl test script executed properly.
|
|
|
|
1;
|