summaryrefslogtreecommitdiffstats
path: root/tests/scripts/misc/general4
blob: cfd69a8987cbb3d8071ca12879504cf212102f41 (plain) (blame)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#                                                                    -*-perl-*-

$description = "\
This tests random features of make's algorithms, often somewhat obscure,
which have either broken at some point in the past or seem likely to
break.";

run_make_test('
# Make sure that subdirectories built as prerequisites are actually handled
# properly.

all: dir/subdir/file.a

dir/subdir: ; @echo mkdir -p dir/subdir

dir/subdir/file.b: dir/subdir ; @echo touch dir/subdir/file.b

dir/subdir/%.a: dir/subdir/%.b ; @echo cp $< $@',
              '', "mkdir -p dir/subdir\ntouch dir/subdir/file.b\ncp dir/subdir/file.b dir/subdir/file.a\n");

# Test implicit rules

&touch('foo.c');
run_make_test('foo: foo.o',
              'CC="@echo cc" OUTPUT_OPTION=',
              'cc -c foo.c
cc foo.o -o foo');
unlink('foo.c');


# Test implicit rules with '$' in the name (see se_implicit)

run_make_test(q!
%.foo : baz$$bar ; @echo 'done $<'
%.foo : bar$$baz ; @echo 'done $<'
test.foo:
baz$$bar bar$$baz: ; @echo '$@'
!,
              '',
              "baz\$bar\ndone baz\$bar");


# Test implicit rules with '$' in the name (see se_implicit)
# Use the '$' in the pattern.

run_make_test(q!
%.foo : %$$bar ; @echo 'done $<'
test.foo:
test$$bar: ; @echo '$@'
!,
              '',
              "test\$bar\ndone test\$bar");

# Make sure that subdirectories built as prerequisites are actually handled
# properly... this time with '$'

run_make_test(q!

all: dir/subdir/file.$$a

dir/subdir: ; @echo mkdir -p '$@'

dir/subdir/file.$$b: dir/subdir ; @echo touch '$@'

dir/subdir/%.$$a: dir/subdir/%.$$b ; @echo 'cp $< $@'
!,
              '', "mkdir -p dir/subdir\ntouch dir/subdir/file.\$b\ncp dir/subdir/file.\$b dir/subdir/file.\$a\n");

# Test odd whitespace at the beginning of a line

run_make_test("
all:
   \f

    \\
 \f  \\
    \013 \\
all: ; \@echo hi
",
              '', "hi\n");

# SV-56834 Ensure setting PATH in the makefile works properly
my $sname = "foobar$scriptsuffix";

mkdir('sd', 0775);
create_file("sd/$sname", "exit 0\n");
chmod 0755, "sd/$sname";

run_make_test(qq!
PATH := sd
all: ; $sname >/dev/null
!,
              '', "$sname >/dev/null\n");

# Don't use the general PATH if not found on the target path

$ENV{PATH} = "$ENV{PATH}:sd";

my ($ernum, $erstr);

if ($port_type eq 'W32') {
    $ernum = 2;
    $erstr = "process_begin: CreateProcess(NULL, $sname, ...) failed.\nmake (e=2): The system cannot find the file specified.";
} else {
    $ernum = 127;
    $erstr = "#MAKE#: $sname: $ERR_no_such_file";
}

run_make_test(qq!
PATH := ..
all: ; $sname
!,
              '', "$sname\n$erstr\n#MAKE#: *** [#MAKEFILE#:3: all] Error $ernum", 512);

unlink("sd/$sname");
rmdir('sd');

# Ensure that local programs are not found if "." is not on the PATH

create_file($sname, '');
chmod 0755, $sname;

if ($port_type eq 'W32') {
    $ernum = -1;
    $erstr = "";
} else {
    $ernum = 127;
    $erstr = "#MAKE#: $sname: $ERR_no_such_file\n";
}

run_make_test(qq!
PATH := ..
all: ; $sname
!,
              '', "$sname\n$erstr#MAKE#: *** [#MAKEFILE#:3: all] Error $ernum", 512);

unlink($sname);

# SV 57674: ensure we use a system default PATH if one is not set
delete $ENV{PATH};
run_make_test(q!
a: ; @echo hi
!,
              '', "hi\n");

1;