1#                                                                    -*-perl-*-
2$description = "Test the -n option.\n";
3
4$details = "Try various uses of -n and ensure they all give the correct results.\n";
5
6open(MAKEFILE, "> $makefile");
7
8# The Contents of the MAKEFILE ...
9
10print MAKEFILE <<'EOMAKE';
11
12final: intermediate ; echo >> $@
13intermediate: orig ; echo >> $@
14
15EOMAKE
16
17close(MAKEFILE);
18
19&touch('orig');
20
21# TEST 0
22
23&run_make_with_options($makefile, "", &get_logfile);
24$answer = "echo >> intermediate\necho >> final\n";
25&compare_output($answer, &get_logfile(1));
26
27# TEST 1
28
29&run_make_with_options($makefile, "-Worig -n", &get_logfile);
30$answer = "echo >> intermediate\necho >> final\n";
31&compare_output($answer, &get_logfile(1));
32
33unlink('orig', 'intermediate', 'final');
34
35# We consider the actual updated timestamp of targets with all
36# recursive commands, even with -n.
37
38$makefile2 = &get_tmpfile;
39
40open(MAKEFILE, "> $makefile2");
41
42print MAKEFILE <<'EOF';
43.SUFFIXES:
44BAR =     # nothing
45FOO = +$(BAR)
46a: b; echo > $@
47b: c; $(FOO)
48EOF
49
50close(MAKEFILE);
51
52&utouch(-20, 'b');
53&utouch(-10, 'a');
54&touch('c');
55
56# TEST 2
57
58&run_make_with_options($makefile2, "", &get_logfile);
59$answer = "$make_name: `a' is up to date.\n";
60&compare_output($answer, &get_logfile(1));
61
62# TEST 3
63
64&run_make_with_options($makefile2, "-n", &get_logfile);
65$answer = "$make_name: `a' is up to date.\n";
66&compare_output($answer, &get_logfile(1));
67
68unlink('a', 'b', 'c');
69
701;
71