| 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 | run_make_test(q!
|
|---|
| 12 | ifdef SE
|
|---|
| 13 | .SECONDEXPANSION:
|
|---|
| 14 | endif
|
|---|
| 15 | foo$$bar: bar$$baz bar$$biz ; @echo '$@ : $^'
|
|---|
| 16 | PRE = one two
|
|---|
| 17 | bar$$baz: $${PRE}
|
|---|
| 18 | baraz: $${PRE}
|
|---|
| 19 | PRE = three four
|
|---|
| 20 | .DEFAULT: ; @echo '$@'
|
|---|
| 21 | !,
|
|---|
| 22 | '',
|
|---|
| 23 | "\${PRE}\nbar\$biz\nfoo\$bar : bar\$baz bar\$biz");
|
|---|
| 24 |
|
|---|
| 25 | run_make_test(undef, 'SE=1', "three\nfour\nbariz\nfoo\$bar : baraz bariz");
|
|---|
| 26 |
|
|---|
| 27 | # TEST #1: automatic variables.
|
|---|
| 28 | #
|
|---|
| 29 | run_make_test(q!
|
|---|
| 30 | .SECONDEXPANSION:
|
|---|
| 31 | .DEFAULT: ; @echo '$@'
|
|---|
| 32 |
|
|---|
| 33 | foo: bar baz
|
|---|
| 34 |
|
|---|
| 35 | foo: biz | buz
|
|---|
| 36 |
|
|---|
| 37 | foo: $$@.1 \
|
|---|
| 38 | $$<.2 \
|
|---|
| 39 | $$(addsuffix .3,$$^) \
|
|---|
| 40 | $$(addsuffix .4,$$+) \
|
|---|
| 41 | $$|.5 \
|
|---|
| 42 | $$*.6
|
|---|
| 43 |
|
|---|
| 44 | !,
|
|---|
| 45 | '-j1',
|
|---|
| 46 | 'bar
|
|---|
| 47 | baz
|
|---|
| 48 | biz
|
|---|
| 49 | buz
|
|---|
| 50 | foo.1
|
|---|
| 51 | bar.2
|
|---|
| 52 | bar.3
|
|---|
| 53 | baz.3
|
|---|
| 54 | biz.3
|
|---|
| 55 | bar.4
|
|---|
| 56 | baz.4
|
|---|
| 57 | biz.4
|
|---|
| 58 | buz.5
|
|---|
| 59 | .6
|
|---|
| 60 | ');
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 | # Test #2: target/pattern -specific variables.
|
|---|
| 64 | #
|
|---|
| 65 | run_make_test(q!
|
|---|
| 66 | .SECONDEXPANSION:
|
|---|
| 67 | .DEFAULT: ; @echo '$@'
|
|---|
| 68 |
|
|---|
| 69 | foo.x: $$a $$b
|
|---|
| 70 |
|
|---|
| 71 | foo.x: a := bar
|
|---|
| 72 |
|
|---|
| 73 | %.x: b := baz
|
|---|
| 74 | !,
|
|---|
| 75 | '',
|
|---|
| 76 | 'bar
|
|---|
| 77 | baz
|
|---|
| 78 | ');
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 | # Test #3: order of prerequisites.
|
|---|
| 82 | #
|
|---|
| 83 | run_make_test(q!
|
|---|
| 84 | .SECONDEXPANSION:
|
|---|
| 85 | .DEFAULT: ; @echo '$@'
|
|---|
| 86 |
|
|---|
| 87 | all: foo bar baz
|
|---|
| 88 |
|
|---|
| 89 | # Subtest #1
|
|---|
| 90 | foo: foo.1; @:
|
|---|
| 91 | foo: foo.2
|
|---|
| 92 | foo: foo.3
|
|---|
| 93 |
|
|---|
| 94 | # Subtest #2
|
|---|
| 95 | bar: bar.2
|
|---|
| 96 | bar: bar.1; @:
|
|---|
| 97 | bar: bar.3
|
|---|
| 98 |
|
|---|
| 99 | # Subtest #3
|
|---|
| 100 | baz: baz.1
|
|---|
| 101 | baz: baz.2
|
|---|
| 102 | baz: ; @:
|
|---|
| 103 | !,
|
|---|
| 104 | '-j1',
|
|---|
| 105 | 'foo.1
|
|---|
| 106 | foo.2
|
|---|
| 107 | foo.3
|
|---|
| 108 | bar.1
|
|---|
| 109 | bar.2
|
|---|
| 110 | bar.3
|
|---|
| 111 | baz.1
|
|---|
| 112 | baz.2
|
|---|
| 113 | ');
|
|---|
| 114 |
|
|---|
| 115 | # TEST #4: eval in a context where there is no reading_file
|
|---|
| 116 | run_make_test(q!
|
|---|
| 117 | .SECONDEXPANSION:
|
|---|
| 118 | all : $$(eval $$(info test))
|
|---|
| 119 | !,
|
|---|
| 120 | '', "test\n#MAKE#: Nothing to be done for `all'.\n");
|
|---|
| 121 |
|
|---|
| 122 | # TEST #5: (NEGATIVE) catch eval in a prereq list trying to create new
|
|---|
| 123 | # target/prereq relationships.
|
|---|
| 124 |
|
|---|
| 125 | run_make_test(q!
|
|---|
| 126 | .SECONDEXPANSION:
|
|---|
| 127 | proj1.exe : proj1.o $$(eval $$(test))
|
|---|
| 128 | define test
|
|---|
| 129 | proj1.o : proj1.c
|
|---|
| 130 | proj1.c: proj1.h
|
|---|
| 131 | endef
|
|---|
| 132 | !,
|
|---|
| 133 | '', "#MAKE#: *** prerequisites cannot be defined in recipes. Stop.\n", 512);
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 | # Automatic $$+ variable expansion issue. Savannah bug #25780
|
|---|
| 137 | run_make_test(q!
|
|---|
| 138 | all : foo foo
|
|---|
| 139 | .SECONDEXPANSION:
|
|---|
| 140 | all : $$+ ; @echo '$+'
|
|---|
| 141 | foo : ;
|
|---|
| 142 | !,
|
|---|
| 143 | '', "foo foo foo foo\n");
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 | # Automatic $$+ variable expansion issue. Savannah bug #25780
|
|---|
| 147 | run_make_test(q!
|
|---|
| 148 | all : bar bar
|
|---|
| 149 | bar : ;
|
|---|
| 150 | q%x : ;
|
|---|
| 151 | .SECONDEXPANSION:
|
|---|
| 152 | a%l: q1x $$+ q2x ; @echo '$+'
|
|---|
| 153 | !,
|
|---|
| 154 | '', "q1x bar bar q2x bar bar\n");
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 | # This tells the test driver that the perl test script executed properly.
|
|---|
| 158 | 1;
|
|---|