1 | export # export all variable to sub-Makefile |
---|
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 | |
---|
7 | MAP_XML = mappings/4c_1p_40.xml |
---|
8 | |
---|
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 |
---|
19 | |
---|
20 | BOOT_OBJS = build/boot/reset.o \ |
---|
21 | build/boot/boot_init.o |
---|
22 | |
---|
23 | DISPLAY_OBJS = build/display/main.o \ |
---|
24 | build/libs/stdio.o \ |
---|
25 | build/libs/utils.o |
---|
26 | |
---|
27 | ROUTER_OBJS = build/router/main.o \ |
---|
28 | build/libs/mwmr_channel.o \ |
---|
29 | build/libs/stdio.o \ |
---|
30 | build/libs/utils.o |
---|
31 | |
---|
32 | HELLO_OBJS = build/hello/main.o \ |
---|
33 | build/libs/stdio.o \ |
---|
34 | build/libs/utils.o |
---|
35 | |
---|
36 | PGCD_OBJS = build/pgcd/main.o \ |
---|
37 | build/libs/stdio.o \ |
---|
38 | build/libs/utils.o |
---|
39 | |
---|
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 \ |
---|
45 | build/libs/malloc.o |
---|
46 | |
---|
47 | |
---|
48 | CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 -g |
---|
49 | |
---|
50 | INCLUDE = -Iboot -Isys -Ixml -Ilibs -I. |
---|
51 | |
---|
52 | all: map.bin soft.elf |
---|
53 | |
---|
54 | ## merge all *.elf and map.bin to soft.elf |
---|
55 | soft.elf: build/boot/boot.elf \ |
---|
56 | build/sys/sys.elf \ |
---|
57 | build/display/display.elf \ |
---|
58 | build/router/router.elf \ |
---|
59 | build/pgcd/pgcd.elf \ |
---|
60 | build/hello/hello.elf \ |
---|
61 | build/dhrystone/dhrystone.elf \ |
---|
62 | |
---|
63 | $(MAKE) -C memo |
---|
64 | memo/memo.x map.bin |
---|
65 | $(DU) -D $@ > build$@.txt |
---|
66 | |
---|
67 | ### mapping compilation |
---|
68 | map.bin: $(MAP_XML) |
---|
69 | $(MAKE) -C xml |
---|
70 | xml/xml2bin $< . |
---|
71 | |
---|
72 | ### system compilation |
---|
73 | build/sys/sys.elf: $(SYS_OBJS) sys/sys.ld |
---|
74 | $(LD) -o $@ -T sys/sys.ld $(SYS_OBJS) |
---|
75 | $(DU) -D $@ > $@.txt |
---|
76 | |
---|
77 | build/sys/%.o: sys/%.c giet_config.h $(MAP_XML) |
---|
78 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
79 | |
---|
80 | build/sys/%.o: sys/%.s giet_config.h $(MAP_XML) |
---|
81 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
82 | |
---|
83 | ### boot compilation |
---|
84 | build/boot/boot.elf: $(BOOT_OBJS) boot/boot.ld |
---|
85 | $(LD) -o $@ -T boot/boot.ld $(BOOT_OBJS) |
---|
86 | $(DU) -D $@ > $@.txt |
---|
87 | |
---|
88 | build/boot/%.o: boot/%.c giet_config.h $(MAP_XML) |
---|
89 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
90 | |
---|
91 | build/boot/%.o: boot/%.S giet_config.h $(MAP_XML) |
---|
92 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
93 | |
---|
94 | ### display compilation |
---|
95 | build/display/display.elf: $(DISPLAY_OBJS) display/display.ld |
---|
96 | $(LD) -o $@ -T display/display.ld $(DISPLAY_OBJS) |
---|
97 | $(DU) -D $@ > $@.txt |
---|
98 | |
---|
99 | build/display/main.o: display/main.c |
---|
100 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
101 | |
---|
102 | ### router compilation |
---|
103 | build/router/router.elf: $(ROUTER_OBJS) router/router.ld |
---|
104 | $(LD) -o $@ -T router/router.ld $(ROUTER_OBJS) |
---|
105 | $(DU) -D $@ > $@.txt |
---|
106 | |
---|
107 | build/router/main.o: router/main.c |
---|
108 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
109 | |
---|
110 | ### hello compilation |
---|
111 | build/hello/hello.elf: $(HELLO_OBJS) hello/hello.ld |
---|
112 | $(LD) -o $@ -T hello/hello.ld $(HELLO_OBJS) |
---|
113 | $(DU) -D $@ > $@.txt |
---|
114 | |
---|
115 | build/hello/main.o: hello/main.c |
---|
116 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
117 | |
---|
118 | ### pgcd compilation |
---|
119 | build/pgcd/pgcd.elf: $(PGCD_OBJS) pgcd/pgcd.ld |
---|
120 | $(LD) -o $@ -T pgcd/pgcd.ld $(PGCD_OBJS) |
---|
121 | $(DU) -D $@ > $@.txt |
---|
122 | |
---|
123 | build/pgcd/main.o: pgcd/main.c |
---|
124 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
125 | |
---|
126 | ### dhrystone compilation |
---|
127 | build/dhrystone/dhrystone.elf: $(DHRYSTONE_OBJS) dhrystone/dhrystone.ld |
---|
128 | $(LD) -o $@ -T dhrystone/dhrystone.ld $(DHRYSTONE_OBJS) |
---|
129 | $(DU) -D $@ > $@.txt |
---|
130 | |
---|
131 | build/dhrystone/dhry_1.o: dhrystone/dhry_1.c |
---|
132 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
133 | |
---|
134 | build/dhrystone/dhry_2.o: dhrystone/dhry_2.c |
---|
135 | $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
136 | |
---|
137 | ### libs compilation |
---|
138 | build/libs/utils.o: libs/utils.c giet_config.h |
---|
139 | $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $< |
---|
140 | |
---|
141 | build/libs/stdio.o: libs/stdio.c giet_config.h |
---|
142 | $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $< |
---|
143 | |
---|
144 | build/libs/mwmr_channel.o: libs/mwmr_channel.c |
---|
145 | $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $< |
---|
146 | |
---|
147 | build/libs/malloc.o: libs/malloc.c libs/malloc.h libs/malloc_private.h giet_config.h |
---|
148 | $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $< |
---|
149 | |
---|
150 | build/libs/string.o: libs/string.c libs/string.h |
---|
151 | $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $< |
---|
152 | |
---|
153 | ### clean |
---|
154 | clean: |
---|
155 | rm -f *.o *.elf *.bin *.txt core giet_vsegs.ld hard_config.h *~ |
---|
156 | $(MAKE) -s clean -C xml |
---|
157 | $(MAKE) -s clean -C memo |
---|
158 | rm -rf build/boot/* |
---|
159 | rm -rf build/sys/* |
---|
160 | rm -rf build/libs/* |
---|
161 | rm -rf build/pgcd/* |
---|
162 | rm -rf build/hello/* |
---|
163 | rm -rf build/display/* |
---|
164 | rm -rf build/router/* |
---|
165 | rm -rf build/dhrystone/* |
---|