[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 | |
---|
[249] | 7 | MAP_XML = mappings/4c_1p_iob.xml |
---|
[204] | 8 | |
---|
[189] | 9 | SYS_OBJS = build/sys/vm_handler.o \ |
---|
[232] | 10 | build/sys/sys_handler.o \ |
---|
[189] | 11 | build/sys/giet.o \ |
---|
[232] | 12 | build/sys/switch.o \ |
---|
[189] | 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 | |
---|
[241] | 40 | DHRYSTONE_OBJS = build/dhrystone/dhry_1.o \ |
---|
| 41 | build/dhrystone/dhry_2.o \ |
---|
| 42 | build/libs/stdio.o \ |
---|
| 43 | build/libs/utils.o \ |
---|
| 44 | build/libs/string.o \ |
---|
[244] | 45 | build/libs/spin_lock.o \ |
---|
[241] | 46 | build/libs/malloc.o |
---|
| 47 | |
---|
| 48 | |
---|
[232] | 49 | CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 -g |
---|
[158] | 50 | |
---|
[189] | 51 | INCLUDE = -Iboot -Isys -Ixml -Ilibs -I. |
---|
[158] | 52 | |
---|
[232] | 53 | all: map.bin soft.elf |
---|
[160] | 54 | |
---|
[189] | 55 | ## merge all *.elf and map.bin to soft.elf |
---|
| 56 | soft.elf: build/boot/boot.elf \ |
---|
| 57 | build/sys/sys.elf \ |
---|
| 58 | build/display/display.elf \ |
---|
| 59 | build/router/router.elf \ |
---|
| 60 | build/pgcd/pgcd.elf \ |
---|
| 61 | build/hello/hello.elf \ |
---|
[241] | 62 | build/dhrystone/dhrystone.elf \ |
---|
[215] | 63 | |
---|
[189] | 64 | $(MAKE) -C memo |
---|
| 65 | memo/memo.x map.bin |
---|
| 66 | $(DU) -D $@ > build$@.txt |
---|
[160] | 67 | |
---|
[177] | 68 | ### mapping compilation |
---|
[204] | 69 | map.bin: $(MAP_XML) |
---|
[189] | 70 | $(MAKE) -C xml |
---|
[215] | 71 | xml/xml2bin $< . |
---|
[158] | 72 | |
---|
[177] | 73 | ### system compilation |
---|
[218] | 74 | build/sys/sys.elf: $(SYS_OBJS) sys/sys.ld |
---|
[189] | 75 | $(LD) -o $@ -T sys/sys.ld $(SYS_OBJS) |
---|
| 76 | $(DU) -D $@ > $@.txt |
---|
[158] | 77 | |
---|
[218] | 78 | build/sys/%.o: sys/%.c giet_config.h $(MAP_XML) |
---|
[189] | 79 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
[158] | 80 | |
---|
[218] | 81 | build/sys/%.o: sys/%.s giet_config.h $(MAP_XML) |
---|
[189] | 82 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
[158] | 83 | |
---|
[177] | 84 | ### boot compilation |
---|
[189] | 85 | build/boot/boot.elf: $(BOOT_OBJS) boot/boot.ld |
---|
| 86 | $(LD) -o $@ -T boot/boot.ld $(BOOT_OBJS) |
---|
| 87 | $(DU) -D $@ > $@.txt |
---|
[158] | 88 | |
---|
[218] | 89 | build/boot/%.o: boot/%.c giet_config.h $(MAP_XML) |
---|
[189] | 90 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
[158] | 91 | |
---|
[218] | 92 | build/boot/%.o: boot/%.S giet_config.h $(MAP_XML) |
---|
[189] | 93 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
[158] | 94 | |
---|
[189] | 95 | ### display compilation |
---|
| 96 | build/display/display.elf: $(DISPLAY_OBJS) display/display.ld |
---|
| 97 | $(LD) -o $@ -T display/display.ld $(DISPLAY_OBJS) |
---|
| 98 | $(DU) -D $@ > $@.txt |
---|
[158] | 99 | |
---|
[189] | 100 | build/display/main.o: display/main.c |
---|
| 101 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 102 | |
---|
| 103 | ### router compilation |
---|
| 104 | build/router/router.elf: $(ROUTER_OBJS) router/router.ld |
---|
| 105 | $(LD) -o $@ -T router/router.ld $(ROUTER_OBJS) |
---|
| 106 | $(DU) -D $@ > $@.txt |
---|
| 107 | |
---|
| 108 | build/router/main.o: router/main.c |
---|
| 109 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 110 | |
---|
| 111 | ### hello compilation |
---|
| 112 | build/hello/hello.elf: $(HELLO_OBJS) hello/hello.ld |
---|
| 113 | $(LD) -o $@ -T hello/hello.ld $(HELLO_OBJS) |
---|
| 114 | $(DU) -D $@ > $@.txt |
---|
| 115 | |
---|
| 116 | build/hello/main.o: hello/main.c |
---|
[232] | 117 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
[189] | 118 | |
---|
| 119 | ### pgcd compilation |
---|
| 120 | build/pgcd/pgcd.elf: $(PGCD_OBJS) pgcd/pgcd.ld |
---|
| 121 | $(LD) -o $@ -T pgcd/pgcd.ld $(PGCD_OBJS) |
---|
| 122 | $(DU) -D $@ > $@.txt |
---|
| 123 | |
---|
| 124 | build/pgcd/main.o: pgcd/main.c |
---|
[232] | 125 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
[189] | 126 | |
---|
[241] | 127 | ### dhrystone compilation |
---|
| 128 | build/dhrystone/dhrystone.elf: $(DHRYSTONE_OBJS) dhrystone/dhrystone.ld |
---|
| 129 | $(LD) -o $@ -T dhrystone/dhrystone.ld $(DHRYSTONE_OBJS) |
---|
| 130 | $(DU) -D $@ > $@.txt |
---|
| 131 | |
---|
| 132 | build/dhrystone/dhry_1.o: dhrystone/dhry_1.c |
---|
| 133 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 134 | |
---|
| 135 | build/dhrystone/dhry_2.o: dhrystone/dhry_2.c |
---|
| 136 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
| 137 | |
---|
[177] | 138 | ### libs compilation |
---|
[197] | 139 | build/libs/utils.o: libs/utils.c giet_config.h |
---|
[232] | 140 | $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $< |
---|
[158] | 141 | |
---|
[197] | 142 | build/libs/stdio.o: libs/stdio.c giet_config.h |
---|
[232] | 143 | $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $< |
---|
[158] | 144 | |
---|
[189] | 145 | build/libs/mwmr_channel.o: libs/mwmr_channel.c |
---|
[232] | 146 | $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $< |
---|
[189] | 147 | |
---|
[232] | 148 | build/libs/malloc.o: libs/malloc.c libs/malloc.h libs/malloc_private.h giet_config.h |
---|
| 149 | $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $< |
---|
[189] | 150 | |
---|
[241] | 151 | build/libs/string.o: libs/string.c libs/string.h |
---|
| 152 | $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $< |
---|
[232] | 153 | |
---|
[244] | 154 | build/libs/spin_lock.o: libs/spin_lock.c libs/spin_lock.h |
---|
| 155 | $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $< |
---|
| 156 | |
---|
[177] | 157 | ### clean |
---|
[158] | 158 | clean: |
---|
[232] | 159 | rm -f *.o *.elf *.bin *.txt core giet_vsegs.ld hard_config.h *~ |
---|
| 160 | $(MAKE) -s clean -C xml |
---|
| 161 | $(MAKE) -s clean -C memo |
---|
| 162 | rm -rf build/boot/* |
---|
| 163 | rm -rf build/sys/* |
---|
| 164 | rm -rf build/libs/* |
---|
| 165 | rm -rf build/pgcd/* |
---|
| 166 | rm -rf build/hello/* |
---|
| 167 | rm -rf build/display/* |
---|
| 168 | rm -rf build/router/* |
---|
[241] | 169 | rm -rf build/dhrystone/* |
---|