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