export # export all variable to sub-Makefile CC = mipsel-unknown-elf-gcc AS = mipsel-unknown-elf-as LD = mipsel-unknown-elf-ld DU = mipsel-unknown-elf-objdump ### FAT parameters definition for Disk image ### sector_size = 512 ### partition_begin_lba = 300 ### sector_per_cluster = 8 ### partition sectors = 524832 MAP_XML = mappings/4c_1p_iob_four.xml ### Objects to be linked for kernel.elf KERNEL_OBJS = build/common/utils.o \ build/common/vmem.o \ build/fat32/fat32.o \ build/drivers/dma_driver.o \ build/drivers/fbf_driver.o \ build/drivers/xcu_driver.o \ build/drivers/icu_driver.o \ build/drivers/ioc_driver.o \ build/drivers/iob_driver.o \ build/drivers/mmc_driver.o \ build/drivers/mwr_driver.o \ build/drivers/nic_driver.o \ build/drivers/tim_driver.o \ build/drivers/tty_driver.o \ build/kernel/giet.o \ build/kernel/switch.o \ build/kernel/ctx_handler.o \ build/kernel/exc_handler.o \ build/kernel/sys_handler.o \ build/kernel/irq_handler.o \ build/kernel/kernel_init.o ### Objects to be linked for boot.elf BOOT_OBJS = build/common/utils.o \ build/common/vmem.o \ build/fat32/fat32.o \ build/drivers/tty_driver.o \ build/drivers/xcu_driver.o \ build/drivers/dma_driver.o \ build/drivers/mwr_driver.o \ build/drivers/ioc_driver.o \ build/drivers/nic_driver.o \ build/drivers/mmc_driver.o \ build/kernel/ctx_handler.o \ build/kernel/switch.o \ build/boot/boot.o ### Objects to be linked for display.elf DISPLAY_OBJS = build/display/main.o \ build/libs/stdio.o ### Objects to be linked for router.elf ROUTER_OBJS = build/router/main.o \ build/libs/mwmr_channel.o \ build/libs/stdio.o ### Objects to be linked for hello.elf HELLO_OBJS = build/hello/main.o \ build/libs/stdio.o ### Objects to be linked for pgcd.elf PGCD_OBJS = build/pgcd/main.o \ build/libs/stdio.o ### Objects to be linked for game.elf GAMEOFLIFE_OBJS = build/gameoflife/main.o \ build/libs/stdio.o \ build/libs/barrier.o ### Objects to be linked for dhrystone.elf DHRYSTONE_OBJS = build/dhrystone/dhry_1.o \ build/dhrystone/dhry_2.o \ build/libs/stdio.o \ build/libs/string.o \ build/libs/spin_lock.o \ build/libs/malloc.o ### Objects to be linked for sort.elf SORT_OBJS = build/sort/main.o \ build/libs/stdio.o \ build/libs/spin_lock.o \ build/libs/barrier.o CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 GIET_INCLUDE = -Igiet_boot \ -Igiet_kernel \ -Igiet_xml \ -Igiet_fat32 \ -Igiet_drivers \ -Igiet_common \ -Igiet_libs \ -I. USER_INCLUDE = -Igiet_libs \ -Igiet_xml \ -I. all: map.bin \ build/boot/boot.elf \ build/kernel/kernel.elf \ build/display/display.elf \ build/router/router.elf \ build/hello/hello.elf \ build/pgcd/pgcd.elf \ build/dhrystone/dhrystone.elf \ build/gameoflife/gameoflife.elf \ build/sort/sort.elf \ hdd/virt_hdd.dmg ### Disk image generation ### This requires the generic LINUX/MacOS sript "create_dmg" script ### written by C.Fuguet. (should be installed in GIET-VM root directory). hdd/virt_hdd.dmg: map.bin \ build/boot/boot.elf \ build/kernel/kernel.elf \ build/display/display.elf \ build/hello/hello.elf \ build/pgcd/pgcd.elf \ build/router/router.elf \ build/dhrystone/dhrystone.elf \ build/gameoflife/gameoflife.elf ### remove all content of virtual disk virt_hdd rm -rf hdd/virt_hdd/* ### copy content to virtual disk from build, misc and map.bin ### the boot.elf file is not copied on the virtual disk cp -r build hdd/virt_hdd rm -rf hdd/virt_hdd/build/boot cp -r hdd/misc hdd/virt_hdd cp map.bin hdd/virt_hdd ### create temporary partition image (partition_image.dmg) ./create_dmg create hdd/virt_hdd partition_image ### copy standard MBR into virtual disk image (mbr.dmg) cp hdd/mbr.dmg $@ ### copy boot.elf into virtual disk image (sector 2) dd if=build/boot/boot.elf of=$@ seek=2 ### copy partition image into virtual disk image (sector 300) dd if=partition_image.dmg of=$@ seek=300 ### remove partition image rm partition_image.dmg ### mapping compilation map.bin: $(MAP_XML) $(MAKE) -C giet_xml giet_xml/xml2bin $< . ### drivers compilation build/drivers/dma_driver.o: giet_drivers/dma_driver.c \ giet_drivers/dma_driver.h \ giet_config.h \ $(MAP_XML) $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/fbf_driver.o: giet_drivers/fbf_driver.c \ giet_drivers/fbf_driver.h \ giet_config.h \ $(MAP_XML) $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/xcu_driver.o: giet_drivers/xcu_driver.c \ giet_drivers/xcu_driver.h \ giet_config.h \ $(MAP_XML) $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/icu_driver.o: giet_drivers/icu_driver.c \ giet_drivers/icu_driver.h \ giet_config.h \ $(MAP_XML) $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/ioc_driver.o: giet_drivers/ioc_driver.c \ giet_drivers/ioc_driver.h \ giet_config.h \ $(MAP_XML) $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/iob_driver.o: giet_drivers/iob_driver.c \ giet_drivers/iob_driver.h \ giet_config.h \ $(MAP_XML) $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/mmc_driver.o: giet_drivers/mmc_driver.c \ giet_drivers/mmc_driver.h \ giet_config.h \ $(MAP_XML) $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/mwr_driver.o: giet_drivers/mwr_driver.c \ giet_drivers/mwr_driver.h \ giet_config.h \ $(MAP_XML) $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/nic_driver.o: giet_drivers/nic_driver.c \ giet_drivers/nic_driver.h \ giet_config.h \ $(MAP_XML) $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/tim_driver.o: giet_drivers/tim_driver.c \ giet_drivers/tim_driver.h \ giet_config.h \ $(MAP_XML) $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/tty_driver.o: giet_drivers/tty_driver.c \ giet_drivers/tty_driver.h \ giet_config.h \ $(MAP_XML) $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< ### fat32 compilation build/fat32/fat32.o: giet_fat32/fat32.c \ giet_fat32/fat32.h \ giet_config.h \ $(MAP_XML) $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< ### utils compilation build/common/utils.o: giet_common/utils.c \ giet_common/utils.h \ giet_config.h \ $(MAP_XML) $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< ### vmem compilation build/common/vmem.o: giet_common/vmem.c \ giet_common/vmem.h \ giet_config.h \ $(MAP_XML) $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< ### boot compilation build/boot/boot.elf: $(BOOT_OBJS) $(LD) -o $@ -T giet_boot/boot.ld $(BOOT_OBJS) $(DU) -D $@ > $@.txt build/boot/boot.o: giet_boot/boot.c \ giet_common/utils.h \ giet_fat32/fat32.h \ giet_common/vmem.h \ giet_drivers/tty_driver.h \ giet_drivers/ioc_driver.h \ giet_config.h \ $(MAP_XML) $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< ### kernel compilation build/kernel/kernel.elf: $(KERNEL_OBJS) giet_kernel/kernel.ld $(LD) -o $@ -T giet_kernel/kernel.ld $(KERNEL_OBJS) $(DU) -D $@ > $@.txt build/kernel/%.o: giet_kernel/%.c giet_config.h $(MAP_XML) $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/kernel/%.o: giet_kernel/%.s giet_config.h $(MAP_XML) $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< ### libs compilation build/libs/stdio.o: giet_libs/stdio.c \ giet_libs/stdio.h \ giet_config.h $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< build/libs/mwmr_channel.o: giet_libs/mwmr_channel.c \ giet_libs/mwmr_channel.h \ giet_config.h $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< build/libs/malloc.o: giet_libs/malloc.c \ giet_libs/malloc.h \ giet_libs/malloc_private.h \ giet_config.h $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< build/libs/barrier.o: giet_libs/barrier.c \ giet_libs/barrier.h \ giet_config.h $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< build/libs/string.o: giet_libs/string.c \ giet_libs/string.h \ giet_config.h $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< build/libs/spin_lock.o: giet_libs/spin_lock.c \ giet_libs/spin_lock.h \ giet_config.h $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< ### display compilation build/display/display.elf: $(DISPLAY_OBJS) display/display.ld $(LD) -o $@ -T display/display.ld $(DISPLAY_OBJS) $(DU) -D $@ > $@.txt build/display/main.o: display/main_cma.c $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< ### router compilation build/router/router.elf: $(ROUTER_OBJS) router/router.ld $(LD) -o $@ -T router/router.ld $(ROUTER_OBJS) $(DU) -D $@ > $@.txt build/router/main.o: router/main.c $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< ### hello compilation build/hello/hello.elf: $(HELLO_OBJS) hello/hello.ld $(LD) -o $@ -T hello/hello.ld $(HELLO_OBJS) $(DU) -D $@ > $@.txt build/hello/main.o: hello/main.c $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< ### pgcd compilation build/pgcd/pgcd.elf: $(PGCD_OBJS) pgcd/pgcd.ld $(LD) -o $@ -T pgcd/pgcd.ld $(PGCD_OBJS) $(DU) -D $@ > $@.txt build/pgcd/main.o: pgcd/main.c $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< ### gameoflife compilation build/gameoflife/gameoflife.elf: $(GAMEOFLIFE_OBJS) gameoflife/gameoflife.ld $(LD) -o $@ -T gameoflife/gameoflife.ld $(GAMEOFLIFE_OBJS) $(DU) -D $@ > $@.txt build/gameoflife/main.o: gameoflife/main.c $(CC) $(USER_INCLUDE) $(CFLAGS) -O3 -c -o $@ $< ### dhrystone compilation build/dhrystone/dhrystone.elf: $(DHRYSTONE_OBJS) dhrystone/dhrystone.ld $(LD) -o $@ -T dhrystone/dhrystone.ld $(DHRYSTONE_OBJS) $(DU) -D $@ > $@.txt build/dhrystone/dhry_1.o: dhrystone/dhry_1.c $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< build/dhrystone/dhry_2.o: dhrystone/dhry_2.c $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< ### sort compilation build/sort/sort.elf: $(SORT_OBJS) sort/sort.ld $(LD) -o $@ -T sort/sort.ld $(SORT_OBJS) $(DU) -D $@ > $@.txt build/sort/main.o: sort/main.c $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< ### clean clean: rm -f *.o *.elf *.bin *.txt core giet_vsegs.ld hard_config.h map.bin*~ $(MAKE) -s clean -C giet_xml rm -rf build/boot/* rm -rf build/fat32/* rm -rf build/common/* rm -rf build/drivers/* rm -rf build/kernel/* rm -rf build/reset/* rm -rf build/libs/* rm -rf build/pgcd/* rm -rf build/hello/* rm -rf build/display/* rm -rf build/router/* rm -rf build/gameoflife/* rm -rf build/dhrystone/* rm -rf build/sort/* rm -rf build/map.bin rm -rf hdd/virt_hdd.dmg