Imported Upstream version 3.82
[platform/upstream/make.git] / tests / scripts / options / dash-f
1 $description = "The following test tests that if you specify greater \n"
2               ."than one '-f makefilename' on the command line, \n"
3               ."that make concatenates them.  This test creates three \n"
4               ."makefiles and specifies all of them with the -f option \n"
5               ."on the command line.  To make sure they were concatenated, \n"
6               ."we then call make with the rules from the concatenated \n"
7               ."makefiles one at a time.  Finally, it calls all three \n"
8               ."rules in one call to make and checks that the output\n"
9               ."is in the correct order.";
10
11 $makefile2 = &get_tmpfile;
12 $makefile3 = &get_tmpfile;
13
14 open(MAKEFILE,"> $makefile");
15
16 # The Contents of the MAKEFILE ...
17
18 print MAKEFILE "all: \n";
19 print MAKEFILE "\t\@echo This is the output from the original makefile\n";
20
21 # END of Contents of MAKEFILE
22
23 close(MAKEFILE);
24
25 # Create a second makefile
26 open(MAKEFILE,"> $makefile2");
27 print MAKEFILE "TWO: \n";
28 print MAKEFILE "\t\@echo This is the output from makefile 2\n";
29 close(MAKEFILE);
30
31 # Create a third makefile
32 open(MAKEFILE,"> $makefile3");
33 print MAKEFILE "THREE: \n";
34 print MAKEFILE "\t\@echo This is the output from makefile 3\n";
35 close(MAKEFILE);
36
37
38 # Create the answer to what should be produced by this Makefile
39 $answer = "This is the output from the original makefile\n";
40
41 # Run make to catch the default rule
42 &run_make_with_options($makefile,"-f $makefile2 -f $makefile3",&get_logfile,0);
43
44 &compare_output($answer,&get_logfile(1));
45
46
47 # Run Make again with the rule from the second makefile: TWO
48 $answer = "This is the output from makefile 2\n";
49
50 &run_make_with_options($makefile,"-f $makefile2 -f $makefile3 TWO",&get_logfile,0);
51
52 &compare_output($answer,&get_logfile(1));
53      
54
55 # Run Make again with the rule from the third makefile: THREE
56
57 $answer = "This is the output from makefile 3\n";
58 &run_make_with_options($makefile,
59                        "-f $makefile2 -f $makefile3 THREE",
60                        &get_logfile,
61                        0);
62 &compare_output($answer,&get_logfile(1));
63
64
65 # Run Make again with ALL three rules in the order 2 1 3 to make sure
66 # that all rules are executed in the proper order
67
68 $answer = "This is the output from makefile 2\n";
69 $answer .= "This is the output from the original makefile\n";
70 $answer .= "This is the output from makefile 3\n";
71 &run_make_with_options($makefile,
72                        "-f $makefile2 -f $makefile3 TWO all THREE",
73                        &get_logfile,
74                        0);
75 &compare_output($answer,&get_logfile(1));
76        
77
78
79
80
81
82
83
84
85