~ubuntu-branches/ubuntu/vivid/remake/vivid

« back to all changes in this revision

Viewing changes to tests/scripts/variables/define

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2012-10-04 10:45:49 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20121004104549-vvltb5m3vutmvjy0
Tags: 3.82+dbg0.9+dfsg-1
* Fresh upstream release
  - dropped emacs mode (moved into a separate project
    https://github.com/rocky/emacs-dbgr)
* Switched to use +dfsg to assure proper version
  comparison going e.g. from 0.9+dfsg to 0.9.1+dfsg
* Moved .gbp.conf under debian/gbp.conf
* Added '-b debian' for Vcs-Git field since we ship Debian
  packaging within upstream repository
* Boosted policy to 3.9.4
* Switched to source package 3.0 (quilt) format
* Switched to minimalistic dh 9.0 debian/rules
  - use dh-autoreconf (added also needed for it 'autopoint' build-dependency)
    (Closes: #536004)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#                                                                    -*-perl-*-
 
2
 
 
3
$description = "Test define/endef variable assignments.";
 
4
 
 
5
$details = "";
 
6
 
 
7
# TEST 0: old-style basic define/endef
 
8
 
 
9
run_make_test('
 
10
define multi
 
11
@echo hi
 
12
echo there
 
13
endef
 
14
 
 
15
all: ; $(multi)
 
16
',
 
17
              '', 
 
18
"hi
 
19
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
20
echo there
 
21
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
22
there
 
23
");
 
24
 
 
25
# TEST 1: Various new-style define/endef
 
26
 
 
27
run_make_test('
 
28
FOO = foo
 
29
 
 
30
define multi =
 
31
echo hi
 
32
@echo $(FOO)
 
33
endef # this is the end
 
34
 
 
35
define simple :=
 
36
@echo $(FOO)
 
37
endef
 
38
 
 
39
append = @echo a
 
40
 
 
41
define append +=
 
42
 
 
43
@echo b
 
44
endef
 
45
 
 
46
define cond ?= # this is a conditional
 
47
@echo first
 
48
endef
 
49
 
 
50
define cond ?=
 
51
@echo second
 
52
endef
 
53
 
 
54
FOO = there
 
55
 
 
56
all: ; $(multi)
 
57
        $(simple)
 
58
        $(append)
 
59
        $(cond)
 
60
',
 
61
              '', 
 
62
"##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
63
echo hi
 
64
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
65
hi\nthere\nfoo\na\nb\nfirst\n");
 
66
 
 
67
# TEST 2: define in true section of conditional (containing conditional)
 
68
 
 
69
run_make_test('
 
70
FOO = foo
 
71
NAME = def
 
72
def =
 
73
ifdef BOGUS
 
74
 define  $(subst e,e,$(NAME))     =
 
75
  ifeq (1,1)
 
76
   FOO = bar
 
77
  endif
 
78
 endef
 
79
endif
 
80
 
 
81
$(eval $(def))
 
82
all: ; @echo $(FOO)
 
83
',
 
84
              'BOGUS=1', "bar\n");
 
85
 
 
86
# TEST 3: define in false section of conditional (containing conditional)
 
87
 
 
88
run_make_test(undef, '', "foo\n");
 
89
 
 
90
# TEST 4: nested define (supported?)
 
91
 
 
92
run_make_test('
 
93
define outer
 
94
 define inner
 
95
  A = B
 
96
 endef
 
97
endef
 
98
 
 
99
$(eval $(outer))
 
100
 
 
101
outer: ; @echo $(inner)
 
102
',
 
103
              '', "A = B\n");
 
104
 
 
105
# TEST 5: NEGATIVE: Missing variable name
 
106
 
 
107
run_make_test('
 
108
NAME =
 
109
define $(NAME)  =
 
110
ouch
 
111
endef
 
112
all: ; @echo ouch
 
113
',
 
114
              '', "#MAKEFILE#:3: *** empty variable name.  Stop.
 
115
Command-line invocation:
 
116
        \"$make_path -f work/variables/define.mk.4\"
 
117
", 512);
 
118
 
 
119
# TEST 6: NEGATIVE: extra text after define
 
120
 
 
121
run_make_test('
 
122
NAME =
 
123
define NAME = $(NAME)
 
124
ouch
 
125
endef
 
126
all: ; @echo ok
 
127
',
 
128
              '', "#MAKEFILE#:3: extraneous text after `define' directive\nok\n");
 
129
 
 
130
# TEST 7: NEGATIVE: extra text after endef
 
131
 
 
132
run_make_test('
 
133
NAME =
 
134
define NAME =
 
135
ouch
 
136
endef $(NAME)
 
137
all: ; @echo ok
 
138
',
 
139
              '', "#MAKEFILE#:5: extraneous text after `endef' directive\nok\n");
 
140
 
 
141
# TEST 8: NEGATIVE: missing endef
 
142
 
 
143
run_make_test('
 
144
NAME =
 
145
all: ; @echo ok
 
146
define NAME =
 
147
ouch
 
148
endef$(NAME)
 
149
',
 
150
              '', "#MAKEFILE#:4: *** missing `endef', unterminated `define'.  Stop.
 
151
Command-line invocation:
 
152
        \"$make_path -f work/variables/define.mk.7\"
 
153
", 512);
 
154
 
 
155
# -------------------------
 
156
# Make sure that prefix characters apply properly to define/endef values.
 
157
#
 
158
# There's a bit of oddness here if you try to use a variable to hold the
 
159
# prefix character for a define.  Even though something like this:
 
160
#
 
161
#       define foo
 
162
#       echo bar
 
163
#       endef
 
164
#
 
165
#       all: ; $(V)$(foo)
 
166
#
 
167
# (where V=@) can be seen by the user to be obviously different than this:
 
168
#
 
169
#       define foo
 
170
#       $(V)echo bar
 
171
#       endef
 
172
#
 
173
#       all: ; $(foo)
 
174
#
 
175
# and the user thinks it should behave the same as when the "@" is literal
 
176
# instead of in a variable, that can't happen because by the time make
 
177
# expands the variables for the command line and sees it begins with a "@" it
 
178
# can't know anymore whether the prefix character came before the variable
 
179
# reference or was included in the first line of the variable reference.
 
180
 
 
181
# TEST #5
 
182
# -------
 
183
 
 
184
run_make_test('
 
185
define FOO
 
186
$(V1)echo hello
 
187
$(V2)echo world
 
188
endef
 
189
all: ; @$(FOO)
 
190
', '', 'hello
 
191
world');
 
192
 
 
193
# TEST #6
 
194
# -------
 
195
 
 
196
run_make_test(undef, 'V1=@ V2=@', 'hello
 
197
world');
 
198
 
 
199
# TEST #7
 
200
# -------
 
201
 
 
202
run_make_test('
 
203
define FOO
 
204
$(V1)echo hello
 
205
$(V2)echo world
 
206
endef
 
207
all: ; $(FOO)
 
208
', 'V1=@', 'hello
 
209
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
210
echo world
 
211
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
212
world');
 
213
 
 
214
# TEST #8
 
215
# -------
 
216
 
 
217
run_make_test(undef, 'V2=@', '##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
218
echo hello
 
219
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
220
hello
 
221
world');
 
222
 
 
223
# TEST #9
 
224
# -------
 
225
 
 
226
run_make_test(undef, 'V1=@ V2=@', 'hello
 
227
world');
 
228
 
 
229
# TEST #10
 
230
# -------
 
231
# Test the basics; a "@" internally to the variable applies to only one line.
 
232
# A "@" before the variable applies to the entire variable.
 
233
 
 
234
run_make_test('
 
235
define FOO
 
236
@echo hello
 
237
echo world
 
238
endef
 
239
define BAR
 
240
echo hello
 
241
echo world
 
242
endef
 
243
 
 
244
all: foo bar
 
245
foo: ; $(FOO)
 
246
bar: ; @$(BAR)
 
247
', '', 'hello
 
248
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
249
echo world
 
250
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
251
world
 
252
hello
 
253
world
 
254
');
 
255
 
 
256
1;