summaryrefslogtreecommitdiff
path: root/tests/scripts/features/patternrules
blob: 0e2f2812a8d9cfc2640ea6e65a537c9765d7471c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#                                                                    -*-perl-*-

$description = "Test pattern rules.";

$details = "";

use Cwd;

$dir = cwd;
$dir =~ s,.*/([^/]+)$,../$1,;


#  TEST #1: Make sure that multiple patterns where the same target
#           can be built are searched even if the first one fails
#           to match properly.
#

run_make_test('
.PHONY: all

all: case.1 case.2 case.3
a: void

# 1 - existing file
%.1: void
	@false
%.1: #MAKEFILE#
	@true

# 2 - phony
%.2: void
	@false
%.2: 2.phony
	@true
.PHONY: 2.phony

# 3 - implicit-phony
%.3: void
	@false
%.3: 3.implicit-phony
	@true

3.implicit-phony:
',
'',
'');

# TEST #2: make sure files that are built via implicit rules are marked
#          as targets (Savannah bug #12202).
#
run_make_test('
TARGETS := foo foo.out

.PHONY: all foo.in

all: $(TARGETS)

%: %.in
	@echo $@

%.out: %
	@echo $@

foo.in: ; @:

',
'',
'foo
foo.out');


# TEST #3: make sure intermidite files that also happened to be
#          prerequisites are not removed (Savannah bug #12267).
#
run_make_test('
$(dir)/foo.o:

$(dir)/foo.y:
	@echo $@

%.c: %.y
	touch $@

%.o: %.c
	@echo $@

.PHONY: install
install: $(dir)/foo.c

',
"dir=$dir",
"$dir/foo.y
touch $dir/foo.c
$dir/foo.o");

unlink("$dir/foo.c");


# TEST #4: make sure precious flag is set properly for targets
#          that are built via implicit rules (Savannah bug #13218).
#
run_make_test('
.DELETE_ON_ERROR:

.PRECIOUS: %.bar

%.bar:; @touch $@ && false

$(dir)/foo.bar:

',
"dir=$dir",
"make: *** [$dir/foo.bar] Error 1",
512);

unlink("$dir/foo.bar");

# This tells the test driver that the perl test script executed properly.
1;