1 | # -*-perl-*-
|
---|
2 |
|
---|
3 | $description = "Test various flavors of make variable setting.";
|
---|
4 |
|
---|
5 | $details = "";
|
---|
6 |
|
---|
7 | open(MAKEFILE, "> $makefile");
|
---|
8 |
|
---|
9 | # The Contents of the MAKEFILE ...
|
---|
10 |
|
---|
11 | print MAKEFILE <<'EOF';
|
---|
12 | foo = $(bar)
|
---|
13 | bar = ${ugh}
|
---|
14 | ugh = Hello
|
---|
15 |
|
---|
16 | all: multi ; @echo $(foo)
|
---|
17 |
|
---|
18 | multi: ; $(multi)
|
---|
19 |
|
---|
20 | x := foo
|
---|
21 | y := $(x) bar
|
---|
22 | x := later
|
---|
23 |
|
---|
24 | nullstring :=
|
---|
25 | space := $(nullstring) $(nullstring)
|
---|
26 |
|
---|
27 | next: ; @echo $x$(space)$y
|
---|
28 |
|
---|
29 | define multi
|
---|
30 | @echo hi
|
---|
31 | echo there
|
---|
32 | endef
|
---|
33 |
|
---|
34 | ifdef BOGUS
|
---|
35 | define
|
---|
36 | @echo error
|
---|
37 | endef
|
---|
38 | endif
|
---|
39 |
|
---|
40 | define outer
|
---|
41 | define inner
|
---|
42 | A = B
|
---|
43 | endef
|
---|
44 | endef
|
---|
45 |
|
---|
46 | $(eval $(outer))
|
---|
47 |
|
---|
48 | outer: ; @echo $(inner)
|
---|
49 |
|
---|
50 | EOF
|
---|
51 |
|
---|
52 | # END of Contents of MAKEFILE
|
---|
53 |
|
---|
54 | close(MAKEFILE);
|
---|
55 |
|
---|
56 | # TEST #1
|
---|
57 | # -------
|
---|
58 |
|
---|
59 | &run_make_with_options($makefile, "", &get_logfile);
|
---|
60 | $answer = "hi\necho there\nthere\nHello\n";
|
---|
61 | &compare_output($answer, &get_logfile(1));
|
---|
62 |
|
---|
63 | # TEST #2
|
---|
64 | # -------
|
---|
65 |
|
---|
66 | &run_make_with_options($makefile, "next", &get_logfile);
|
---|
67 | $answer = "later foo bar\n";
|
---|
68 | &compare_output($answer, &get_logfile(1));
|
---|
69 |
|
---|
70 | # TEST #3
|
---|
71 | # -------
|
---|
72 |
|
---|
73 | &run_make_with_options($makefile, "BOGUS=true", &get_logfile, 512);
|
---|
74 | $answer = "$makefile:23: *** empty variable name. Stop.\n";
|
---|
75 | &compare_output($answer, &get_logfile(1));
|
---|
76 |
|
---|
77 | # TEST #4
|
---|
78 | # -------
|
---|
79 |
|
---|
80 | &run_make_with_options($makefile, "outer", &get_logfile);
|
---|
81 | $answer = "A = B\n";
|
---|
82 | &compare_output($answer, &get_logfile(1));
|
---|
83 |
|
---|
84 |
|
---|
85 | 1;
|
---|