vpathplus 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # -*-perl-*-
  2. $description = "Tests the new VPATH+ functionality added in 3.76.";
  3. $details = "";
  4. $VP = "$workdir$pathsep";
  5. open(MAKEFILE,"> $makefile");
  6. # The Contents of the MAKEFILE ...
  7. print MAKEFILE "VPATH = $VP\n";
  8. print MAKEFILE <<'EOMAKE';
  9. SHELL = /bin/sh
  10. .SUFFIXES: .a .b .c .d
  11. .PHONY: general rename notarget intermediate
  12. %.a:
  13. %.b:
  14. %.c:
  15. %.d:
  16. %.a : %.b
  17. cat $^ > $@
  18. %.b : %.c
  19. cat $^ > $@ 2>/dev/null || exit 1
  20. %.c :: %.d
  21. cat $^ > $@
  22. # General testing info:
  23. general: foo.b
  24. foo.b: foo.c bar.c
  25. # Rename testing info:
  26. rename: $(VPATH)/foo.c foo.d
  27. # Target not made testing info:
  28. notarget: notarget.b
  29. notarget.c: notarget.d
  30. -@echo "not creating $@ from $^"
  31. # Intermediate files:
  32. intermediate: inter.a
  33. EOMAKE
  34. close(MAKEFILE);
  35. @touchedfiles = ();
  36. sub touchfiles {
  37. foreach (@_) {
  38. sleep($wtime);
  39. ($f = $_) =~ s,VP/,$VP,g;
  40. &touch($f);
  41. push(@touchedfiles, $f);
  42. }
  43. }
  44. # Run the general-case test
  45. &touchfiles("VP/foo.d", "VP/bar.d", "VP/foo.c", "VP/bar.c", "foo.b", "bar.d");
  46. &run_make_with_options($makefile,"general",&get_logfile);
  47. push(@touchedfiles, "bar.c");
  48. $answer = "cat bar.d > bar.c
  49. cat ${VP}foo.c bar.c > foo.b 2>/dev/null || exit 1
  50. ";
  51. &compare_output($answer,&get_logfile(1));
  52. # Test rules that don't make the target correctly
  53. &touchfiles("VP/notarget.c", "notarget.b", "notarget.d");
  54. &run_make_with_options($makefile,"notarget",&get_logfile,512);
  55. $answer = "not creating notarget.c from notarget.d
  56. cat notarget.c > notarget.b 2>/dev/null || exit 1
  57. $make_name: *** [notarget.b] Error 1
  58. ";
  59. &compare_output($answer,&get_logfile(1));
  60. # Test intermediate file handling (part 1)
  61. &touchfiles("VP/inter.d");
  62. &run_make_with_options($makefile,"intermediate",&get_logfile);
  63. push(@touchedfiles, "inter.a", "inter.b");
  64. $answer = "cat ${VP}inter.d > inter.c
  65. cat inter.c > inter.b 2>/dev/null || exit 1
  66. cat inter.b > inter.a
  67. rm inter.b inter.c
  68. ";
  69. &compare_output($answer,&get_logfile(1));
  70. # Test intermediate file handling (part 2)
  71. &touchfiles("VP/inter.b", "VP/inter.d");
  72. &run_make_with_options($makefile,"intermediate",&get_logfile);
  73. $answer = "cat ${VP}inter.d > inter.c
  74. cat inter.c > inter.b 2>/dev/null || exit 1
  75. cat inter.b > inter.a
  76. rm inter.c
  77. ";
  78. &compare_output($answer,&get_logfile(1));
  79. unlink @touchedfiles unless $keep;
  80. 1;