mult_rules 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. $description = "\
  2. The following test creates a makefile to test the presence
  3. of multiple rules for one target. One file can be the
  4. target of several rules if at most one rule has commands;
  5. the other rules can only have dependencies.";
  6. $details = "\
  7. The makefile created in this test contains two hardcoded rules
  8. for foo.o and bar.o. It then gives another multiple target rule
  9. with the same names as above but adding more dependencies.
  10. Additionally, another variable extradeps is listed as a
  11. dependency but is defined to be null. It can however be defined
  12. on the make command line as extradeps=extra.h which adds yet
  13. another dependency to the targets.";
  14. open(MAKEFILE,"> $makefile");
  15. # The Contents of the MAKEFILE ...
  16. print MAKEFILE <<EOF;
  17. objects = foo.o bar.o
  18. foo.o : defs.h
  19. bar.o : defs.h test.h
  20. extradeps =
  21. \$(objects) : config.h \$(extradeps)
  22. \t\@echo EXTRA EXTRA
  23. EOF
  24. # END of Contents of MAKEFILE
  25. close(MAKEFILE);
  26. &touch("defs.h","test.h","config.h");
  27. if ($vos)
  28. {
  29. $error_code = 3307;
  30. }
  31. else
  32. {
  33. $error_code = 512;
  34. }
  35. &run_make_with_options($makefile,
  36. "extradeps=extra.h",
  37. &get_logfile,
  38. $error_code);
  39. # Create the answer to what should be produced by this Makefile
  40. $answer = "$make_name: *** No rule to make target `extra.h', needed by `foo.o'. Stop.\n";
  41. &compare_output($answer,&get_logfile(1));
  42. # TEST #2
  43. # -------
  44. &touch("extra.h");
  45. &run_make_with_options($makefile,
  46. "extradeps=extra.h",
  47. &get_logfile,
  48. 0);
  49. # Create the answer to what should be produced by this Makefile
  50. $answer = "EXTRA EXTRA\n";
  51. &compare_output($answer,&get_logfile(1));
  52. unlink("defs.h","test.h","config.h","extra.h");
  53. 1;