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