-include build.mk 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 AR = mipsel-unknown-elf-ar # Parameters definition ARCH ?= ../tsar-trunk-svn-2013/platforms/tsar_generic_iob X_SIZE ?= 8 Y_SIZE ?= 8 NB_PROCS ?= 2 NB_TTYS ?= 1 FBF_WIDTH ?= 128 APP ?= classif .PHONY: map.bin ### FAT parameters definition for Disk image ### sector_size = 512 ### partition_begin_lba = 300 ### sector_per_cluster = 8 ### partition sectors = 524832 ### Objects to be linked for the drivers library DRIVERS_OBJS = build/drivers/dma_driver.o \ build/drivers/cma_driver.o \ build/drivers/xcu_driver.o \ build/drivers/ioc_driver.o \ build/drivers/bdv_driver.o \ build/drivers/hba_driver.o \ build/drivers/sdc_driver.o \ build/drivers/spi_driver.o \ build/drivers/rdk_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/drivers/pic_driver.o ### Objects to be linked for kernel.elf KERNEL_OBJS = build/common/utils.o \ build/common/locks.o \ build/common/tty0.o \ build/common/vmem.o \ build/common/kernel_malloc.o \ build/fat32/fat32.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/locks.o \ build/common/tty0.o \ build/common/pmem.o \ build/common/vmem.o \ build/common/kernel_malloc.o \ build/fat32/fat32.o \ build/kernel/ctx_handler.o \ build/kernel/switch.o \ build/boot/boot.o \ build/boot/boot_entry.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/user_lock.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 \ build/libs/malloc.o \ build/libs/user_lock.o ### Objects to be linked for dhrystone.elf DHRYSTONE_OBJS = build/dhrystone/dhry_1.o \ build/dhrystone/dhry_2.o \ build/libs/stdlib.o \ build/libs/stdio.o \ build/libs/string.o \ build/libs/user_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/barrier.o \ build/libs/malloc.o \ build/libs/user_lock.o ### Objects to be linked for transpose.elf TRANSPOSE_OBJS = build/transpose/main.o \ build/libs/stdio.o \ build/libs/barrier.o \ build/libs/malloc.o \ build/libs/user_lock.o ### Objects to be linked for convol.elf CONVOL_OBJS = build/convol/main.o \ build/libs/stdio.o \ build/libs/stdlib.o \ build/libs/barrier.o \ build/libs/malloc.o \ build/libs/user_lock.o ### Objects to be linked for classif.elf CLASSIF_OBJS = build/classif/main.o \ build/libs/stdio.o \ build/libs/mwmr_channel.o \ build/libs/barrier.o \ build/libs/malloc.o \ build/libs/user_lock.o CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 -g -O2 \ -fno-delete-null-pointer-checks GIET_INCLUDE = -Igiet_boot \ -Igiet_kernel \ -Igiet_xml \ -Igiet_fat32 \ -Igiet_drivers \ -Igiet_common \ -Igiet_libs \ -I. USER_INCLUDE = -Igiet_libs \ -Igiet_xml \ -I. DISK_IMAGE := hdd/virt_hdd.dmg all: map.bin \ hard_config.h \ giet_vsegs.ld \ 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 \ build/sort/sort.elf \ build/transpose/transpose.elf \ build/convol/convol.elf \ build/router/router.elf \ build/classif/classif.elf \ $(DISK_IMAGE) ### Copy always all files into disk image mcopy -o -i $(DISK_IMAGE) build/kernel/kernel.elf ::/build/kernel mcopy -o -i $(DISK_IMAGE) build/display/display.elf ::/build/display mcopy -o -i $(DISK_IMAGE) build/sort/sort.elf ::/build/sort mcopy -o -i $(DISK_IMAGE) build/transpose/transpose.elf ::/build/transpose mcopy -o -i $(DISK_IMAGE) build/convol/convol.elf ::/build/convol mcopy -o -i $(DISK_IMAGE) build/classif/classif.elf ::/build/classif mcopy -o -i $(DISK_IMAGE) build/hello/hello.elf ::/build/hello mcopy -o -i $(DISK_IMAGE) build/pgcd/pgcd.elf ::/build/pgcd mcopy -o -i $(DISK_IMAGE) build/router/router.elf ::/build/router mcopy -o -i $(DISK_IMAGE) build/gameoflife/gameoflife.elf ::/build/gameoflife mcopy -o -i $(DISK_IMAGE) build/dhrystone/dhrystone.elf ::/build/dhrystone mcopy -o -i $(DISK_IMAGE) applications/transpose/images.raw ::/misc mcopy -o -i $(DISK_IMAGE) applications/convol/philips_image.raw ::/misc mcopy -o -i $(DISK_IMAGE) map.bin ::/ ### Copy bootloader into sector 2 of disk image dd if=build/boot/boot.elf of=$(DISK_IMAGE) seek=2 conv=notrunc ### Checking root directory mdir -/ -b -i $(DISK_IMAGE) ::/ ### Disk image generation (no files in this step) ### This requires the generic LINUX/MacOS script "create_dmg" script ### written by C.Fuguet. (should be installed in GIET-VM root directory). $(DISK_IMAGE): ./create_dmg create $(basename $(DISK_IMAGE)) mmd -o -i $(DISK_IMAGE) ::/build mmd -o -i $(DISK_IMAGE) ::/build/kernel mmd -o -i $(DISK_IMAGE) ::/build/display mmd -o -i $(DISK_IMAGE) ::/build/sort mmd -o -i $(DISK_IMAGE) ::/build/transpose mmd -o -i $(DISK_IMAGE) ::/build/convol mmd -o -i $(DISK_IMAGE) ::/build/classif mmd -o -i $(DISK_IMAGE) ::/build/hello mmd -o -i $(DISK_IMAGE) ::/build/pgcd mmd -o -i $(DISK_IMAGE) ::/build/router mmd -o -i $(DISK_IMAGE) ::/build/gameoflife mmd -o -i $(DISK_IMAGE) ::/build/dhrystone mmd -o -i $(DISK_IMAGE) ::/misc dd if=$(DISK_IMAGE) of=temp.dmg count=65536 mv temp.dmg $(DISK_IMAGE) ### mapping generation: map.bin / map.xml / hard_config.h / giet_vsegs.ld map.bin hard_config.h giet_vsegs.ld: $(ARCH)/arch.py applications/$(APP)/$(APP).py giet_python/genmap --arch=$(ARCH) \ --x=$(X_SIZE) \ --y=$(Y_SIZE) \ --p=$(NB_PROCS) \ --tty=$(NB_TTYS) \ --fbf=$(FBF_WIDTH) \ --giet=. \ --$(APP) \ --xml=. ### drivers compilation build/drivers/cma_driver.o: giet_drivers/cma_driver.c \ giet_drivers/cma_driver.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/dma_driver.o: giet_drivers/dma_driver.c \ giet_drivers/dma_driver.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/xcu_driver.o: giet_drivers/xcu_driver.c \ giet_drivers/xcu_driver.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/ioc_driver.o: giet_drivers/ioc_driver.c \ giet_drivers/ioc_driver.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/bdv_driver.o: giet_drivers/bdv_driver.c \ giet_drivers/bdv_driver.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/hba_driver.o: giet_drivers/hba_driver.c \ giet_drivers/hba_driver.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/sdc_driver.o: giet_drivers/sdc_driver.c \ giet_drivers/sdc_driver.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/spi_driver.o: giet_drivers/spi_driver.c \ giet_drivers/spi_driver.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/rdk_driver.o: giet_drivers/rdk_driver.c \ giet_drivers/rdk_driver.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/iob_driver.o: giet_drivers/iob_driver.c \ giet_drivers/iob_driver.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/mmc_driver.o: giet_drivers/mmc_driver.c \ giet_drivers/mmc_driver.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/mwr_driver.o: giet_drivers/mwr_driver.c \ giet_drivers/mwr_driver.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/nic_driver.o: giet_drivers/nic_driver.c \ giet_drivers/nic_driver.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/tim_driver.o: giet_drivers/tim_driver.c \ giet_drivers/tim_driver.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/tty_driver.o: giet_drivers/tty_driver.c \ giet_drivers/tty_driver.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/drivers/pic_driver.o: giet_drivers/pic_driver.c \ giet_drivers/pic_driver.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< ################################ ### drivers library compilation build/drivers/libdrivers.a: $(DRIVERS_OBJS) $(AR) -rcs $@ $(DRIVERS_OBJS) ########################## ### common compilation build/fat32/fat32.o: giet_fat32/fat32.c \ giet_fat32/fat32.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/common/utils.o: giet_common/utils.c \ giet_common/utils.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/common/locks.o: giet_common/locks.c \ giet_common/locks.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/common/tty0.o: giet_common/tty0.c \ giet_common/tty0.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/common/vmem.o: giet_common/vmem.c \ giet_common/vmem.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/common/pmem.o: giet_common/pmem.c \ giet_common/pmem.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/common/kernel_malloc.o: giet_common/kernel_malloc.c \ giet_common/kernel_malloc.h \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< ######################## ### boot compilation build/boot/boot.elf: $(BOOT_OBJS) \ giet_boot/boot.ld \ build/drivers/libdrivers.a $(LD) -o $@ -T giet_boot/boot.ld $(BOOT_OBJS) -Lbuild/drivers -ldrivers $(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 \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/boot/boot_entry.o: giet_boot/boot_entry.S \ hard_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< ######################### ### kernel compilation build/kernel/kernel.elf: $(KERNEL_OBJS) \ giet_kernel/kernel.ld \ build/drivers/libdrivers.a $(LD) -o $@ -T giet_kernel/kernel.ld $(KERNEL_OBJS) -Lbuild/drivers -ldrivers $(DU) -D $@ > $@.txt build/kernel/%.o: giet_kernel/%.c \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< build/kernel/%.o: giet_kernel/%.s \ hard_config.h \ giet_config.h $(CC) $(GIET_INCLUDE) $(CFLAGS) -c -o $@ $< ########################### ### user libs compilation build/libs/stdio.o: giet_libs/stdio.c \ giet_libs/stdio.h \ hard_config.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 \ hard_config.h \ giet_config.h $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< build/libs/malloc.o: giet_libs/malloc.c \ giet_libs/malloc.h \ hard_config.h \ giet_config.h $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< build/libs/barrier.o: giet_libs/barrier.c \ giet_libs/barrier.h \ hard_config.h \ giet_config.h $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< build/libs/stdlib.o: giet_libs/stdlib.c \ giet_libs/stdlib.h \ hard_config.h \ giet_config.h $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< build/libs/string.o: giet_libs/string.c \ giet_libs/string.h \ hard_config.h \ giet_config.h $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< build/libs/user_lock.o: giet_libs/user_lock.c \ giet_libs/user_lock.h \ hard_config.h \ giet_config.h $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< build/libs/sbt_barrier.o: giet_libs/sbt_barrier.c \ hard_config.h \ giet_config.h $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< ######################################## ### display application compilation build/display/display.elf: $(DISPLAY_OBJS) applications/display/display.ld hard_config.h $(LD) -o $@ -T applications/display/display.ld $(DISPLAY_OBJS) $(DU) -D $@ > $@.txt build/display/main.o: applications/display/main.c $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< ######################################## ### router compilation build/router/router.elf: $(ROUTER_OBJS) applications/router/router.ld hard_config.h $(LD) -o $@ -T applications/router/router.ld $(ROUTER_OBJS) $(DU) -D $@ > $@.txt build/router/main.o: applications/router/main.c $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< ######################################## ### hello compilation build/hello/hello.elf: $(HELLO_OBJS) applications/hello/hello.ld hard_config.h $(LD) -o $@ -T applications/hello/hello.ld $(HELLO_OBJS) $(DU) -D $@ > $@.txt build/hello/main.o: applications/hello/main.c $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< ######################################## ### pgcd compilation build/pgcd/pgcd.elf: $(PGCD_OBJS) applications/pgcd/pgcd.ld hard_config.h $(LD) -o $@ -T applications/pgcd/pgcd.ld $(PGCD_OBJS) $(DU) -D $@ > $@.txt build/pgcd/main.o: applications/pgcd/main.c $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< ######################################## ### gameoflife compilation build/gameoflife/gameoflife.elf: $(GAMEOFLIFE_OBJS) applications/gameoflife/gameoflife.ld $(LD) -o $@ -T applications/gameoflife/gameoflife.ld $(GAMEOFLIFE_OBJS) $(DU) -D $@ > $@.txt build/gameoflife/main.o: applications/gameoflife/main.c $(CC) $(USER_INCLUDE) $(CFLAGS) -O3 -c -o $@ $< ######################################## ### dhrystone compilation build/dhrystone/dhrystone.elf: $(DHRYSTONE_OBJS) applications/dhrystone/dhrystone.ld hard_config.h $(LD) -o $@ -T applications/dhrystone/dhrystone.ld $(DHRYSTONE_OBJS) $(DU) -D $@ > $@.txt build/dhrystone/dhry_1.o: applications/dhrystone/dhry_1.c $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< build/dhrystone/dhry_2.o: applications/dhrystone/dhry_2.c $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< ######################################## ### sort compilation build/sort/sort.elf: $(SORT_OBJS) applications/sort/sort.ld hard_config.h $(LD) -o $@ -T applications/sort/sort.ld $(SORT_OBJS) $(DU) -D $@ > $@.txt build/sort/main.o: applications/sort/main.c $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< ######################################## ### transpose compilation build/transpose/transpose.elf: $(TRANSPOSE_OBJS) applications/transpose/transpose.ld hard_config.h $(LD) -o $@ -T applications/transpose/transpose.ld $(TRANSPOSE_OBJS) $(DU) -D $@ > $@.txt build/transpose/main.o: applications/transpose/main.c $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< ######################################## ### convol compilation build/convol/convol.elf: $(CONVOL_OBJS) applications/convol/convol.ld hard_config.h $(LD) -o $@ -T applications/convol/convol.ld $(CONVOL_OBJS) $(DU) -D $@ > $@.txt build/convol/main.o: applications/convol/main.c $(CC) $(USER_INCLUDE) $(CFLAGS) -O0 -c -o $@ $< ######################################## ### classif compilation build/classif/classif.elf: $(CLASSIF_OBJS) applications/classif/classif.ld hard_config.h $(LD) -o $@ -T applications/classif/classif.ld $(CLASSIF_OBJS) $(DU) -D $@ > $@.txt build/classif/main.o: applications/classif/main.c $(CC) $(USER_INCLUDE) $(CFLAGS) -O0 -c -o $@ $< ######################################## ### clean clean: rm -f *.o *.elf *.bin *.txt core rm -f hard_config.h giet_vsegs.ld map.bin map.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/transpose/* rm -rf build/convol/* rm -rf build/classif/* rm -rf $(DISK_IMAGE)