| 1 | # -*-perl-*-
|
|---|
| 2 |
|
|---|
| 3 | $description = "Test the behaviour of the .INTERMEDIATE target.";
|
|---|
| 4 |
|
|---|
| 5 | $details = "\
|
|---|
| 6 | Test the behavior of the .INTERMEDIATE special target.
|
|---|
| 7 | Create a makefile where a file would not normally be considered
|
|---|
| 8 | intermediate, then specify it as .INTERMEDIATE. Build and ensure it's
|
|---|
| 9 | deleted properly. Rebuild to ensure that it's not created if it doesn't
|
|---|
| 10 | exist but doesn't need to be built. Change the original and ensure
|
|---|
| 11 | that the intermediate file and the ultimate target are both rebuilt, and
|
|---|
| 12 | that the intermediate file is again deleted.
|
|---|
| 13 |
|
|---|
| 14 | Try this with implicit rules and explicit rules: both should work.\n";
|
|---|
| 15 |
|
|---|
| 16 | open(MAKEFILE,"> $makefile");
|
|---|
| 17 |
|
|---|
| 18 | print MAKEFILE <<'EOF';
|
|---|
| 19 |
|
|---|
| 20 | .INTERMEDIATE: foo.e bar.e
|
|---|
| 21 |
|
|---|
| 22 | # Implicit rule test
|
|---|
| 23 | %.d : %.e ; cp $< $@
|
|---|
| 24 | %.e : %.f ; cp $< $@
|
|---|
| 25 |
|
|---|
| 26 | foo.d: foo.e
|
|---|
| 27 |
|
|---|
| 28 | # Explicit rule test
|
|---|
| 29 | foo.c: foo.e bar.e; cat $^ > $@
|
|---|
| 30 | EOF
|
|---|
| 31 |
|
|---|
| 32 | close(MAKEFILE);
|
|---|
| 33 |
|
|---|
| 34 | # TEST #0
|
|---|
| 35 |
|
|---|
| 36 | &utouch(-20, 'foo.f', 'bar.f');
|
|---|
| 37 |
|
|---|
| 38 | &run_make_with_options($makefile,'foo.d',&get_logfile);
|
|---|
| 39 | $answer = "cp foo.f foo.e\ncp foo.e foo.d\nrm foo.e\n";
|
|---|
| 40 | &compare_output($answer, &get_logfile(1));
|
|---|
| 41 |
|
|---|
| 42 | # TEST #1
|
|---|
| 43 |
|
|---|
| 44 | &run_make_with_options($makefile,'foo.d',&get_logfile);
|
|---|
| 45 | $answer = "$make_name: 'foo.d' is up to date.\n";
|
|---|
| 46 | &compare_output($answer, &get_logfile(1));
|
|---|
| 47 |
|
|---|
| 48 | # TEST #2
|
|---|
| 49 |
|
|---|
| 50 | &utouch(-10, 'foo.d');
|
|---|
| 51 | &touch('foo.f');
|
|---|
| 52 |
|
|---|
| 53 | &run_make_with_options($makefile,'foo.d',&get_logfile);
|
|---|
| 54 | $answer = "cp foo.f foo.e\ncp foo.e foo.d\nrm foo.e\n";
|
|---|
| 55 | &compare_output($answer, &get_logfile(1));
|
|---|
| 56 |
|
|---|
| 57 | # TEST #3
|
|---|
| 58 | # kmk+fast: differs because of different hashing.
|
|---|
| 59 |
|
|---|
| 60 | &run_make_with_options($makefile,'foo.c',&get_logfile);
|
|---|
| 61 | $answer = "cp foo.f foo.e\ncp bar.f bar.e\ncat foo.e bar.e > foo.c\n"
|
|---|
| 62 | . (!$is_kmk && !$is_fast ? "rm bar.e foo.e\n" : "rm foo.e bar.e\n");
|
|---|
| 63 | &compare_output($answer, &get_logfile(1));
|
|---|
| 64 |
|
|---|
| 65 | # TEST #4
|
|---|
| 66 |
|
|---|
| 67 | &run_make_with_options($makefile,'foo.c',&get_logfile);
|
|---|
| 68 | $answer = "$make_name: 'foo.c' is up to date.\n";
|
|---|
| 69 | &compare_output($answer, &get_logfile(1));
|
|---|
| 70 |
|
|---|
| 71 | # TEST #5
|
|---|
| 72 | # kmk+fast: differs because of different hashing.
|
|---|
| 73 |
|
|---|
| 74 | &utouch(-10, 'foo.c');
|
|---|
| 75 | &touch('foo.f');
|
|---|
| 76 |
|
|---|
| 77 | &run_make_with_options($makefile,'foo.c',&get_logfile);
|
|---|
| 78 | $answer = "cp foo.f foo.e\ncp bar.f bar.e\ncat foo.e bar.e > foo.c\n"
|
|---|
| 79 | . (!$is_kmk && !$is_fast ? "rm bar.e foo.e\n" : "rm foo.e bar.e\n");
|
|---|
| 80 | &compare_output($answer, &get_logfile(1));
|
|---|
| 81 |
|
|---|
| 82 | # TEST #6 -- added for PR/1669: don't remove files mentioned on the cmd line.
|
|---|
| 83 |
|
|---|
| 84 | &run_make_with_options($makefile,'foo.e',&get_logfile);
|
|---|
| 85 | $answer = "cp foo.f foo.e\n";
|
|---|
| 86 | &compare_output($answer, &get_logfile(1));
|
|---|
| 87 |
|
|---|
| 88 | unlink('foo.f', 'foo.e', 'foo.d', 'foo.c', 'bar.f', 'bar.e', 'bar.d', 'bar.c');
|
|---|
| 89 |
|
|---|
| 90 | # TEST #7 -- added for PR/1423
|
|---|
| 91 |
|
|---|
| 92 | $makefile2 = &get_tmpfile;
|
|---|
| 93 |
|
|---|
| 94 | open(MAKEFILE, "> $makefile2");
|
|---|
| 95 |
|
|---|
| 96 | print MAKEFILE <<'EOF';
|
|---|
| 97 | all: foo
|
|---|
| 98 | foo.a: ; touch $@
|
|---|
| 99 | %: %.a ; touch $@
|
|---|
| 100 | .INTERMEDIATE: foo.a
|
|---|
| 101 | EOF
|
|---|
| 102 |
|
|---|
| 103 | close(MAKEFILE);
|
|---|
| 104 |
|
|---|
| 105 | &run_make_with_options($makefile2, '-R', &get_logfile);
|
|---|
| 106 | $answer = "touch foo.a\ntouch foo\nrm foo.a\n";
|
|---|
| 107 | &compare_output($answer, &get_logfile(1));
|
|---|
| 108 |
|
|---|
| 109 | unlink('foo');
|
|---|
| 110 |
|
|---|
| 111 | # This tells the test driver that the perl test script executed properly.
|
|---|
| 112 | 1;
|
|---|