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