| 1 |
# -*-perl-*- |
| 2 |
|
| 3 |
$description = "\ |
| 4 |
This tests random features of make's algorithms, often somewhat obscure, |
| 5 |
which have either broken at some point in the past or seem likely to |
| 6 |
break."; |
| 7 |
|
| 8 |
run_make_test(' |
| 9 |
# Make sure that subdirectories built as prerequisites are actually handled |
| 10 |
# properly. |
| 11 |
|
| 12 |
all: dir/subdir/file.a |
| 13 |
|
| 14 |
dir/subdir: ; @echo mkdir -p dir/subdir |
| 15 |
|
| 16 |
dir/subdir/file.b: dir/subdir ; @echo touch dir/subdir/file.b |
| 17 |
|
| 18 |
dir/subdir/%.a: dir/subdir/%.b ; @echo cp $< $@', |
| 19 |
'', "mkdir -p dir/subdir\ntouch dir/subdir/file.b\ncp dir/subdir/file.b dir/subdir/file.a\n"); |
| 20 |
|
| 21 |
# Test implicit rules |
| 22 |
|
| 23 |
&touch('foo.c'); |
| 24 |
run_make_test('foo: foo.o', |
| 25 |
'CC="@echo cc" OUTPUT_OPTION=', |
| 26 |
'cc -c foo.c |
| 27 |
cc foo.o -o foo'); |
| 28 |
unlink('foo.c'); |
| 29 |
|
| 30 |
|
| 31 |
# Test implicit rules with '$' in the name (see se_implicit) |
| 32 |
|
| 33 |
run_make_test(q! |
| 34 |
%.foo : baz$$bar ; @echo 'done $<' |
| 35 |
%.foo : bar$$baz ; @echo 'done $<' |
| 36 |
test.foo: |
| 37 |
baz$$bar bar$$baz: ; @echo '$@' |
| 38 |
!, |
| 39 |
'', |
| 40 |
"baz\$bar\ndone baz\$bar"); |
| 41 |
|
| 42 |
|
| 43 |
# Test implicit rules with '$' in the name (see se_implicit) |
| 44 |
# Use the '$' in the pattern. |
| 45 |
|
| 46 |
run_make_test(q! |
| 47 |
%.foo : %$$bar ; @echo 'done $<' |
| 48 |
test.foo: |
| 49 |
test$$bar: ; @echo '$@' |
| 50 |
!, |
| 51 |
'', |
| 52 |
"test\$bar\ndone test\$bar"); |
| 53 |
|
| 54 |
# Make sure that subdirectories built as prerequisites are actually handled |
| 55 |
# properly... this time with '$' |
| 56 |
|
| 57 |
run_make_test(q! |
| 58 |
|
| 59 |
all: dir/subdir/file.$$a |
| 60 |
|
| 61 |
dir/subdir: ; @echo mkdir -p '$@' |
| 62 |
|
| 63 |
dir/subdir/file.$$b: dir/subdir ; @echo touch '$@' |
| 64 |
|
| 65 |
dir/subdir/%.$$a: dir/subdir/%.$$b ; @echo 'cp $< $@' |
| 66 |
!, |
| 67 |
'', "mkdir -p dir/subdir\ntouch dir/subdir/file.\$b\ncp dir/subdir/file.\$b dir/subdir/file.\$a\n"); |
| 68 |
|
| 69 |
# Test odd whitespace at the beginning of a line |
| 70 |
|
| 71 |
run_make_test(" |
| 72 |
all: |
| 73 |
\f |
| 74 |
|
| 75 |
\\ |
| 76 |
\f \\ |
| 77 |
\013 \\ |
| 78 |
all: ; \@echo hi |
| 79 |
", |
| 80 |
'', "hi\n"); |
| 81 |
|
| 82 |
# SV-56834 Ensure setting PATH in the makefile works properly |
| 83 |
my $sname = "foobar$scriptsuffix"; |
| 84 |
|
| 85 |
mkdir('sd', 0775); |
| 86 |
create_file("sd/$sname", "exit 0\n"); |
| 87 |
chmod 0755, "sd/$sname"; |
| 88 |
|
| 89 |
run_make_test(qq! |
| 90 |
PATH := sd |
| 91 |
all: ; $sname >/dev/null |
| 92 |
!, |
| 93 |
'', "$sname >/dev/null\n"); |
| 94 |
|
| 95 |
# Don't use the general PATH if not found on the target path |
| 96 |
|
| 97 |
$ENV{PATH} = "$ENV{PATH}:sd"; |
| 98 |
|
| 99 |
my ($ernum, $erstr); |
| 100 |
|
| 101 |
if ($port_type eq 'W32') { |
| 102 |
$ernum = 2; |
| 103 |
$erstr = "process_begin: CreateProcess(NULL, $sname, ...) failed.\nmake (e=2): The system cannot find the file specified."; |
| 104 |
} else { |
| 105 |
$ernum = 127; |
| 106 |
$erstr = "#MAKE#: $sname: $ERR_no_such_file"; |
| 107 |
} |
| 108 |
|
| 109 |
run_make_test(qq! |
| 110 |
PATH := .. |
| 111 |
all: ; $sname |
| 112 |
!, |
| 113 |
'', "$sname\n$erstr\n#MAKE#: *** [#MAKEFILE#:3: all] Error $ernum", 512); |
| 114 |
|
| 115 |
unlink("sd/$sname"); |
| 116 |
rmdir('sd'); |
| 117 |
|
| 118 |
# Ensure that local programs are not found if "." is not on the PATH |
| 119 |
|
| 120 |
create_file($sname, ''); |
| 121 |
chmod 0755, $sname; |
| 122 |
|
| 123 |
if ($port_type eq 'W32') { |
| 124 |
$ernum = -1; |
| 125 |
$erstr = ""; |
| 126 |
} else { |
| 127 |
$ernum = 127; |
| 128 |
$erstr = "#MAKE#: $sname: $ERR_no_such_file\n"; |
| 129 |
} |
| 130 |
|
| 131 |
run_make_test(qq! |
| 132 |
PATH := .. |
| 133 |
all: ; $sname |
| 134 |
!, |
| 135 |
'', "$sname\n$erstr#MAKE#: *** [#MAKEFILE#:3: all] Error $ernum", 512); |
| 136 |
|
| 137 |
unlink($sname); |
| 138 |
|
| 139 |
if ($port_type eq 'UNIX') { |
| 140 |
# SV 57674: ensure we use a system default PATH if one is not set |
| 141 |
delete $ENV{PATH}; |
| 142 |
run_make_test(q! |
| 143 |
a: ; @echo hi |
| 144 |
!, |
| 145 |
'', "hi\n"); |
| 146 |
} |
| 147 |
|
| 148 |
1; |