| 1 |
# -*-perl-*- |
| 2 |
$description = "Test the .INCLUDE_DIRS special variable."; |
| 3 |
|
| 4 |
$details = ""; |
| 5 |
|
| 6 |
use Cwd; |
| 7 |
|
| 8 |
$dir = cwd; |
| 9 |
$dir =~ s,.*/([^/]+)$,../$1,; |
| 10 |
|
| 11 |
if (-d '/usr/include') { |
| 12 |
# Test #1: The content of .INCLUDE_DIRS depends on the platform for which |
| 13 |
# make was built. What we know for sure is that it shouldn't be |
| 14 |
# empty. |
| 15 |
# |
| 16 |
run_make_test(' |
| 17 |
ifeq ($(.INCLUDE_DIRS),) |
| 18 |
$(warning .INCLUDE_DIRS is empty) |
| 19 |
endif |
| 20 |
|
| 21 |
.PHONY: all |
| 22 |
all:;@: |
| 23 |
', |
| 24 |
'', ''); |
| 25 |
} |
| 26 |
|
| 27 |
# Test #2: Make sure -I paths end up in .INCLUDE_DIRS. |
| 28 |
# |
| 29 |
run_make_test(' |
| 30 |
ifeq ($(dir),) |
| 31 |
$(warning dir is empty) |
| 32 |
endif |
| 33 |
|
| 34 |
ifeq ($(filter $(dir),$(.INCLUDE_DIRS)),) |
| 35 |
$(warning .INCLUDE_DIRS does not contain $(dir): $(.INCLUDE_DIRS)) |
| 36 |
endif |
| 37 |
|
| 38 |
.PHONY: all |
| 39 |
all:;@: |
| 40 |
', |
| 41 |
"-I$dir dir=$dir", ''); |
| 42 |
|
| 43 |
# Find the default .INCLUDE_DIRS |
| 44 |
create_file('defaultdirs.mk', "\$(info \$(.INCLUDE_DIRS))\nall:;\@:\n"); |
| 45 |
my $cmd = subst_make_string("#MAKEPATH# -f defaultdirs.mk"); |
| 46 |
my @dirs = `$cmd`; |
| 47 |
my $dirs = $dirs[0]; |
| 48 |
$dirs =~ s/\r?\n//g; |
| 49 |
unlink('defaultdirs.mk'); |
| 50 |
|
| 51 |
run_make_test(" |
| 52 |
ifneq (\$(.INCLUDE_DIRS),$dirs) |
| 53 |
\$(warning Mismatched \$(.INCLUDE_DIRS) != $dirs) |
| 54 |
endif |
| 55 |
all:;\@: |
| 56 |
", |
| 57 |
'', ''); |
| 58 |
|
| 59 |
# Verify that -I- disables content from .INCLUDE_DIRS |
| 60 |
|
| 61 |
run_make_test(q/ |
| 62 |
ifneq ($(.INCLUDE_DIRS),) |
| 63 |
$(warning Mismatched $(.INCLUDE_DIRS) != ) |
| 64 |
endif |
| 65 |
all:;@: |
| 66 |
/, |
| 67 |
'-I-', ''); |
| 68 |
|
| 69 |
# Prefix -I dirs to the front |
| 70 |
mkdir('somedir', 0777); |
| 71 |
|
| 72 |
my $xdirs = $dirs ? " $dirs" : ''; |
| 73 |
run_make_test(" |
| 74 |
ifneq (\$(.INCLUDE_DIRS),somedir$xdirs) |
| 75 |
\$(warning Mismatched '\$(.INCLUDE_DIRS)' != 'somedir$xdirs') |
| 76 |
endif |
| 77 |
all:;\@: |
| 78 |
", |
| 79 |
'-I somedir', ''); |
| 80 |
|
| 81 |
# Verify .INCLUDE_DIRS contains files after -I- |
| 82 |
|
| 83 |
run_make_test(q/ |
| 84 |
ifneq ($(.INCLUDE_DIRS),somedir) |
| 85 |
$(warning Mismatched $(.INCLUDE_DIRS) != somedir) |
| 86 |
endif |
| 87 |
all:;@: |
| 88 |
/, |
| 89 |
'-I - -I somedir', ''); |
| 90 |
|
| 91 |
rmdir('somedir'); |
| 92 |
|
| 93 |
# This tells the test driver that the perl test script executed properly. |
| 94 |
1; |