質問編集履歴

1

makefileの内容を追記しました。

2019/03/20 06:43

投稿

wertyu
wertyu

スコア17

test CHANGED
File without changes
test CHANGED
@@ -24,6 +24,352 @@
24
24
 
25
25
 
26
26
 
27
+ ### Makefileの内容
28
+
29
+ ```
30
+
31
+ #
32
+
33
+ # Makefile for a workspace of Platform.
34
+
35
+ #
36
+
37
+
38
+
39
+ #
40
+
41
+ # Include configurations of SDK
42
+
43
+ #
44
+
45
+ SDKDIR = ..
46
+
47
+ WSPDIR = $(basename $(PWD))
48
+
49
+ include $(SDKDIR)/Makefile.sdk.conf
50
+
51
+
52
+
53
+ # Configuration
54
+
55
+ SRCLANG := c
56
+
57
+ KERNEL := hrp2
58
+
59
+
60
+
61
+ #
62
+
63
+ # Functions
64
+
65
+ #
66
+
67
+ get_relpath = $(shell perl -MFile::Spec -e "print File::Spec->abs2rel(q($1),q($2))")
68
+
69
+
70
+
71
+ #
72
+
73
+ # Paths
74
+
75
+ #
76
+
77
+ KERNELDIR := $(PWD)/$(SDKDIR)/$(EV3RT_BASE_DIR)
78
+
79
+ OBJDIR := $(PWD)/$(SDKDIR)/$(EV3RT_PRJ_OBJ_DIR)
80
+
81
+ LIBKERNELDIR := $(PWD)/$(SDKDIR)/$(EV3RT_LIBKERNEL_DIR)
82
+
83
+ TARGETDIR := $(PWD)/$(KERNELDIR)/target/ev3_gcc
84
+
85
+
86
+
87
+ # Object files
88
+
89
+ OBJFILENAME := $(KERNEL)
90
+
91
+ ifneq (, $(findstring CYGWIN, $(shell uname)))
92
+
93
+ OBJFILENAME := $(OBJFILENAME).exe
94
+
95
+ endif
96
+
97
+ OBJBINARY := $(OBJDIR)/$(KERNEL).bin
98
+
99
+
100
+
101
+ #
102
+
103
+ # Determine Makefile for application
104
+
105
+ # OUTPUT:
106
+
107
+ # $(APPLDIR): Absolute path of application folder
108
+
109
+ # $(MKFILENAME): File name of Makefile
110
+
111
+ # $(MKFILE_DIR): Absolute path of the folder holding Makefile
112
+
113
+ #
114
+
115
+ ifdef img
116
+
117
+ APPLDIR := $(PWD)/$(img)
118
+
119
+ MKFILENAME := Makefile.img
120
+
121
+ endif
122
+
123
+ ifdef app
124
+
125
+ APPLDIR := $(PWD)/$(app)
126
+
127
+ MKFILENAME := Makefile.app
128
+
129
+ endif
130
+
131
+ MKFILE_DIR := $(APPLDIR)
132
+
133
+ ifeq (,$(wildcard $(mkfile_dir)/$(MKFILENAME)))
134
+
135
+ MKFILE_DIR := $(SDKDIR)/common
136
+
137
+ endif
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+ # Target for an application (static)
146
+
147
+ #
148
+
149
+ ifdef img
150
+
151
+
152
+
153
+ include $(APPLDIR)/Makefile.inc
154
+
155
+
156
+
157
+ ifeq (,$(wildcard $(LIBKERNELDIR)/libkernel.a))
158
+
159
+ # Build libkernel.a if not exist
160
+
161
+ img: $(APPLDIR) $(LIBKERNELDIR)/libkernel.a prepare-obj-folder
162
+
163
+ else
164
+
165
+ img: $(APPLDIR) prepare-obj-folder
166
+
167
+ endif
168
+
169
+ @cd $(OBJDIR) && \
170
+
171
+ make offset.h kernel_cfg.h && \
172
+
173
+ make -j8 > /dev/null && \
174
+
175
+ arm-none-eabi-objcopy -O binary \
176
+
177
+ $(OBJFILENAME) $(call get_relpath,$(OBJBINARY),$(OBJDIR))
178
+
179
+ @mkimage -A arm -O linux -T kernel -C none -a 0xc0008000 -e 0xc0008000 \
180
+
181
+ -n "TOPPERS/$(KERNEL) Kernel (EV3)" \
182
+
183
+ -d $(call get_relpath,$(OBJBINARY),$(PWD)) uImage
184
+
185
+ @chmod +x uImage
186
+
187
+ @cp $(OBJDIR)/$(OBJFILENAME) $(PWD)
188
+
189
+
190
+
191
+ $(LIBKERNELDIR)/libkernel.a: prepare-obj-folder
192
+
193
+ @cd $(OBJDIR) && \
194
+
195
+ make clean && \
196
+
197
+ make libkernel.a > /dev/null && \
198
+
199
+ cp libkernel.a $(LIBKERNELDIR)/libkernel.a
200
+
201
+
202
+
203
+ endif
204
+
205
+
206
+
207
+ #
208
+
209
+ # Target for an application module (dynamic)
210
+
211
+ #
212
+
213
+ ifdef app
214
+
215
+
216
+
217
+ include $(APPLDIR)/Makefile.inc
218
+
219
+
220
+
221
+ app: $(APPLDIR) prepare-obj-folder
222
+
223
+ @cd $(OBJDIR) && \
224
+
225
+ make module_cfg.h && \
226
+
227
+ make -j8 && \
228
+
229
+ cp app $(PWD)/app # && cp app $(PWD)/app-$(subst /,,$(app))
230
+
231
+
232
+
233
+ endif
234
+
235
+
236
+
237
+ usage:
238
+
239
+ @echo make img="<folder>"
240
+
241
+ @echo make app="<folder>"
242
+
243
+ @echo "make upload [ip=<ev3_ip_address>] [from=<local_file_name>] [to=<remote_file_name>]"
244
+
245
+ @echo "make uploadimg [ip=<ev3_ip_address>] [from=<local_image_path>]"
246
+
247
+
248
+
249
+ # TODO: check file name carefully
250
+
251
+ ifndef ip # Default IP
252
+
253
+ ip := 10.0.10.1
254
+
255
+ endif
256
+
257
+ ifndef from # Default local application (or uImage) file name
258
+
259
+ from := app
260
+
261
+ uploadimg: from := uImage
262
+
263
+ endif
264
+
265
+ ifndef to
266
+
267
+ to := $(from)
268
+
269
+ endif
270
+
271
+ upload:
272
+
273
+ @echo = "Upload user application file"
274
+
275
+ @echo " BT PAN IP: $(ip)"
276
+
277
+ @echo " FILE NAME: (Local) \"$(from)\" -> (Remote) \"$(to)\""
278
+
279
+ @echo = "Execute cURL:"
280
+
281
+ @curl -f --noproxy "*" -H "Content-Type: ev3rt/app" -H 'Content-Disposition: inline; filename="$(to)"' --data-binary @$(from) http://$(ip)/upload > /dev/null
282
+
283
+ @echo = Application has been successfully uploaded.
284
+
285
+
286
+
287
+ uploadimg:
288
+
289
+ @echo = "Upload uImage file"
290
+
291
+ @echo " BT PAN IP: $(ip)"
292
+
293
+ @echo " FILE NAME: (Local) \"$(from)\" -> (Remote) \"/uImage\""
294
+
295
+ @echo = "Execute cURL:"
296
+
297
+ @curl -f --noproxy "*" -H "Content-Type: ev3rt/img" --data-binary @$(from) http://$(ip)/upload > /dev/null
298
+
299
+ @echo = uImage has been successfully uploaded.
300
+
301
+
302
+
303
+
304
+
305
+ clean:
306
+
307
+ rm -rf $(OBJDIR)
308
+
309
+
310
+
311
+ realclean: clean
312
+
313
+ rm -rf $(notdir $(OBJFILENAME)) uImage app $(LIBKERNELDIR)/libkernel.a
314
+
315
+
316
+
317
+ #
318
+
319
+ # Phony target for preparing $(OBJDIR) folder
320
+
321
+ #
322
+
323
+ temp_mkfilename := .ev3rt_temp_Makefile
324
+
325
+ ifdef app
326
+
327
+ configure_copts := -DBUILD_MODULE
328
+
329
+ endif
330
+
331
+ prepare-obj-folder: clean
332
+
333
+ @cp $(MKFILE_DIR)/$(MKFILENAME) $(APPLDIR)/$(temp_mkfilename)
334
+
335
+ @mkdir -p $(OBJDIR)
336
+
337
+ cd $(OBJDIR) && \
338
+
339
+ $(KERNELDIR)/configure -T ev3_gcc -A app \
340
+
341
+ -a $(call get_relpath,$(APPLDIR),$(OBJDIR)) \
342
+
343
+ -t $(call get_relpath,$(APPLDIR),$(OBJDIR)) \
344
+
345
+ -D $(call get_relpath,$(KERNELDIR),$(OBJDIR)) \
346
+
347
+ -L $(call get_relpath,$(LIBKERNELDIR),$(OBJDIR)) \
348
+
349
+ -l $(SRCLANG) \
350
+
351
+ -m $(temp_mkfilename) -o "$(configure_copts)" \
352
+
353
+ -U "$(APPLOBJS)" && \
354
+
355
+ rm $(APPLDIR)/$(temp_mkfilename) && \
356
+
357
+ mv $(temp_mkfilename) Makefile && \
358
+
359
+ make clean
360
+
361
+
362
+
363
+
364
+
365
+ .PHONY: clean realclean prepare-obj-folder img app
366
+
367
+
368
+
369
+
370
+
371
+ ```
372
+
27
373
 
28
374
 
29
375
  ### 試したこと