[162] | 1 | export # export all variable to sub-Makefile |
---|
[158] | 2 | CC=mipsel-unknown-elf-gcc |
---|
| 3 | AS=mipsel-unknown-elf-as |
---|
| 4 | LD=mipsel-unknown-elf-ld |
---|
| 5 | DU=mipsel-unknown-elf-objdump |
---|
| 6 | |
---|
[214] | 7 | MAP_XML = mappings/4c_1p_four.xml |
---|
[204] | 8 | |
---|
[189] | 9 | SYS_OBJS = build/sys/vm_handler.o \ |
---|
| 10 | build/sys/sys_handler.o \ |
---|
| 11 | build/sys/giet.o \ |
---|
| 12 | build/sys/switch.o \ |
---|
| 13 | build/sys/common.o \ |
---|
| 14 | build/sys/ctx_handler.o \ |
---|
| 15 | build/sys/drivers.o \ |
---|
| 16 | build/sys/exc_handler.o \ |
---|
| 17 | build/sys/irq_handler.o \ |
---|
| 18 | build/sys/kernel_init.o |
---|
[162] | 19 | |
---|
[189] | 20 | BOOT_OBJS = build/boot/reset.o \ |
---|
| 21 | build/boot/boot_init.o |
---|
[162] | 22 | |
---|
[189] | 23 | DISPLAY_OBJS = build/display/main.o \ |
---|
| 24 | build/libs/stdio.o \ |
---|
| 25 | build/libs/utils.o |
---|
[162] | 26 | |
---|
[189] | 27 | ROUTER_OBJS = build/router/main.o \ |
---|
| 28 | build/libs/mwmr_channel.o \ |
---|
| 29 | build/libs/stdio.o \ |
---|
| 30 | build/libs/utils.o |
---|
[162] | 31 | |
---|
[189] | 32 | HELLO_OBJS = build/hello/main.o \ |
---|
| 33 | build/libs/stdio.o \ |
---|
| 34 | build/libs/utils.o |
---|
[158] | 35 | |
---|
[189] | 36 | PGCD_OBJS = build/pgcd/main.o \ |
---|
| 37 | build/libs/stdio.o \ |
---|
| 38 | build/libs/utils.o |
---|
[158] | 39 | |
---|
[160] | 40 | CFLAGS=-Wall -ffreestanding -mno-gpopt -mips32 -g |
---|
[158] | 41 | |
---|
[189] | 42 | INCLUDE = -Iboot -Isys -Ixml -Ilibs -I. |
---|
[158] | 43 | |
---|
[160] | 44 | TRASH= /dev/null||true |
---|
| 45 | |
---|
[215] | 46 | all: map.bin soft.elf |
---|
[160] | 47 | |
---|
[189] | 48 | ## merge all *.elf and map.bin to soft.elf |
---|
| 49 | soft.elf: build/boot/boot.elf \ |
---|
| 50 | build/sys/sys.elf \ |
---|
| 51 | build/display/display.elf \ |
---|
| 52 | build/router/router.elf \ |
---|
| 53 | build/pgcd/pgcd.elf \ |
---|
| 54 | build/hello/hello.elf \ |
---|
[215] | 55 | |
---|
[189] | 56 | $(MAKE) -C memo |
---|
| 57 | memo/memo.x map.bin |
---|
| 58 | $(DU) -D $@ > build$@.txt |
---|
[160] | 59 | |
---|
[177] | 60 | ### mapping compilation |
---|
[204] | 61 | map.bin: $(MAP_XML) |
---|
[189] | 62 | $(MAKE) -C xml |
---|
[215] | 63 | xml/xml2bin $< . |
---|
[158] | 64 | |
---|
[177] | 65 | ### system compilation |
---|
[218] | 66 | build/sys/sys.elf: $(SYS_OBJS) sys/sys.ld |
---|
[189] | 67 | $(LD) -o $@ -T sys/sys.ld $(SYS_OBJS) |
---|
| 68 | $(DU) -D $@ > $@.txt |
---|
[158] | 69 | |
---|
[218] | 70 | build/sys/%.o: sys/%.c giet_config.h $(MAP_XML) |
---|
[189] | 71 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
[158] | 72 | |
---|
[218] | 73 | build/sys/%.o: sys/%.s giet_config.h $(MAP_XML) |
---|
[189] | 74 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
[158] | 75 | |
---|
[177] | 76 | ### boot compilation |
---|
[189] | 77 | build/boot/boot.elf: $(BOOT_OBJS) boot/boot.ld |
---|
| 78 | $(LD) -o $@ -T boot/boot.ld $(BOOT_OBJS) |
---|
| 79 | $(DU) -D $@ > $@.txt |
---|
[158] | 80 | |
---|
[218] | 81 | build/boot/%.o: boot/%.c giet_config.h $(MAP_XML) |
---|
[189] | 82 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
[158] | 83 | |
---|
[218] | 84 | build/boot/%.o: boot/%.S giet_config.h $(MAP_XML) |
---|
[189] | 85 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
[158] | 86 | |
---|
[189] | 87 | ### display compilation |
---|
| 88 | build/display/display.elf: $(DISPLAY_OBJS) display/display.ld |
---|
| 89 | $(LD) -o $@ -T display/display.ld $(DISPLAY_OBJS) |
---|
| 90 | $(DU) -D $@ > $@.txt |
---|
[158] | 91 | |
---|
[189] | 92 | build/display/main.o: display/main.c |
---|
| 93 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 94 | |
---|
| 95 | ### router compilation |
---|
| 96 | build/router/router.elf: $(ROUTER_OBJS) router/router.ld |
---|
| 97 | $(LD) -o $@ -T router/router.ld $(ROUTER_OBJS) |
---|
| 98 | $(DU) -D $@ > $@.txt |
---|
| 99 | |
---|
| 100 | build/router/main.o: router/main.c |
---|
| 101 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 102 | |
---|
| 103 | ### hello compilation |
---|
| 104 | build/hello/hello.elf: $(HELLO_OBJS) hello/hello.ld |
---|
| 105 | $(LD) -o $@ -T hello/hello.ld $(HELLO_OBJS) |
---|
| 106 | $(DU) -D $@ > $@.txt |
---|
| 107 | |
---|
| 108 | build/hello/main.o: hello/main.c |
---|
| 109 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 110 | |
---|
| 111 | ### pgcd compilation |
---|
| 112 | build/pgcd/pgcd.elf: $(PGCD_OBJS) pgcd/pgcd.ld |
---|
| 113 | $(LD) -o $@ -T pgcd/pgcd.ld $(PGCD_OBJS) |
---|
| 114 | $(DU) -D $@ > $@.txt |
---|
| 115 | |
---|
| 116 | build/pgcd/main.o: pgcd/main.c |
---|
| 117 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 118 | |
---|
[177] | 119 | ### libs compilation |
---|
[197] | 120 | build/libs/utils.o: libs/utils.c giet_config.h |
---|
[189] | 121 | $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $< |
---|
[158] | 122 | |
---|
[197] | 123 | build/libs/stdio.o: libs/stdio.c giet_config.h |
---|
[189] | 124 | $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $< |
---|
[158] | 125 | |
---|
[189] | 126 | build/libs/mwmr_channel.o: libs/mwmr_channel.c |
---|
| 127 | $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $< |
---|
| 128 | |
---|
| 129 | |
---|
[177] | 130 | ### clean |
---|
[158] | 131 | clean: |
---|
[215] | 132 | rm -f *.o *.elf *.bin *.txt core giet_vsegs.ld hard_config.h *~ 2>$(TRASH) |
---|
[196] | 133 | $(MAKE) -s clean -C xml 2>$(TRASH) |
---|
| 134 | $(MAKE) -s clean -C memo 2>$(TRASH) |
---|
[189] | 135 | rm -r build/boot/* 2>$(TRASH) |
---|
| 136 | rm -r build/sys/* 2>$(TRASH) |
---|
| 137 | rm -r build/libs/* 2>$(TRASH) |
---|
| 138 | rm -r build/pgcd/* 2>$(TRASH) |
---|
| 139 | rm -r build/hello/* 2>$(TRASH) |
---|
| 140 | rm -r build/display/* 2>$(TRASH) |
---|
| 141 | rm -r build/router/* 2>$(TRASH) |
---|