statipattrules 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # -*-perl-*-
  2. $description = "Test handling of static pattern rules.";
  3. $details = "\
  4. The makefile created in this test has three targets. The
  5. filter command is used to get those target names ending in
  6. .o and statically creates a compile command with the target
  7. name and the target name with .c. It also does the same thing
  8. for another target filtered with .elc and creates a command
  9. to emacs a .el file";
  10. open(MAKEFILE,"> $makefile");
  11. print MAKEFILE <<'EOF';
  12. files = foo.elc bar.o lose.o
  13. $(filter %.o,$(files)): %.o: %.c ; @echo CC -c $(CFLAGS) $< -o $@
  14. $(filter %.elc,$(files)): %.elc: %.el ; @echo emacs $<
  15. EOF
  16. close(MAKEFILE);
  17. &touch('bar.c', 'lose.c');
  18. # TEST #1
  19. # -------
  20. &run_make_with_options($makefile, '', &get_logfile);
  21. $answer = "CC -c bar.c -o bar.o\n";
  22. &compare_output($answer, &get_logfile(1));
  23. # TEST #2
  24. # -------
  25. &run_make_with_options($makefile, 'lose.o', &get_logfile);
  26. $answer = "CC -c lose.c -o lose.o\n";
  27. &compare_output($answer, &get_logfile(1));
  28. # TEST #3
  29. # -------
  30. &touch("foo.el");
  31. &run_make_with_options($makefile, 'foo.elc', &get_logfile);
  32. $answer = "emacs foo.el\n";
  33. &compare_output($answer, &get_logfile(1));
  34. unlink('foo.el', 'bar.c', 'lose.c');
  35. # TEST #4 -- PR/1670: don't core dump on invalid static pattern rules
  36. # -------
  37. $makefile2 = &get_tmpfile;
  38. open(MAKEFILE, "> $makefile2");
  39. print MAKEFILE "foo: foo%: % ; \@echo $@\n";
  40. close(MAKEFILE);
  41. &run_make_with_options($makefile2, '', &get_logfile, 512);
  42. $answer = "$makefile2:1: *** target `foo' leaves prerequisite pattern empty. Stop.\n";
  43. &compare_output($answer, &get_logfile(1));
  44. 1;