2 $description = "Check GNU make export/unexport commands.";
6 # The test driver cleans out our environment for us so we don't have to worry
9 open(MAKEFILE,"> $makefile");
11 # The Contents of the MAKEFILE ...
13 print MAKEFILE <<'EOMAKE';
36 ifdef EXPORT_ALL_PSEUDO
37 .EXPORT_ALL_VARIABLES:
41 @echo "FOO=$(FOO) BAR=$(BAR) BAZ=$(BAZ) BOZ=$(BOZ) BITZ=$(BITZ) BOTZ=$(BOTZ)"
42 @echo "FOO=$$FOO BAR=$$BAR BAZ=$$BAZ BOZ=$$BOZ BITZ=$$BITZ BOTZ=$$BOTZ"
50 &run_make_with_options($makefile,"",&get_logfile,0);
52 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
53 FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
55 &compare_output($answer,&get_logfile(1));
57 # TEST 1: make sure vars inherited from the parent are exported
61 &run_make_with_options($makefile,"",&get_logfile,0);
63 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
64 FOO=foo BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
66 &compare_output($answer,&get_logfile(1));
70 # TEST 2: global export. Explicit unexport takes precedence.
72 &run_make_with_options($makefile,"EXPORT_ALL=1",&get_logfile,0);
74 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
75 FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
77 &compare_output($answer,&get_logfile(1));
79 # TEST 3: global unexport. Explicit export takes precedence.
81 &run_make_with_options($makefile,"UNEXPORT_ALL=1",&get_logfile,0);
83 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
84 FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
86 &compare_output($answer,&get_logfile(1));
88 # TEST 4: both: in the above makefile the unexport comes last so that rules.
90 &run_make_with_options($makefile,"EXPORT_ALL=1 UNEXPORT_ALL=1",&get_logfile,0);
92 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
93 FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
95 &compare_output($answer,&get_logfile(1));
97 # TEST 5: test the pseudo target.
99 &run_make_with_options($makefile,"EXPORT_ALL_PSEUDO=1",&get_logfile,0);
101 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
102 FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
104 &compare_output($answer,&get_logfile(1));
107 # TEST 6: Test the expansion of variables inside export
109 $makefile2 = &get_tmpfile;
111 open(MAKEFILE, "> $makefile2");
113 print MAKEFILE <<'EOF';
128 @echo foo=$(foo) bar=$(bar)
129 @echo foo=$$foo bar=$$bar
135 &run_make_with_options($makefile2,"",&get_logfile,0);
136 $answer = "foo=f-ok bar=b-ok\nfoo=f-ok bar=b-ok\n";
137 &compare_output($answer,&get_logfile(1));
140 # TEST 7: Test the expansion of variables inside unexport
142 $makefile3 = &get_tmpfile;
144 open(MAKEFILE, "> $makefile3");
146 print MAKEFILE <<'EOF';
163 @echo foo=$(foo) bar=$(bar)
164 @echo foo=$$foo bar=$$bar
170 &run_make_with_options($makefile3,"",&get_logfile,0);
171 $answer = "foo=f-ok bar=b-ok\nfoo= bar=\n";
172 &compare_output($answer,&get_logfile(1));
175 # TEST 7: Test exporting multiple variables on the same line
177 $makefile4 = &get_tmpfile;
179 open(MAKEFILE, "> $makefile4");
181 print MAKEFILE <<'EOF';
200 all: ; @echo A=$$A B=$$B C=$$C D=$$D E=$$E F=$$F G=$$G H=$$H I=$$I J=$$J
205 &run_make_with_options($makefile4,"",&get_logfile,0);
206 $answer = "A=a B=b C=c D=d E=e F=f G=g H=h I=i J=j\n";
207 &compare_output($answer,&get_logfile(1));
210 # TEST 8: Test unexporting multiple variables on the same line
212 $makefile5 = &get_tmpfile;
214 open(MAKEFILE, "> $makefile5");
216 print MAKEFILE <<'EOF';
235 all: ; @echo A=$$A B=$$B C=$$C D=$$D E=$$E F=$$F G=$$G H=$$H I=$$I J=$$J
240 @ENV{qw(A B C D E F G H I J)} = qw(1 2 3 4 5 6 7 8 9 10);
242 &run_make_with_options($makefile5,"",&get_logfile,0);
243 $answer = "A= B= C= D= E= F= G= H= I= J=\n";
244 &compare_output($answer,&get_logfile(1));
246 delete @ENV{qw(A B C D E F G H I J)};
249 # This tells the test driver that the perl test script executed properly.