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