| 1 | # -*-perl-*-
|
|---|
| 2 | $description = "Test second expansion in ordinary rules.";
|
|---|
| 3 |
|
|---|
| 4 | $details = "";
|
|---|
| 5 |
|
|---|
| 6 | # TEST #0: Test handing of '$' in prerequisites with and without second
|
|---|
| 7 | # expansion.
|
|---|
| 8 | # bird: Modified this test to use ${PRE} instead of $(PRE) as it failes
|
|---|
| 9 | # when make is built with NO_ARCHIVES defined.
|
|---|
| 10 |
|
|---|
| 11 | # If we don't support archives then the prerequisite is different
|
|---|
| 12 | my $prereq = exists $FEATURES{'archives'} ? '$' : '$(PRE)';
|
|---|
| 13 |
|
|---|
| 14 | run_make_test(q!
|
|---|
| 15 | ifdef SE
|
|---|
| 16 | .SECONDEXPANSION:
|
|---|
| 17 | endif
|
|---|
| 18 | foo$$bar: bar$$baz bar$$biz ; @echo '$@ : $^'
|
|---|
| 19 | PRE = one two
|
|---|
| 20 | bar$$baz: $${PRE}
|
|---|
| 21 | baraz: $${PRE}
|
|---|
| 22 | PRE = three four
|
|---|
| 23 | .DEFAULT: ; @echo '$@'
|
|---|
| 24 | !,
|
|---|
| 25 | '',
|
|---|
| 26 | "$prereq\nbar\$biz\nfoo\$bar : bar\$baz bar\$biz");
|
|---|
| 27 |
|
|---|
| 28 | run_make_test(undef, 'SE=1', "three\nfour\nbariz\nfoo\$bar : baraz bariz");
|
|---|
| 29 |
|
|---|
| 30 | # TEST #1: automatic variables.
|
|---|
| 31 | #
|
|---|
| 32 | run_make_test(q!
|
|---|
| 33 | .SECONDEXPANSION:
|
|---|
| 34 | .DEFAULT: ; @echo '$@'
|
|---|
| 35 |
|
|---|
| 36 | foo: bar baz
|
|---|
| 37 |
|
|---|
| 38 | foo: biz | buz
|
|---|
| 39 |
|
|---|
| 40 | foo: $$@.1 \
|
|---|
| 41 | $$<.2 \
|
|---|
| 42 | $$(addsuffix .3,$$^) \
|
|---|
| 43 | $$(addsuffix .4,$$+) \
|
|---|
| 44 | $$|.5 \
|
|---|
| 45 | $$*.6
|
|---|
| 46 |
|
|---|
| 47 | !,
|
|---|
| 48 | '-j1',
|
|---|
| 49 | 'bar
|
|---|
| 50 | baz
|
|---|
| 51 | biz
|
|---|
| 52 | buz
|
|---|
| 53 | foo.1
|
|---|
| 54 | bar.2
|
|---|
| 55 | bar.3
|
|---|
| 56 | baz.3
|
|---|
| 57 | biz.3
|
|---|
| 58 | bar.4
|
|---|
| 59 | baz.4
|
|---|
| 60 | biz.4
|
|---|
| 61 | buz.5
|
|---|
| 62 | .6
|
|---|
| 63 | ');
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | # Test #2: target/pattern -specific variables.
|
|---|
| 67 | #
|
|---|
| 68 | run_make_test(q!
|
|---|
| 69 | .SECONDEXPANSION:
|
|---|
| 70 | .DEFAULT: ; @echo '$@'
|
|---|
| 71 |
|
|---|
| 72 | foo.x: $$a $$b
|
|---|
| 73 |
|
|---|
| 74 | foo.x: a := bar
|
|---|
| 75 |
|
|---|
| 76 | %.x: b := baz
|
|---|
| 77 | !,
|
|---|
| 78 | '',
|
|---|
| 79 | 'bar
|
|---|
| 80 | baz
|
|---|
| 81 | ');
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 | # Test #3: order of prerequisites.
|
|---|
| 85 | #
|
|---|
| 86 | run_make_test(q!
|
|---|
| 87 | .SECONDEXPANSION:
|
|---|
| 88 | .DEFAULT: ; @echo '$@'
|
|---|
| 89 |
|
|---|
| 90 | all: foo bar baz
|
|---|
| 91 |
|
|---|
| 92 | # Subtest #1
|
|---|
| 93 | foo: foo.1; @:
|
|---|
| 94 | foo: foo.2
|
|---|
| 95 | foo: foo.3
|
|---|
| 96 |
|
|---|
| 97 | # Subtest #2
|
|---|
| 98 | bar: bar.2
|
|---|
| 99 | bar: bar.1; @:
|
|---|
| 100 | bar: bar.3
|
|---|
| 101 |
|
|---|
| 102 | # Subtest #3
|
|---|
| 103 | baz: baz.1
|
|---|
| 104 | baz: baz.2
|
|---|
| 105 | baz: ; @:
|
|---|
| 106 | !,
|
|---|
| 107 | '-j1',
|
|---|
| 108 | 'foo.1
|
|---|
| 109 | foo.2
|
|---|
| 110 | foo.3
|
|---|
| 111 | bar.1
|
|---|
| 112 | bar.2
|
|---|
| 113 | bar.3
|
|---|
| 114 | baz.1
|
|---|
| 115 | baz.2
|
|---|
| 116 | ');
|
|---|
| 117 |
|
|---|
| 118 | # TEST #4: eval in a context where there is no reading_file
|
|---|
| 119 | run_make_test(q!
|
|---|
| 120 | .SECONDEXPANSION:
|
|---|
| 121 | all : $$(eval $$(info test))
|
|---|
| 122 | !,
|
|---|
| 123 | '', "test\n#MAKE#: Nothing to be done for 'all'.\n");
|
|---|
| 124 |
|
|---|
| 125 | # TEST #5: (NEGATIVE) catch eval in a prereq list trying to create new
|
|---|
| 126 | # target/prereq relationships.
|
|---|
| 127 |
|
|---|
| 128 | run_make_test(q!
|
|---|
| 129 | .SECONDEXPANSION:
|
|---|
| 130 | proj1.exe : proj1.o $$(eval $$(test))
|
|---|
| 131 | define test
|
|---|
| 132 | proj1.o : proj1.c
|
|---|
| 133 | proj1.c: proj1.h
|
|---|
| 134 | endef
|
|---|
| 135 | !,
|
|---|
| 136 | '', "#MAKE#: *** prerequisites cannot be defined in recipes. Stop.\n", 512);
|
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 | # Automatic $$+ variable expansion issue. Savannah bug #25780
|
|---|
| 140 | run_make_test(q!
|
|---|
| 141 | all : foo foo
|
|---|
| 142 | .SECONDEXPANSION:
|
|---|
| 143 | all : $$+ ; @echo '$+'
|
|---|
| 144 | foo : ;
|
|---|
| 145 | !,
|
|---|
| 146 | '', "foo foo foo foo\n");
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 | # Automatic $$+ variable expansion issue. Savannah bug #25780
|
|---|
| 150 | run_make_test(q!
|
|---|
| 151 | all : bar bar
|
|---|
| 152 | bar : ;
|
|---|
| 153 | q%x : ;
|
|---|
| 154 | .SECONDEXPANSION:
|
|---|
| 155 | a%l: q1x $$+ q2x ; @echo '$+'
|
|---|
| 156 | !,
|
|---|
| 157 | '', "q1x bar bar q2x bar bar\n");
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 | # Allow patsubst shorthand in second expansion context.
|
|---|
| 161 | # Requires the colon to be quoted. Savannah bug #16545
|
|---|
| 162 | run_make_test(q!
|
|---|
| 163 | .PHONY: foo.bar
|
|---|
| 164 | .SECONDEXPANSION:
|
|---|
| 165 | foo: $$(@\\:%=%.bar); @echo '$^'
|
|---|
| 166 | !,
|
|---|
| 167 | '', "foo.bar\n");
|
|---|
| 168 |
|
|---|
| 169 | 1;
|
|---|