1 | export # export all variable to sub-Makefile |
---|
2 | CC = mipsel-unknown-elf-gcc |
---|
3 | AS = mipsel-unknown-elf-as |
---|
4 | LD = mipsel-unknown-elf-ld |
---|
5 | DU = mipsel-unknown-elf-objdump |
---|
6 | |
---|
7 | ### FAT parameters definition for Disk image |
---|
8 | ### sector_size = 512 |
---|
9 | ### partition_begin_lba = 300 |
---|
10 | ### sector_per_cluster = 8 |
---|
11 | ### partition sectors = 524832 |
---|
12 | |
---|
13 | MAP_XML = mappings/4c_1p_four.xml |
---|
14 | |
---|
15 | ### Objects to be linked for kernel.elf |
---|
16 | KERNEL_OBJS = build/common/utils.o \ |
---|
17 | build/common/vmem.o \ |
---|
18 | build/fat32/fat32.o \ |
---|
19 | build/drivers/dma_driver.o \ |
---|
20 | build/drivers/fbf_driver.o \ |
---|
21 | build/drivers/xcu_driver.o \ |
---|
22 | build/drivers/icu_driver.o \ |
---|
23 | build/drivers/ioc_driver.o \ |
---|
24 | build/drivers/bdv_driver.o \ |
---|
25 | build/drivers/hba_driver.o \ |
---|
26 | build/drivers/sdc_driver.o \ |
---|
27 | build/drivers/spi_driver.o \ |
---|
28 | build/drivers/iob_driver.o \ |
---|
29 | build/drivers/mmc_driver.o \ |
---|
30 | build/drivers/mwr_driver.o \ |
---|
31 | build/drivers/nic_driver.o \ |
---|
32 | build/drivers/tim_driver.o \ |
---|
33 | build/drivers/tty_driver.o \ |
---|
34 | build/kernel/giet.o \ |
---|
35 | build/kernel/switch.o \ |
---|
36 | build/kernel/ctx_handler.o \ |
---|
37 | build/kernel/exc_handler.o \ |
---|
38 | build/kernel/sys_handler.o \ |
---|
39 | build/kernel/irq_handler.o \ |
---|
40 | build/kernel/kernel_init.o |
---|
41 | |
---|
42 | ### Objects to be linked for boot.elf |
---|
43 | BOOT_OBJS = build/common/utils.o \ |
---|
44 | build/common/vmem.o \ |
---|
45 | build/fat32/fat32.o \ |
---|
46 | build/drivers/tty_driver.o \ |
---|
47 | build/drivers/xcu_driver.o \ |
---|
48 | build/drivers/dma_driver.o \ |
---|
49 | build/drivers/mwr_driver.o \ |
---|
50 | build/drivers/ioc_driver.o \ |
---|
51 | build/drivers/bdv_driver.o \ |
---|
52 | build/drivers/hba_driver.o \ |
---|
53 | build/drivers/sdc_driver.o \ |
---|
54 | build/drivers/spi_driver.o \ |
---|
55 | build/drivers/nic_driver.o \ |
---|
56 | build/drivers/mmc_driver.o \ |
---|
57 | build/kernel/ctx_handler.o \ |
---|
58 | build/kernel/switch.o \ |
---|
59 | build/boot/boot.o |
---|
60 | |
---|
61 | ### Objects to be linked for display.elf |
---|
62 | DISPLAY_OBJS = build/display/main.o \ |
---|
63 | build/libs/stdio.o |
---|
64 | |
---|
65 | ### Objects to be linked for router.elf |
---|
66 | ROUTER_OBJS = build/router/main.o \ |
---|
67 | build/libs/mwmr_channel.o \ |
---|
68 | build/libs/stdio.o |
---|
69 | |
---|
70 | ### Objects to be linked for hello.elf |
---|
71 | HELLO_OBJS = build/hello/main.o \ |
---|
72 | build/libs/stdio.o |
---|
73 | |
---|
74 | ### Objects to be linked for pgcd.elf |
---|
75 | PGCD_OBJS = build/pgcd/main.o \ |
---|
76 | build/libs/stdio.o |
---|
77 | |
---|
78 | ### Objects to be linked for game.elf |
---|
79 | GAMEOFLIFE_OBJS = build/gameoflife/main.o \ |
---|
80 | build/libs/stdio.o \ |
---|
81 | build/libs/barrier.o |
---|
82 | |
---|
83 | ### Objects to be linked for dhrystone.elf |
---|
84 | DHRYSTONE_OBJS = build/dhrystone/dhry_1.o \ |
---|
85 | build/dhrystone/dhry_2.o \ |
---|
86 | build/libs/stdlib.o \ |
---|
87 | build/libs/stdio.o \ |
---|
88 | build/libs/string.o \ |
---|
89 | build/libs/spin_lock.o \ |
---|
90 | build/libs/malloc.o |
---|
91 | |
---|
92 | ### Objects to be linked for sort.elf |
---|
93 | SORT_OBJS = build/sort/main.o \ |
---|
94 | build/libs/stdio.o \ |
---|
95 | build/libs/spin_lock.o \ |
---|
96 | build/libs/barrier.o |
---|
97 | |
---|
98 | |
---|
99 | CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32# -O3 -fno-inline |
---|
100 | |
---|
101 | |
---|
102 | GIET_INCLUDE = -Igiet_boot \ |
---|
103 | -Igiet_kernel \ |
---|
104 | -Igiet_xml \ |
---|
105 | -Igiet_fat32 \ |
---|
106 | -Igiet_drivers \ |
---|
107 | -Igiet_common \ |
---|
108 | -Igiet_libs \ |
---|
109 | -I. |
---|
110 | |
---|
111 | USER_INCLUDE = -Igiet_libs \ |
---|
112 | -Igiet_xml \ |
---|
113 | -I. |
---|
114 | |
---|
115 | all: map.bin \ |
---|
116 | build/boot/boot.elf \ |
---|
117 | build/kernel/kernel.elf \ |
---|
118 | build/display/display.elf \ |
---|
119 | build/router/router.elf \ |
---|
120 | build/hello/hello.elf \ |
---|
121 | build/pgcd/pgcd.elf \ |
---|
122 | build/dhrystone/dhrystone.elf \ |
---|
123 | build/gameoflife/gameoflife.elf \ |
---|
124 | build/sort/sort.elf \ |
---|
125 | hdd/virt_hdd.dmg |
---|
126 | |
---|
127 | ### Disk image generation |
---|
128 | ### This requires the generic LINUX/MacOS script "create_dmg" script |
---|
129 | ### written by C.Fuguet. (should be installed in GIET-VM root directory). |
---|
130 | hdd/virt_hdd.dmg: map.bin \ |
---|
131 | build/boot/boot.elf \ |
---|
132 | build/kernel/kernel.elf \ |
---|
133 | build/display/display.elf \ |
---|
134 | build/hello/hello.elf \ |
---|
135 | build/pgcd/pgcd.elf \ |
---|
136 | build/router/router.elf \ |
---|
137 | build/dhrystone/dhrystone.elf \ |
---|
138 | build/gameoflife/gameoflife.elf |
---|
139 | ### remove all content of virtual disk virt_hdd |
---|
140 | rm -rf hdd/virt_hdd/* |
---|
141 | ### copy content to virtual disk from build, misc and map.bin |
---|
142 | ### the boot.elf file is not copied on the virtual disk |
---|
143 | cp -r build hdd/virt_hdd |
---|
144 | rm -rf hdd/virt_hdd/build/boot |
---|
145 | cp -r hdd/misc hdd/virt_hdd |
---|
146 | cp map.bin hdd/virt_hdd |
---|
147 | ### create temporary partition image (partition_image.dmg) |
---|
148 | ./create_dmg create hdd/virt_hdd partition_image |
---|
149 | ### copy standard MBR into virtual disk image (mbr.dmg) |
---|
150 | cp hdd/mbr.dmg $@ |
---|
151 | ### copy boot.elf into virtual disk image (sector 2) |
---|
152 | dd if=build/boot/boot.elf of=$@ seek=2 |
---|
153 | ### copy partition image into virtual disk image (sector 300) |
---|
154 | dd if=partition_image.dmg of=$@ seek=300 |
---|
155 | ### remove partition image |
---|
156 | rm partition_image.dmg |
---|
157 | |
---|
158 | ### mapping compilation |
---|
159 | map.bin: $(MAP_XML) |
---|
160 | $(MAKE) -C giet_xml |
---|
161 | giet_xml/xml2bin $< . |
---|
162 | |
---|
163 | ### drivers compilation |
---|
164 | build/drivers/dma_driver.o: giet_drivers/dma_driver.c \ |
---|
165 | giet_drivers/dma_driver.h \ |
---|
166 | giet_config.h \ |
---|
167 | $(MAP_XML) |
---|
168 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
169 | |
---|
170 | build/drivers/fbf_driver.o: giet_drivers/fbf_driver.c \ |
---|
171 | giet_drivers/fbf_driver.h \ |
---|
172 | giet_config.h \ |
---|
173 | $(MAP_XML) |
---|
174 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
175 | |
---|
176 | build/drivers/xcu_driver.o: giet_drivers/xcu_driver.c \ |
---|
177 | giet_drivers/xcu_driver.h \ |
---|
178 | giet_config.h \ |
---|
179 | $(MAP_XML) |
---|
180 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
181 | |
---|
182 | build/drivers/icu_driver.o: giet_drivers/icu_driver.c \ |
---|
183 | giet_drivers/icu_driver.h \ |
---|
184 | giet_config.h \ |
---|
185 | $(MAP_XML) |
---|
186 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
187 | |
---|
188 | build/drivers/ioc_driver.o: giet_drivers/ioc_driver.c \ |
---|
189 | giet_drivers/ioc_driver.h \ |
---|
190 | giet_config.h \ |
---|
191 | $(MAP_XML) |
---|
192 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
193 | |
---|
194 | build/drivers/bdv_driver.o: giet_drivers/bdv_driver.c \ |
---|
195 | giet_drivers/bdv_driver.h \ |
---|
196 | giet_config.h \ |
---|
197 | $(MAP_XML) |
---|
198 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
199 | |
---|
200 | build/drivers/hba_driver.o: giet_drivers/hba_driver.c \ |
---|
201 | giet_drivers/hba_driver.h \ |
---|
202 | giet_config.h \ |
---|
203 | $(MAP_XML) |
---|
204 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
205 | |
---|
206 | build/drivers/sdc_driver.o: giet_drivers/sdc_driver.c \ |
---|
207 | giet_drivers/sdc_driver.h \ |
---|
208 | giet_config.h \ |
---|
209 | $(MAP_XML) |
---|
210 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
211 | |
---|
212 | build/drivers/spi_driver.o: giet_drivers/spi_driver.c \ |
---|
213 | giet_drivers/spi_driver.h \ |
---|
214 | giet_config.h \ |
---|
215 | $(MAP_XML) |
---|
216 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
217 | |
---|
218 | build/drivers/iob_driver.o: giet_drivers/iob_driver.c \ |
---|
219 | giet_drivers/iob_driver.h \ |
---|
220 | giet_config.h \ |
---|
221 | $(MAP_XML) |
---|
222 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
223 | |
---|
224 | build/drivers/mmc_driver.o: giet_drivers/mmc_driver.c \ |
---|
225 | giet_drivers/mmc_driver.h \ |
---|
226 | giet_config.h \ |
---|
227 | $(MAP_XML) |
---|
228 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
229 | |
---|
230 | build/drivers/mwr_driver.o: giet_drivers/mwr_driver.c \ |
---|
231 | giet_drivers/mwr_driver.h \ |
---|
232 | giet_config.h \ |
---|
233 | $(MAP_XML) |
---|
234 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
235 | |
---|
236 | build/drivers/nic_driver.o: giet_drivers/nic_driver.c \ |
---|
237 | giet_drivers/nic_driver.h \ |
---|
238 | giet_config.h \ |
---|
239 | $(MAP_XML) |
---|
240 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
241 | |
---|
242 | build/drivers/tim_driver.o: giet_drivers/tim_driver.c \ |
---|
243 | giet_drivers/tim_driver.h \ |
---|
244 | giet_config.h \ |
---|
245 | $(MAP_XML) |
---|
246 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
247 | |
---|
248 | build/drivers/tty_driver.o: giet_drivers/tty_driver.c \ |
---|
249 | giet_drivers/tty_driver.h \ |
---|
250 | giet_config.h \ |
---|
251 | $(MAP_XML) |
---|
252 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
253 | |
---|
254 | ### fat32 compilation |
---|
255 | build/fat32/fat32.o: giet_fat32/fat32.c \ |
---|
256 | giet_fat32/fat32.h \ |
---|
257 | giet_config.h \ |
---|
258 | $(MAP_XML) |
---|
259 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
260 | |
---|
261 | ### utils compilation |
---|
262 | build/common/utils.o: giet_common/utils.c \ |
---|
263 | giet_common/utils.h \ |
---|
264 | giet_config.h \ |
---|
265 | $(MAP_XML) |
---|
266 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
267 | |
---|
268 | ### vmem compilation |
---|
269 | build/common/vmem.o: giet_common/vmem.c \ |
---|
270 | giet_common/vmem.h \ |
---|
271 | giet_config.h \ |
---|
272 | $(MAP_XML) |
---|
273 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
274 | |
---|
275 | ### boot compilation |
---|
276 | build/boot/boot.elf: $(BOOT_OBJS) |
---|
277 | $(LD) -o $@ -T giet_boot/boot.ld $(BOOT_OBJS) |
---|
278 | $(DU) -D $@ > $@.txt |
---|
279 | |
---|
280 | build/boot/boot.o: giet_boot/boot.c \ |
---|
281 | giet_common/utils.h \ |
---|
282 | giet_fat32/fat32.h \ |
---|
283 | giet_common/vmem.h \ |
---|
284 | giet_drivers/tty_driver.h \ |
---|
285 | giet_drivers/ioc_driver.h \ |
---|
286 | giet_config.h \ |
---|
287 | $(MAP_XML) |
---|
288 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
289 | |
---|
290 | ### kernel compilation |
---|
291 | build/kernel/kernel.elf: $(KERNEL_OBJS) giet_kernel/kernel.ld |
---|
292 | $(LD) -o $@ -T giet_kernel/kernel.ld $(KERNEL_OBJS) |
---|
293 | $(DU) -D $@ > $@.txt |
---|
294 | |
---|
295 | build/kernel/%.o: giet_kernel/%.c giet_config.h $(MAP_XML) |
---|
296 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
297 | |
---|
298 | build/kernel/%.o: giet_kernel/%.s giet_config.h $(MAP_XML) |
---|
299 | $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
300 | |
---|
301 | |
---|
302 | |
---|
303 | |
---|
304 | ### libs compilation |
---|
305 | build/libs/stdio.o: giet_libs/stdio.c \ |
---|
306 | giet_libs/stdio.h \ |
---|
307 | giet_config.h |
---|
308 | $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< |
---|
309 | |
---|
310 | build/libs/mwmr_channel.o: giet_libs/mwmr_channel.c \ |
---|
311 | giet_libs/mwmr_channel.h \ |
---|
312 | giet_config.h |
---|
313 | $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< |
---|
314 | |
---|
315 | build/libs/malloc.o: giet_libs/malloc.c \ |
---|
316 | giet_libs/malloc.h \ |
---|
317 | giet_libs/malloc_private.h \ |
---|
318 | giet_config.h |
---|
319 | $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< |
---|
320 | |
---|
321 | build/libs/barrier.o: giet_libs/barrier.c \ |
---|
322 | giet_libs/barrier.h \ |
---|
323 | giet_config.h |
---|
324 | $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< |
---|
325 | |
---|
326 | build/libs/stdlib.o: giet_libs/stdlib.c \ |
---|
327 | giet_libs/stdlib.h \ |
---|
328 | giet_config.h |
---|
329 | $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< |
---|
330 | |
---|
331 | build/libs/string.o: giet_libs/string.c \ |
---|
332 | giet_libs/string.h \ |
---|
333 | giet_config.h |
---|
334 | $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< |
---|
335 | |
---|
336 | build/libs/spin_lock.o: giet_libs/spin_lock.c \ |
---|
337 | giet_libs/spin_lock.h \ |
---|
338 | giet_config.h |
---|
339 | $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< |
---|
340 | |
---|
341 | |
---|
342 | |
---|
343 | |
---|
344 | ### display compilation |
---|
345 | build/display/display.elf: $(DISPLAY_OBJS) display/display.ld |
---|
346 | $(LD) -o $@ -T display/display.ld $(DISPLAY_OBJS) |
---|
347 | $(DU) -D $@ > $@.txt |
---|
348 | |
---|
349 | build/display/main.o: display/main_cma.c |
---|
350 | $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
351 | |
---|
352 | ### router compilation |
---|
353 | build/router/router.elf: $(ROUTER_OBJS) router/router.ld |
---|
354 | $(LD) -o $@ -T router/router.ld $(ROUTER_OBJS) |
---|
355 | $(DU) -D $@ > $@.txt |
---|
356 | |
---|
357 | build/router/main.o: router/main.c |
---|
358 | $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
359 | |
---|
360 | ### hello compilation |
---|
361 | build/hello/hello.elf: $(HELLO_OBJS) hello/hello.ld |
---|
362 | $(LD) -o $@ -T hello/hello.ld $(HELLO_OBJS) |
---|
363 | $(DU) -D $@ > $@.txt |
---|
364 | |
---|
365 | build/hello/main.o: hello/main.c |
---|
366 | $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
367 | |
---|
368 | ### pgcd compilation |
---|
369 | build/pgcd/pgcd.elf: $(PGCD_OBJS) pgcd/pgcd.ld |
---|
370 | $(LD) -o $@ -T pgcd/pgcd.ld $(PGCD_OBJS) |
---|
371 | $(DU) -D $@ > $@.txt |
---|
372 | |
---|
373 | build/pgcd/main.o: pgcd/main.c |
---|
374 | $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
375 | |
---|
376 | ### gameoflife compilation |
---|
377 | build/gameoflife/gameoflife.elf: $(GAMEOFLIFE_OBJS) gameoflife/gameoflife.ld |
---|
378 | $(LD) -o $@ -T gameoflife/gameoflife.ld $(GAMEOFLIFE_OBJS) |
---|
379 | $(DU) -D $@ > $@.txt |
---|
380 | |
---|
381 | build/gameoflife/main.o: gameoflife/main.c |
---|
382 | $(CC) $(USER_INCLUDE) $(CFLAGS) -O3 -c -o $@ $< |
---|
383 | |
---|
384 | ### dhrystone compilation |
---|
385 | build/dhrystone/dhrystone.elf: $(DHRYSTONE_OBJS) dhrystone/dhrystone.ld |
---|
386 | $(LD) -o $@ -T dhrystone/dhrystone.ld $(DHRYSTONE_OBJS) |
---|
387 | $(DU) -D $@ > $@.txt |
---|
388 | |
---|
389 | build/dhrystone/dhry_1.o: dhrystone/dhry_1.c |
---|
390 | $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
391 | |
---|
392 | build/dhrystone/dhry_2.o: dhrystone/dhry_2.c |
---|
393 | $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
394 | |
---|
395 | ### sort compilation |
---|
396 | build/sort/sort.elf: $(SORT_OBJS) sort/sort.ld |
---|
397 | $(LD) -o $@ -T sort/sort.ld $(SORT_OBJS) |
---|
398 | $(DU) -D $@ > $@.txt |
---|
399 | |
---|
400 | build/sort/main.o: sort/main.c |
---|
401 | $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
402 | |
---|
403 | ### clean |
---|
404 | clean: |
---|
405 | rm -f *.o *.elf *.bin *.txt core giet_vsegs.ld hard_config.h map.bin*~ |
---|
406 | $(MAKE) -s clean -C giet_xml |
---|
407 | rm -rf build/boot/* |
---|
408 | rm -rf build/fat32/* |
---|
409 | rm -rf build/common/* |
---|
410 | rm -rf build/drivers/* |
---|
411 | rm -rf build/kernel/* |
---|
412 | rm -rf build/reset/* |
---|
413 | rm -rf build/libs/* |
---|
414 | rm -rf build/pgcd/* |
---|
415 | rm -rf build/hello/* |
---|
416 | rm -rf build/display/* |
---|
417 | rm -rf build/router/* |
---|
418 | rm -rf build/gameoflife/* |
---|
419 | rm -rf build/dhrystone/* |
---|
420 | rm -rf build/sort/* |
---|
421 | rm -rf build/map.bin |
---|
422 | rm -rf hdd/virt_hdd/* |
---|
423 | rm -rf hdd/virt_hdd.dmg |
---|