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 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
# -*-perl-*-
$description = "Test suffix rules.";
$details = "";
# TEST #0: Clear all suffixes
touch('foo.c');
run_make_test(q!
.SUFFIXES:
all: foo.o ; @echo $@ $<
!,
'', "#MAKE#: *** No rule to make target 'foo.o', needed by 'all'. Stop.\n", 512);
unlink('foo.c');
# Test #1: Add a simple suffix rule
touch('foo.baz');
run_make_test(q!
.SUFFIXES: .biz .baz
.baz.biz: ; @echo make $@
!,
'foo.biz', "make foo.biz\n");
unlink('foo.baz');
# Test #2: Make sure the defaults still work
touch('foo.c');
run_make_test(undef, 'foo.o COMPILE.c=@echo OUTPUT_OPTION=', "foo.c\n");
unlink('foo.c');
# Test #3: Replacing all suffixes
touch('foo.baz');
run_make_test(q!
.SUFFIXES:
.SUFFIXES: .biz .baz
.baz.biz: ; @echo make $@
!,
'foo.biz', "make foo.biz\n");
unlink('foo.baz');
# SV 40657: Test #4: "Suffix rules" with deps are normal rules
my $prewarn = 'warning: ignoring prerequisites on suffix rule definition';
touch('foo.bar');
run_make_test(q!
.SUFFIXES:
.SUFFIXES: .biz .baz
$X.POSIX:
.baz.biz: foo.bar ; @echo make $@ from $<
!,
'X=1 .baz.biz', "#MAKEFILE#:7: $prewarn\nmake .baz.biz from foo.bar\n");
# SV 40657: Test #5: In POSIX mode we don't get a warning
run_make_test(undef, 'X= .baz.biz', "make .baz.biz from foo.bar\n");
unlink('foo.bar');
# SV 40657: Test #6: In POSIX mode, no pattern rules should be created
utouch(-20, 'foo.baz');
run_make_test(undef,
'X= foo.biz', "#MAKE#: *** No rule to make target 'foo.biz'. Stop.\n", 512);
# SV 40657: Test #7: In Non-POSIX mode, a pattern rule is created
run_make_test(undef,
'X=1 foo.biz', "#MAKEFILE#:7: $prewarn\nmake foo.biz from foo.baz\n");
# SV 40657: Test #8: ... but any prerequisites are ignored
utouch(-10, 'foo.biz');
touch('foo.bar');
run_make_test(undef,
'X=1 foo.biz', "#MAKEFILE#:7: $prewarn\n#MAKE#: 'foo.biz' is up to date.\n");
unlink('foo.baz', 'foo.biz', 'foo.bar');
touch('hello.c');
unlink('hello.o');
# sv 63821.
# Default suffix rule .c.o.
run_make_test('all: hello.o', 'COMPILE.c=@echo OUTPUT_OPTION=', 'hello.c');
# User defined rules beat built-in rules.
run_make_test(q!
all: hello.o
.c.o:; $(info $@ user defined .c.o rule)
!, '', "hello.o user defined .c.o rule\n#MAKE#: Nothing to be done for 'all'.\n");
# sv 63821.
# The same as above, but suffixes are cleared.
run_make_test(q!
all: hello.o
.SUFFIXES:
.c.o:; $(info $@ user defined .c.o rule)
!, '', "#MAKE#: *** No rule to make target 'hello.o', needed by 'all'. Stop.\n", 512);
# sv 63821.
# Suffixes are cleared and defined in the makefile.
run_make_test(q!
all: hello.o
.SUFFIXES:
.SUFFIXES: .c .o
.c.o:; $(info $@ user defined .c.o rule)
!, '', "hello.o user defined .c.o rule\n#MAKE#: Nothing to be done for 'all'.\n");
# sv 63821.
# When built-in rules are disabled, but certain suffixes are added to
# .SUFFIXES, make should exit with the 'No rule...' error message.
run_make_test(q!
.SUFFIXES: .c .o
all: hello.o
!, '-r', "#MAKE#: *** No rule to make target 'hello.o', needed by 'all'. Stop.\n", 512);
# sv 63821.
# Same as above, but this time built-in rules are disabled inside the makefile.
run_make_test(q!
MAKEFLAGS += -r
.SUFFIXES: .c .o
all: hello.o
!, '', "#MAKE#: *** No rule to make target 'hello.o', needed by 'all'. Stop.\n", 512);
# sv 63821.
# Same as above, but this time there is a rule.
run_make_test(q!
all: hello.o
MAKEFLAGS += -r
.SUFFIXES: .c .o
.c.o:; $(info $@ user defined .c.o rule)
!, '', "hello.o user defined .c.o rule\n#MAKE#: Nothing to be done for 'all'.\n");
unlink('hello.c', 'hello.o');
# Complete
1;
|