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