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