mirror of
https://git.savannah.gnu.org/git/make.git
synced 2025-01-01 01:33:51 +00:00
6ccf33cdbd
string into the strcache. As a side-effect, many more structure members and function arguments can/should be declared const. As mentioned in the changelog, unfortunately measurement shows that this change does not yet reduce memory. The problem is with secondary expansion: because of this we store all the prerequisites in the string cache twice. First we store the prerequisite string after initial expansion but before secondary expansion, then we store each individual file after secondary expansion and expand_deps(). I plan to change expand_deps() to be callable in either context (eval or snap_deps) then have non-second-expansion targets call expand_deps() during eval, so that we only need to store that dependency list once.
149 lines
2 KiB
Perl
149 lines
2 KiB
Perl
# -*-perl-*-
|
|
|
|
$description = "Test pattern rules.";
|
|
|
|
$details = "";
|
|
|
|
use Cwd;
|
|
|
|
$dir = cwd;
|
|
$dir =~ s,.*/([^/]+)$,../$1,;
|
|
|
|
|
|
# TEST #0: Make sure that multiple patterns where the same target
|
|
# can be built are searched even if the first one fails
|
|
# to match properly.
|
|
#
|
|
|
|
run_make_test('
|
|
.PHONY: all
|
|
|
|
all: case.1 case.2 case.3
|
|
a: void
|
|
|
|
# 1 - existing file
|
|
%.1: void
|
|
@exit 1
|
|
%.1: #MAKEFILE#
|
|
@exit 0
|
|
|
|
# 2 - phony
|
|
%.2: void
|
|
@exit 1
|
|
%.2: 2.phony
|
|
@exit 0
|
|
.PHONY: 2.phony
|
|
|
|
# 3 - implicit-phony
|
|
%.3: void
|
|
@exit 1
|
|
%.3: 3.implicit-phony
|
|
@exit 0
|
|
|
|
3.implicit-phony:
|
|
',
|
|
'',
|
|
'');
|
|
|
|
# TEST #1: 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');
|
|
|
|
|
|
# TEST #2: make sure intermediate 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");
|
|
|
|
|
|
# TEST #3: 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
|
|
|
|
%.bar:; @touch $@ && exit 1
|
|
|
|
$(dir)/foo.bar:
|
|
|
|
',
|
|
"dir=$dir",
|
|
"#MAKE#: *** [$dir/foo.bar] Error 1",
|
|
512);
|
|
|
|
unlink("$dir/foo.bar");
|
|
|
|
|
|
# TEST #4: make sure targets of a matched implicit pattern rule are
|
|
# never considered intermediate (Savannah bug #13022).
|
|
#
|
|
run_make_test('
|
|
.PHONY: all
|
|
all: foo.c foo.o
|
|
|
|
%.h %.c: %.in
|
|
touch $*.h
|
|
touch $*.c
|
|
|
|
%.o: %.c %.h
|
|
echo $+ >$@
|
|
|
|
%.o: %.c
|
|
@echo wrong rule
|
|
|
|
foo.in:
|
|
touch $@
|
|
|
|
',
|
|
'',
|
|
'touch foo.in
|
|
touch foo.h
|
|
touch foo.c
|
|
echo foo.c foo.h >foo.o');
|
|
|
|
unlink('foo.in', 'foo.h', 'foo.c', 'foo.o');
|
|
|
|
# This tells the test driver that the perl test script executed properly.
|
|
1;
|