[158] | 1 | CC=mipsel-unknown-elf-gcc |
---|
| 2 | AS=mipsel-unknown-elf-as |
---|
| 3 | LD=mipsel-unknown-elf-ld |
---|
| 4 | DU=mipsel-unknown-elf-objdump |
---|
| 5 | |
---|
[160] | 6 | SYS_OBJS = giet.o \ |
---|
| 7 | switch.o \ |
---|
| 8 | common.o \ |
---|
| 9 | ctx_handler.o \ |
---|
| 10 | drivers.o \ |
---|
| 11 | exc_handler.o \ |
---|
| 12 | irq_handler.o \ |
---|
| 13 | sys_handler.o \ |
---|
| 14 | init.o \ |
---|
| 15 | task_init.o |
---|
[158] | 16 | |
---|
[160] | 17 | BOOT_OBJS = reset.o \ |
---|
| 18 | boot_handler.o |
---|
[158] | 19 | |
---|
| 20 | SYS_PATH = sys |
---|
[160] | 21 | BOOT_PATH = boot |
---|
[158] | 22 | MAP_PATH = xml |
---|
| 23 | LIBS_PATH = libs |
---|
[160] | 24 | BUILD_DIR_NAME = build |
---|
[158] | 25 | |
---|
[160] | 26 | CFLAGS=-Wall -ffreestanding -mno-gpopt -mips32 -g |
---|
[158] | 27 | |
---|
| 28 | SYS_INCLUDE = -I$(SYS_PATH) -I$(MAP_PATH) -I$(LIBS_PATH) -I. |
---|
| 29 | |
---|
[160] | 30 | BOOT_INCLUDE = -I$(BOOT_PATH) -I$(MAP_PATH) -I$(LIBS_PATH) -I. |
---|
[158] | 31 | |
---|
[160] | 32 | #commons between sys and boot are: common.ld , mips_registers.h... |
---|
| 33 | |
---|
| 34 | TRASH= /dev/null||true |
---|
| 35 | |
---|
| 36 | .PHONY: apps prepare |
---|
| 37 | |
---|
| 38 | all: prepare soft.bin |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | ## merge all *.bin to soft.bin |
---|
| 42 | soft.bin: boot.bin sys.bin map.bin apps |
---|
| 43 | make -C mover |
---|
| 44 | mover/mover.x -sm map.bin |
---|
| 45 | $(DU) -D $@ > $@.txt |
---|
| 46 | |
---|
| 47 | ## prepare the environement |
---|
| 48 | prepare: |
---|
| 49 | @mkdir $(BUILD_DIR_NAME) 2>$(TRASH) |
---|
| 50 | |
---|
[158] | 51 | ## mapping compilation |
---|
| 52 | map.bin: map.xml |
---|
[160] | 53 | make -C xml #compile the parser |
---|
[158] | 54 | xml/xml2bin map.xml map.bin |
---|
| 55 | |
---|
| 56 | ## system compilation |
---|
| 57 | sys.bin: $(SYS_OBJS) $(SYS_PATH)/sys.ld |
---|
[160] | 58 | (cd $(BUILD_DIR_NAME); $(LD) -o ../$@ -T ../$(SYS_PATH)/sys.ld $(SYS_OBJS) ) |
---|
| 59 | (cd $(BUILD_DIR_NAME); $(DU) -D ../$@ > $@.txt) |
---|
[158] | 60 | |
---|
| 61 | switch.o: $(SYS_PATH)/switch.s giet_config.h |
---|
[160] | 62 | $(AS) -g -mips32 -o $(BUILD_DIR_NAME)/$@ $< |
---|
[158] | 63 | |
---|
| 64 | giet.o: $(SYS_PATH)/giet.s giet_config.h |
---|
[160] | 65 | $(AS) -g -mips32 -o $(BUILD_DIR_NAME)/$@ $< |
---|
[158] | 66 | |
---|
[160] | 67 | task_init.o: $(SYS_PATH)/task_init.S giet_config.h |
---|
| 68 | #$(AS) -g -mips32 -o $(BUILD_DIR_NAME)/$@ $< |
---|
| 69 | $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
| 70 | $(DU) -D $(BUILD_DIR_NAME)/$@ > $(BUILD_DIR_NAME)/$@.txt |
---|
[158] | 71 | |
---|
| 72 | ctx_handler.o: $(SYS_PATH)/ctx_handler.c $(SYS_PATH)/ctx_handler.h giet_config.h |
---|
[160] | 73 | $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
[158] | 74 | |
---|
| 75 | exc_handler.o: $(SYS_PATH)/exc_handler.c $(SYS_PATH)/exc_handler.h giet_config.h |
---|
[160] | 76 | $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
[158] | 77 | |
---|
| 78 | irq_handler.o: $(SYS_PATH)/irq_handler.c $(SYS_PATH)/irq_handler.h giet_config.h |
---|
[160] | 79 | $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
[158] | 80 | |
---|
| 81 | sys_handler.o: $(SYS_PATH)/sys_handler.c $(SYS_PATH)/sys_handler.h giet_config.h |
---|
[160] | 82 | $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
[158] | 83 | |
---|
| 84 | drivers.o: $(SYS_PATH)/drivers.c $(SYS_PATH)/drivers.h giet_config.h |
---|
[160] | 85 | $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
[158] | 86 | |
---|
| 87 | common.o: $(SYS_PATH)/common.c $(SYS_PATH)/common.h giet_config.h |
---|
[160] | 88 | $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
[158] | 89 | |
---|
[160] | 90 | init.o: $(SYS_PATH)/init.c giet_config.h |
---|
| 91 | $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
[158] | 92 | |
---|
[160] | 93 | ## boot compilation |
---|
| 94 | boot.bin: $(BOOT_OBJS) $(BOOT_PATH)/boot.ld |
---|
| 95 | (cd $(BUILD_DIR_NAME); $(LD) -o ../$@ -T ../$(BOOT_PATH)/boot.ld $(BOOT_OBJS) ) |
---|
| 96 | (cd $(BUILD_DIR_NAME); $(DU) -D ../$@ > $@.txt) |
---|
[158] | 97 | |
---|
[160] | 98 | reset.o: $(BOOT_PATH)/reset.S giet_config.h |
---|
| 99 | $(CC) $(CFLAGS) $(BOOT_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
| 100 | $(DU) -D $(BUILD_DIR_NAME)/$@ > $(BUILD_DIR_NAME)/$@.txt |
---|
[158] | 101 | |
---|
[160] | 102 | boot_handler.o: $(BOOT_PATH)/boot_handler.c $(BOOT_PATH)/boot_handler.h giet_config.h |
---|
| 103 | $(CC) $(CFLAGS) $(BOOT_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
[158] | 104 | |
---|
[160] | 105 | ## applications and libs compilation |
---|
| 106 | apps: |
---|
| 107 | @echo "---------------------------------------------BUILDING APPS------------------------------------------------------" |
---|
| 108 | make -C apps |
---|
[158] | 109 | |
---|
| 110 | ### special rules |
---|
| 111 | clean: |
---|
[160] | 112 | rm -f *.o *.bin *.txt core *~ 2>$(TRASH) |
---|
| 113 | make clean -C xml/ 2>$(TRASH) |
---|
| 114 | make clean -C mover/ 2>$(TRASH) |
---|
| 115 | make clean -C apps 2>$(TRASH) |
---|
| 116 | rm -r $(BUILD_DIR_NAME) 2>$(TRASH) |
---|