* Handle case of empty static pattern rule prerequisites.
[make.git] / tests / scripts / features / statipattrules
blob29a7c08cbf794116147caabb85e7ad85e389528e
1 #                                                                    -*-perl-*-
2 $description = "Test handling of static pattern rules.";
4 $details = "\
5 The makefile created in this test has three targets.  The
6 filter command is used to get those target names ending in
7 .o and statically creates a compile command with the target
8 name and the target name with .c.  It also does the same thing
9 for another target filtered with .elc and creates a command
10 to emacs a .el file";
12 open(MAKEFILE,"> $makefile");
13 print MAKEFILE <<'EOF';
14 files = foo.elc bar.o lose.o
16 $(filter %.o,$(files)): %.o: %.c ; @echo CC -c $(CFLAGS) $< -o $@
18 $(filter %.elc,$(files)): %.elc: %.el ; @echo emacs $<
19 EOF
20 close(MAKEFILE);
23 &touch('bar.c', 'lose.c');
25 #   TEST #1
26 #   -------
28 &run_make_with_options($makefile, '', &get_logfile);
29 $answer = "CC -c bar.c -o bar.o\n";
30 &compare_output($answer, &get_logfile(1));
33 #  TEST #2
34 #  -------
36 &run_make_with_options($makefile, 'lose.o', &get_logfile);
37 $answer = "CC -c lose.c -o lose.o\n";
38 &compare_output($answer, &get_logfile(1));
41 #   TEST #3
42 #   -------
43 &touch("foo.el");
45 &run_make_with_options($makefile, 'foo.elc', &get_logfile);
46 $answer = "emacs foo.el\n";
47 &compare_output($answer, &get_logfile(1));
50 unlink('foo.el', 'bar.c', 'lose.c');
53 # TEST #4 -- PR/1670: don't core dump on invalid static pattern rules
54 # -------
56 $makefile2 = &get_tmpfile;
57 open(MAKEFILE, "> $makefile2");
58 print MAKEFILE "foo: foo%: % ; \@echo $@\n";
59 close(MAKEFILE);
61 &run_make_with_options($makefile2, '', &get_logfile, 512);
62 $answer = "$makefile2:1: *** target `foo' leaves prerequisite pattern empty.  Stop.\n";
63 &compare_output($answer, &get_logfile(1));