1 | ############################################################################# |
---|
2 | # ALMOS-MKH Makefile for Kernel # |
---|
3 | ############################################################################# |
---|
4 | |
---|
5 | -include ../params-soft.mk |
---|
6 | ifeq ($(ARCH_NAME),) |
---|
7 | $(error Please define in ARCH_NAME parameter in params-soft.mk!) |
---|
8 | endif |
---|
9 | |
---|
10 | # We choose drivers and hal file to be linked with kernel.elf |
---|
11 | ifeq ($(ARCH_NAME), tsar_mips32) |
---|
12 | |
---|
13 | DRIVERS_OBJS = $(HAL_ARCH)/build/drivers/soclib_tty.o \ |
---|
14 | $(HAL_ARCH)/build/drivers/soclib_mty.o \ |
---|
15 | $(HAL_ARCH)/build/drivers/soclib_bdv.o \ |
---|
16 | $(HAL_ARCH)/build/drivers/soclib_hba.o \ |
---|
17 | $(HAL_ARCH)/build/drivers/soclib_mmc.o \ |
---|
18 | $(HAL_ARCH)/build/drivers/soclib_pic.o \ |
---|
19 | $(HAL_ARCH)/build/drivers/soclib_nic.o \ |
---|
20 | $(HAL_ARCH)/build/drivers/soclib_dma.o \ |
---|
21 | $(HAL_ARCH)/build/drivers/soclib_iob.o |
---|
22 | |
---|
23 | HAL_OBJS = $(HAL_ARCH)/build/core/hal_special.o \ |
---|
24 | $(HAL_ARCH)/build/core/hal_context.o \ |
---|
25 | $(HAL_ARCH)/build/core/hal_atomic.o \ |
---|
26 | $(HAL_ARCH)/build/core/hal_remote.o \ |
---|
27 | $(HAL_ARCH)/build/core/hal_uspace.o \ |
---|
28 | $(HAL_ARCH)/build/core/hal_irqmask.o \ |
---|
29 | $(HAL_ARCH)/build/core/hal_gpt.o \ |
---|
30 | $(HAL_ARCH)/build/core/hal_ppm.o \ |
---|
31 | $(HAL_ARCH)/build/core/hal_vmm.o \ |
---|
32 | $(HAL_ARCH)/build/core/hal_kentry.o \ |
---|
33 | $(HAL_ARCH)/build/core/hal_switch.o \ |
---|
34 | $(HAL_ARCH)/build/core/hal_syscall.o \ |
---|
35 | $(HAL_ARCH)/build/core/hal_exception.o \ |
---|
36 | $(HAL_ARCH)/build/core/hal_interrupt.o \ |
---|
37 | $(HAL_ARCH)/build/core/hal_drivers.o |
---|
38 | endif |
---|
39 | |
---|
40 | ifeq ($(ARCH_NAME), x86_64) |
---|
41 | |
---|
42 | DRIVERS_OBJS = $(HAL_ARCH)/build/drivers/ioc_ata.o \ |
---|
43 | $(HAL_ARCH)/build/drivers/pic_apic.o \ |
---|
44 | $(HAL_ARCH)/build/drivers/txt_rs232.o |
---|
45 | |
---|
46 | HAL_OBJS = $(HAL_ARCH)/build/core/hal_boot.o \ |
---|
47 | $(HAL_ARCH)/build/core/hal_smpboot.o \ |
---|
48 | $(HAL_ARCH)/build/core/hal_init.o \ |
---|
49 | $(HAL_ARCH)/build/core/hal_cpu.o \ |
---|
50 | $(HAL_ARCH)/build/core/hal_kentry.o \ |
---|
51 | $(HAL_ARCH)/build/core/hal_acpi.o \ |
---|
52 | $(HAL_ARCH)/build/core/hal_apic.o \ |
---|
53 | $(HAL_ARCH)/build/core/x86_printf.o \ |
---|
54 | $(HAL_ARCH)/build/core/hal_drivers.o \ |
---|
55 | $(HAL_ARCH)/build/core/hal_special.o \ |
---|
56 | $(HAL_ARCH)/build/core/hal_context.o \ |
---|
57 | $(HAL_ARCH)/build/core/hal_atomic.o \ |
---|
58 | $(HAL_ARCH)/build/core/hal_remote.o \ |
---|
59 | $(HAL_ARCH)/build/core/hal_uspace.o \ |
---|
60 | $(HAL_ARCH)/build/core/hal_irqmask.o \ |
---|
61 | $(HAL_ARCH)/build/core/hal_gpt.o \ |
---|
62 | $(HAL_ARCH)/build/core/hal_ppm.o \ |
---|
63 | $(HAL_ARCH)/build/core/hal_exception.o \ |
---|
64 | $(HAL_ARCH)/build/core/hal_interrupt.o \ |
---|
65 | $(HAL_ARCH)/build/core/hal_syscall.o |
---|
66 | endif |
---|
67 | |
---|
68 | LIBGCC = -L$(shell $(CC) -print-libgcc-file-name | sed 's/libgcc.a//') #todo ? |
---|
69 | |
---|
70 | # Rules that don't build target files |
---|
71 | # always out-of-date, need to be regenerated everytime they are called |
---|
72 | .PHONY: compile \ |
---|
73 | dirs \ |
---|
74 | clean \ |
---|
75 | build/kernel.elf |
---|
76 | |
---|
77 | |
---|
78 | # Objects to be linked for kernel.elf generation |
---|
79 | KERN_OBJS = build/kern/kernel_init.o \ |
---|
80 | build/kern/printk.o \ |
---|
81 | build/kern/thread.o \ |
---|
82 | build/kern/process.o \ |
---|
83 | build/kern/chdev.o \ |
---|
84 | build/kern/cluster.o \ |
---|
85 | build/kern/scheduler.o \ |
---|
86 | build/kern/core.o \ |
---|
87 | build/kern/dqdt.o \ |
---|
88 | build/kern/do_syscall.o \ |
---|
89 | build/kern/rpc.o |
---|
90 | |
---|
91 | DEV_OBJS = build/devices/dev_txt.o \ |
---|
92 | build/devices/dev_ioc.o \ |
---|
93 | build/devices/dev_mmc.o \ |
---|
94 | build/devices/dev_nic.o \ |
---|
95 | build/devices/dev_pic.o \ |
---|
96 | build/devices/dev_dma.o \ |
---|
97 | build/devices/dev_fbf.o \ |
---|
98 | build/devices/dev_iob.o |
---|
99 | |
---|
100 | MM_OBJS = build/mm/ppm.o \ |
---|
101 | build/mm/vmm.o \ |
---|
102 | build/mm/vseg.o \ |
---|
103 | build/mm/page.o \ |
---|
104 | build/mm/kcm.o \ |
---|
105 | build/mm/khm.o \ |
---|
106 | build/mm/mapper.o \ |
---|
107 | build/mm/kmem.o |
---|
108 | |
---|
109 | LIBK_OBJS = build/libk/grdxt.o \ |
---|
110 | build/libk/bits.o \ |
---|
111 | build/libk/elf.o \ |
---|
112 | build/libk/string.o \ |
---|
113 | build/libk/ctype.o \ |
---|
114 | build/libk/rwlock.o \ |
---|
115 | build/libk/busylock.o \ |
---|
116 | build/libk/queuelock.o \ |
---|
117 | build/libk/barrier.o \ |
---|
118 | build/libk/xbarrier.o \ |
---|
119 | build/libk/remote_busylock.o \ |
---|
120 | build/libk/remote_queuelock.o \ |
---|
121 | build/libk/remote_rwlock.o \ |
---|
122 | build/libk/remote_fifo.o \ |
---|
123 | build/libk/remote_mutex.o \ |
---|
124 | build/libk/remote_dir.o \ |
---|
125 | build/libk/remote_sem.o \ |
---|
126 | build/libk/remote_condvar.o \ |
---|
127 | build/libk/remote_barrier.o \ |
---|
128 | build/libk/memcpy.o \ |
---|
129 | build/libk/htab.o \ |
---|
130 | build/libk/xhtab.o |
---|
131 | |
---|
132 | SYS_OBJS_0 = build/syscalls/sys_thread_exit.o \ |
---|
133 | build/syscalls/sys_thread_yield.o \ |
---|
134 | build/syscalls/sys_thread_create.o \ |
---|
135 | build/syscalls/sys_thread_join.o \ |
---|
136 | build/syscalls/sys_thread_detach.o \ |
---|
137 | build/syscalls/sys_thread_cancel.o \ |
---|
138 | build/syscalls/sys_sem.o \ |
---|
139 | build/syscalls/sys_condvar.o \ |
---|
140 | build/syscalls/sys_barrier.o \ |
---|
141 | build/syscalls/sys_mutex.o |
---|
142 | |
---|
143 | SYS_OBJS_1 = build/syscalls/sys_rename.o \ |
---|
144 | build/syscalls/sys_munmap.o \ |
---|
145 | build/syscalls/sys_open.o \ |
---|
146 | build/syscalls/sys_mmap.o \ |
---|
147 | build/syscalls/sys_read.o \ |
---|
148 | build/syscalls/sys_write.o \ |
---|
149 | build/syscalls/sys_lseek.o \ |
---|
150 | build/syscalls/sys_close.o \ |
---|
151 | build/syscalls/sys_unlink.o \ |
---|
152 | build/syscalls/sys_pipe.o |
---|
153 | |
---|
154 | SYS_OBJS_2 = build/syscalls/sys_chdir.o \ |
---|
155 | build/syscalls/sys_mkdir.o \ |
---|
156 | build/syscalls/sys_mkfifo.o \ |
---|
157 | build/syscalls/sys_opendir.o \ |
---|
158 | build/syscalls/sys_readdir.o \ |
---|
159 | build/syscalls/sys_closedir.o \ |
---|
160 | build/syscalls/sys_getcwd.o \ |
---|
161 | build/syscalls/sys_isatty.o \ |
---|
162 | build/syscalls/sys_alarm.o \ |
---|
163 | build/syscalls/sys_rmdir.o |
---|
164 | |
---|
165 | SYS_OBJS_3 = build/syscalls/sys_utls.o \ |
---|
166 | build/syscalls/sys_chmod.o \ |
---|
167 | build/syscalls/sys_signal.o \ |
---|
168 | build/syscalls/sys_timeofday.o \ |
---|
169 | build/syscalls/sys_kill.o \ |
---|
170 | build/syscalls/sys_getpid.o \ |
---|
171 | build/syscalls/sys_fork.o \ |
---|
172 | build/syscalls/sys_exec.o \ |
---|
173 | build/syscalls/sys_stat.o \ |
---|
174 | build/syscalls/sys_wait.o |
---|
175 | |
---|
176 | SYS_OBJS_4 = build/syscalls/sys_get_config.o \ |
---|
177 | build/syscalls/sys_get_core.o \ |
---|
178 | build/syscalls/sys_get_cycle.o \ |
---|
179 | build/syscalls/sys_display.o \ |
---|
180 | build/syscalls/sys_place_fork.o \ |
---|
181 | build/syscalls/sys_thread_sleep.o \ |
---|
182 | build/syscalls/sys_thread_wakeup.o \ |
---|
183 | build/syscalls/sys_trace.o \ |
---|
184 | build/syscalls/sys_fg.o \ |
---|
185 | build/syscalls/sys_is_fg.o |
---|
186 | |
---|
187 | SYS_OBJS_5 = build/syscalls/sys_exit.o |
---|
188 | |
---|
189 | VFS_OBJS = build/fs/vfs.o \ |
---|
190 | build/fs/fatfs.o \ |
---|
191 | build/fs/devfs.o \ |
---|
192 | build/fs/ramfs.o |
---|
193 | |
---|
194 | # List of directories to be searched for included files |
---|
195 | # when compiling for kernel.elf generation |
---|
196 | KERNEL_INCLUDE = -I. \ |
---|
197 | -Ikern \ |
---|
198 | -Idevices \ |
---|
199 | -Isyscalls \ |
---|
200 | -I$(SHARED_INCLUDE) \ |
---|
201 | -I$(HAL_ARCH)/drivers \ |
---|
202 | -Isyscalls \ |
---|
203 | -Ilibk \ |
---|
204 | -Imm \ |
---|
205 | -Ifs \ |
---|
206 | -I../tools/arch_info \ |
---|
207 | -I$(HAL)/generic \ |
---|
208 | -I$(HAL_ARCH)/core \ |
---|
209 | -I.. |
---|
210 | |
---|
211 | # Rule to generate kernel.elf. |
---|
212 | compile: dirs \ |
---|
213 | build/kernel.elf |
---|
214 | |
---|
215 | # Rule to create the build directories. |
---|
216 | dirs: |
---|
217 | @mkdir -p build |
---|
218 | @mkdir -p build/kern |
---|
219 | @mkdir -p build/hal |
---|
220 | @mkdir -p build/devices |
---|
221 | @mkdir -p build/mm |
---|
222 | @mkdir -p build/libk |
---|
223 | @mkdir -p build/drivers |
---|
224 | @mkdir -p build/fs |
---|
225 | @mkdir -p build/syscalls |
---|
226 | |
---|
227 | |
---|
228 | ############################## |
---|
229 | # rules to compile the drivers and hal |
---|
230 | $(HAL_ARCH)/build/%: |
---|
231 | $(MAKE) -C $(HAL_ARCH) |
---|
232 | |
---|
233 | ####################################### |
---|
234 | # Rules to generate kernel/kern objects |
---|
235 | build/kern/%.o: kern/%.c \ |
---|
236 | kern/%.h \ |
---|
237 | kernel_config.h \ |
---|
238 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
239 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
240 | |
---|
241 | |
---|
242 | ###################################### |
---|
243 | # Rules to generate kernel/dev objects |
---|
244 | build/devices/%.o: devices/%.c \ |
---|
245 | devices/%.h \ |
---|
246 | kernel_config.h \ |
---|
247 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
248 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
249 | |
---|
250 | ##################################### |
---|
251 | # Rules to generate kernel/mm objects |
---|
252 | build/mm/%.o: mm/%.c \ |
---|
253 | mm/%.h \ |
---|
254 | kernel_config.h \ |
---|
255 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
256 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
257 | |
---|
258 | ####################################### |
---|
259 | # Rules to generate kernel/libk objects |
---|
260 | build/libk/%.o: libk/%.c \ |
---|
261 | libk/%.h \ |
---|
262 | kernel_config.h \ |
---|
263 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
264 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
265 | |
---|
266 | ########################################### |
---|
267 | # Rules to generate kernel/syscalls objects |
---|
268 | build/syscalls/%.o: syscalls/%.c \ |
---|
269 | syscalls/syscalls.h \ |
---|
270 | kernel_config.h \ |
---|
271 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
272 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
273 | |
---|
274 | ####################################### |
---|
275 | # Rules to generate kernel/fs objects |
---|
276 | build/fs/%.o: fs/%.c \ |
---|
277 | fs/%.h \ |
---|
278 | kernel_config.h \ |
---|
279 | $(HAL_ARCH)/core/hal_kernel_types.h |
---|
280 | $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< |
---|
281 | |
---|
282 | ############################## |
---|
283 | # Rule to generate kernel.elf |
---|
284 | build/kernel.elf: $(KERN_OBJS) \ |
---|
285 | $(HAL_OBJS_0) \ |
---|
286 | $(HAL_OBJS_1) \ |
---|
287 | $(DEV_OBJS) \ |
---|
288 | $(MM_OBJS) \ |
---|
289 | $(LIBK_OBJS) \ |
---|
290 | $(DRIVERS_OBJS) \ |
---|
291 | $(VFS_OBJS) \ |
---|
292 | $(SYS_OBJS_0) \ |
---|
293 | $(SYS_OBJS_1) \ |
---|
294 | $(SYS_OBJS_2) \ |
---|
295 | $(SYS_OBJS_3) \ |
---|
296 | $(SYS_OBJS_4) \ |
---|
297 | $(SYS_OBJS_5) \ |
---|
298 | $(HAL_ARCH)/kernel.ld |
---|
299 | $(LD) -o $@ -T $(HAL_ARCH)/kernel.ld $(LIBGCC) \ |
---|
300 | $(KERN_OBJS) $(HAL_OBJS) $(DEV_OBJS) $(MM_OBJS) \ |
---|
301 | $(LIBK_OBJS) $(DRIVERS_OBJS) $(VFS_OBJS) \ |
---|
302 | $(SYS_OBJS_0) $(SYS_OBJS_1) $(SYS_OBJS_2) \ |
---|
303 | $(SYS_OBJS_3) $(SYS_OBJS_4) $(SYS_OBJS_5) -lgcc |
---|
304 | $(DU) -D $@ > $@.txt |
---|
305 | |
---|
306 | clean: |
---|
307 | rm -rf build/* |
---|