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