Home | History | Annotate | Download | only in features
      1 #                                                                    -*-perl-*-
      2 $description = "Test second expansion in static pattern rules.";
      3 
      4 $details = "";
      5 
      6 # Test #1: automatic variables.
      7 #
      8 run_make_test('
      9 .SECONDEXPANSION:
     10 .DEFAULT: ; @echo $@
     11 
     12 foo.a foo.b: foo.%: bar.% baz.%
     13 
     14 foo.a foo.b: foo.%: biz.% | buz.%
     15 
     16 foo.a foo.b: foo.%: $$@.1 \
     17                     $$<.2 \
     18                     $$(addsuffix .3,$$^) \
     19                     $$(addsuffix .4,$$+) \
     20                     $$|.5 \
     21                     $$*.6
     22 
     23 ',
     24 '',
     25 'bar.a
     26 baz.a
     27 biz.a
     28 buz.a
     29 foo.a.1
     30 bar.a.2
     31 bar.a.3
     32 baz.a.3
     33 biz.a.3
     34 bar.a.4
     35 baz.a.4
     36 biz.a.4
     37 buz.a.5
     38 a.6
     39 ');
     40 
     41 
     42 # Test #2: target/pattern -specific variables.
     43 #
     44 run_make_test('
     45 .SECONDEXPANSION:
     46 .DEFAULT: ; @echo $@
     47 
     48 foo.x foo.y: foo.%: $$(%_a) $$($$*_b)
     49 
     50 foo.x: x_a := bar
     51 
     52 %.x: x_b := baz
     53 
     54 
     55 ',
     56 '',
     57 'bar
     58 baz
     59 ');
     60 
     61 
     62 # Test #3: order of prerequisites.
     63 #
     64 run_make_test('
     65 .SECONDEXPANSION:
     66 .DEFAULT: ; @echo $@
     67 
     68 all: foo.a bar.a baz.a
     69 
     70 # Subtest #1
     71 #
     72 foo.a foo.b: foo.%: foo.%.1; @:
     73 
     74 foo.a foo.b: foo.%: foo.%.2
     75 
     76 foo.a foo.b: foo.%: foo.%.3
     77 
     78 
     79 # Subtest #2
     80 #
     81 bar.a bar.b: bar.%: bar.%.2
     82 
     83 bar.a bar.b: bar.%: bar.%.1; @:
     84 
     85 bar.a bar.b: bar.%: bar.%.3
     86 
     87 
     88 # Subtest #3
     89 #
     90 baz.a baz.b: baz.%: baz.%.1
     91 
     92 baz.a baz.b: baz.%: baz.%.2
     93 
     94 baz.a baz.b: ; @:
     95 
     96 ',
     97 '',
     98 'foo.a.1
     99 foo.a.2
    100 foo.a.3
    101 bar.a.1
    102 bar.a.2
    103 bar.a.3
    104 baz.a.1
    105 baz.a.2
    106 ');
    107 
    108 
    109 # Test #4: Make sure stem triple-expansion does not happen.
    110 #
    111 run_make_test('
    112 .SECONDEXPANSION:
    113 foo$$bar: f%r: % $$*.1
    114 	@echo \'$*\'
    115 
    116 oo$$ba oo$$ba.1:
    117 	@echo \'$@\'
    118 
    119 ',
    120 '',
    121 'oo$ba
    122 oo$ba.1
    123 oo$ba
    124 ');
    125 
    126 
    127 # This tells the test driver that the perl test script executed properly.
    128 1;
    129