VirtualBox

source: kBuild/trunk/src/kmk/tests/scripts/features/conditionals

Last change on this file was 3140, checked in by bird, 7 years ago

kmk: Merged in changes from GNU make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6 / https://git.savannah.gnu.org/git/make.git).

  • Property svn:eol-style set to LF
File size: 2.6 KB
Line 
1# -*-perl-*-
2$description = "Check GNU make conditionals.";
3
4$details = "Attempt various different flavors of GNU make conditionals.";
5
6run_make_test('
7arg1 = first
8arg2 = second
9arg3 = third
10arg4 = cc
11arg5 = second
12
13all:
14ifeq ($(arg1),$(arg2))
15 @echo arg1 equals arg2
16else
17 @echo arg1 NOT equal arg2
18endif
19
20ifeq \'$(arg2)\' "$(arg5)"
21 @echo arg2 equals arg5
22else
23 @echo arg2 NOT equal arg5
24endif
25
26ifneq \'$(arg3)\' \'$(arg4)\'
27 @echo arg3 NOT equal arg4
28else
29 @echo arg3 equal arg4
30endif
31
32ifndef undefined
33 @echo variable is undefined
34else
35 @echo variable undefined is defined
36endif
37ifdef arg4
38 @echo arg4 is defined
39else
40 @echo arg4 is NOT defined
41endif',
42 '',
43 'arg1 NOT equal arg2
44arg2 equals arg5
45arg3 NOT equal arg4
46variable is undefined
47arg4 is defined');
48
49
50# Test expansion of variables inside ifdef.
51
52run_make_test('
53foo = 1
54
55FOO = foo
56F = f
57
58DEF = no
59DEF2 = no
60
61ifdef $(FOO)
62DEF = yes
63endif
64
65ifdef $(F)oo
66DEF2 = yes
67endif
68
69
70DEF3 = no
71FUNC = $1
72ifdef $(call FUNC,DEF)3
73 DEF3 = yes
74endif
75
76all:; @echo DEF=$(DEF) DEF2=$(DEF2) DEF3=$(DEF3)',
77 '',
78 'DEF=yes DEF2=yes DEF3=yes');
79
80
81# Test all the different "else if..." constructs
82
83run_make_test('
84arg1 = first
85arg2 = second
86arg3 = third
87arg4 = cc
88arg5 = fifth
89
90result =
91
92ifeq ($(arg1),$(arg2))
93 result += arg1 equals arg2
94else ifeq \'$(arg2)\' "$(arg5)"
95 result += arg2 equals arg5
96else ifneq \'$(arg3)\' \'$(arg3)\'
97 result += arg3 NOT equal arg4
98else ifndef arg5
99 result += variable is undefined
100else ifdef undefined
101 result += arg4 is defined
102else
103 result += success
104endif
105
106
107all: ; @echo $(result)',
108 '',
109 'success');
110
111
112# Test some random "else if..." construct nesting
113
114run_make_test('
115arg1 = first
116arg2 = second
117arg3 = third
118arg4 = cc
119arg5 = second
120
121ifeq ($(arg1),$(arg2))
122 $(info failed 1)
123else ifeq \'$(arg2)\' "$(arg2)"
124 ifdef undefined
125 $(info failed 2)
126 else
127 $(info success)
128 endif
129else ifneq \'$(arg3)\' \'$(arg3)\'
130 $(info failed 3)
131else ifdef arg5
132 $(info failed 4)
133else ifdef undefined
134 $(info failed 5)
135else
136 $(info failed 6)
137endif
138
139.PHONY: all
140all: ; @:',
141 '',
142 'success');
143
144# SV 47960 : ensure variable assignments in non-taken legs don't cause problems
145run_make_test('
146ifneq ($(FOO),yes)
147target:
148else
149BAR = bar
150target:
151endif
152 @echo one
153',
154 '', "one\n");
155
156
157# This tells the test driver that the perl test script executed properly.
1581;
159
160### Local Variables:
161### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
162### End:
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette