1 | # -*-perl-*-
|
---|
2 | $description = "Check GNU make conditionals.";
|
---|
3 |
|
---|
4 | $details = "Attempt various different flavors of GNU make conditionals.";
|
---|
5 |
|
---|
6 | open(MAKEFILE,"> $makefile");
|
---|
7 |
|
---|
8 | # The Contents of the MAKEFILE ...
|
---|
9 |
|
---|
10 | print MAKEFILE <<'EOMAKE';
|
---|
11 | objects = foo.obj
|
---|
12 | arg1 = first
|
---|
13 | arg2 = second
|
---|
14 | arg3 = third
|
---|
15 | arg4 = cc
|
---|
16 | arg5 = second
|
---|
17 |
|
---|
18 | all:
|
---|
19 | ifeq ($(arg1),$(arg2))
|
---|
20 | @echo arg1 equals arg2
|
---|
21 | else
|
---|
22 | @echo arg1 NOT equal arg2
|
---|
23 | endif
|
---|
24 |
|
---|
25 | ifeq '$(arg2)' "$(arg5)"
|
---|
26 | @echo arg2 equals arg5
|
---|
27 | else
|
---|
28 | @echo arg2 NOT equal arg5
|
---|
29 | endif
|
---|
30 |
|
---|
31 | ifneq '$(arg3)' '$(arg4)'
|
---|
32 | @echo arg3 NOT equal arg4
|
---|
33 | else
|
---|
34 | @echo arg3 equal arg4
|
---|
35 | endif
|
---|
36 |
|
---|
37 | ifndef undefined
|
---|
38 | @echo variable is undefined
|
---|
39 | else
|
---|
40 | @echo variable undefined is defined
|
---|
41 | endif
|
---|
42 | ifdef arg4
|
---|
43 | @echo arg4 is defined
|
---|
44 | else
|
---|
45 | @echo arg4 is NOT defined
|
---|
46 | endif
|
---|
47 |
|
---|
48 | EOMAKE
|
---|
49 |
|
---|
50 | close(MAKEFILE);
|
---|
51 |
|
---|
52 | &run_make_with_options($makefile,"",&get_logfile,0);
|
---|
53 |
|
---|
54 | $answer = "arg1 NOT equal arg2
|
---|
55 | arg2 equals arg5
|
---|
56 | arg3 NOT equal arg4
|
---|
57 | variable is undefined
|
---|
58 | arg4 is defined
|
---|
59 | ";
|
---|
60 |
|
---|
61 | &compare_output($answer,&get_logfile(1));
|
---|
62 |
|
---|
63 |
|
---|
64 | # Test expansion of variables inside ifdef.
|
---|
65 |
|
---|
66 | $makefile2 = &get_tmpfile;
|
---|
67 |
|
---|
68 | open(MAKEFILE, "> $makefile2");
|
---|
69 |
|
---|
70 | print MAKEFILE <<'EOF';
|
---|
71 |
|
---|
72 | foo = 1
|
---|
73 |
|
---|
74 | FOO = foo
|
---|
75 | F = f
|
---|
76 |
|
---|
77 | DEF = no
|
---|
78 | DEF2 = no
|
---|
79 |
|
---|
80 | ifdef $(FOO)
|
---|
81 | DEF = yes
|
---|
82 | endif
|
---|
83 |
|
---|
84 | ifdef $(F)oo
|
---|
85 | DEF2 = yes
|
---|
86 | endif
|
---|
87 |
|
---|
88 |
|
---|
89 | DEF3 = no
|
---|
90 | FUNC = $1
|
---|
91 | ifdef $(call FUNC,DEF)3
|
---|
92 | DEF3 = yes
|
---|
93 | endif
|
---|
94 |
|
---|
95 | all:; @echo DEF=$(DEF) DEF2=$(DEF2) DEF3=$(DEF3)
|
---|
96 |
|
---|
97 | EOF
|
---|
98 |
|
---|
99 | close(MAKEFILE)
|
---|
100 |
|
---|
101 | &run_make_with_options($makefile2,"",&get_logfile,0);
|
---|
102 | $answer = "DEF=yes DEF2=yes DEF3=yes\n";
|
---|
103 | &compare_output($answer,&get_logfile(1));
|
---|
104 |
|
---|
105 |
|
---|
106 | # This tells the test driver that the perl test script executed properly.
|
---|
107 | 1;
|
---|