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