2004-09-22 12:36:17 +08:00
|
|
|
# -*-perl-*-
|
|
|
|
|
|
|
|
$description = "Test pattern rules.";
|
|
|
|
|
|
|
|
$details = "";
|
|
|
|
|
2005-03-10 17:14:09 +08:00
|
|
|
use Cwd;
|
|
|
|
|
|
|
|
$dir = cwd;
|
|
|
|
$dir =~ s,.*/([^/]+)$,../$1,;
|
|
|
|
|
|
|
|
|
2005-03-04 22:31:09 +08:00
|
|
|
# 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.
|
|
|
|
#
|
2004-09-22 12:36:17 +08:00
|
|
|
|
|
|
|
run_make_test('
|
|
|
|
.PHONY: all
|
|
|
|
|
|
|
|
all: case.1 case.2 case.3
|
|
|
|
a: void
|
|
|
|
|
|
|
|
# 1 - existing file
|
|
|
|
%.1: void
|
2005-07-04 11:50:59 +08:00
|
|
|
@exit 1
|
2004-09-22 12:36:17 +08:00
|
|
|
%.1: #MAKEFILE#
|
2005-07-04 11:50:59 +08:00
|
|
|
@exit 0
|
2004-09-22 12:36:17 +08:00
|
|
|
|
|
|
|
# 2 - phony
|
|
|
|
%.2: void
|
2005-07-04 11:50:59 +08:00
|
|
|
@exit 1
|
2004-09-22 12:36:17 +08:00
|
|
|
%.2: 2.phony
|
2005-07-04 11:50:59 +08:00
|
|
|
@exit 0
|
2004-09-22 12:36:17 +08:00
|
|
|
.PHONY: 2.phony
|
|
|
|
|
|
|
|
# 3 - implicit-phony
|
|
|
|
%.3: void
|
2005-07-04 11:50:59 +08:00
|
|
|
@exit 1
|
2004-09-22 12:36:17 +08:00
|
|
|
%.3: 3.implicit-phony
|
2005-07-04 11:50:59 +08:00
|
|
|
@exit 0
|
2004-09-22 12:36:17 +08:00
|
|
|
|
|
|
|
3.implicit-phony:
|
2005-03-04 22:31:09 +08:00
|
|
|
',
|
|
|
|
'',
|
|
|
|
'');
|
|
|
|
|
|
|
|
# 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');
|
2004-09-22 12:36:17 +08:00
|
|
|
|
|
|
|
|
2005-03-10 17:14:09 +08:00
|
|
|
# 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");
|
|
|
|
|
2005-06-01 04:54:30 +08:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2005-06-28 06:18:47 +08:00
|
|
|
%.bar:; @touch $@ && exit 1
|
2005-06-01 04:54:30 +08:00
|
|
|
|
|
|
|
$(dir)/foo.bar:
|
|
|
|
|
|
|
|
',
|
|
|
|
"dir=$dir",
|
2005-07-04 11:50:59 +08:00
|
|
|
"#MAKE#: *** [$dir/foo.bar] Error 1",
|
2005-06-01 04:54:30 +08:00
|
|
|
512);
|
|
|
|
|
|
|
|
unlink("$dir/foo.bar");
|
|
|
|
|
2004-09-22 12:36:17 +08:00
|
|
|
# This tells the test driver that the perl test script executed properly.
|
|
|
|
1;
|