You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
138 lines
3.0 KiB
138 lines
3.0 KiB
project(
|
|
'freywaros',
|
|
'c',
|
|
default_options: [
|
|
'warning_level=2',
|
|
'c_std=c11',
|
|
],
|
|
version: '0.1.0',
|
|
)
|
|
|
|
run_target(
|
|
'compdb',
|
|
command: ['ninja', '-C', meson.project_build_root(), '-t', 'compdb'],
|
|
)
|
|
|
|
nasm = find_program('nasm')
|
|
|
|
custom_target(
|
|
'boot',
|
|
input: 'src/mbr.asm',
|
|
output: 'mbr.bin',
|
|
command: [nasm, '-f', 'bin', '-l', 'mbr.lst', '@INPUT@', '-o', '@OUTPUT@'],
|
|
build_by_default: true,
|
|
)
|
|
|
|
custom_target(
|
|
'bootloader',
|
|
input: 'src/bootloader.asm',
|
|
output: 'bootloader.bin',
|
|
command: [nasm, '-f', 'bin', '-l', 'bootloader.lst', '@INPUT@', '-o', '@OUTPUT@'],
|
|
build_by_default: true,
|
|
)
|
|
|
|
kernel_entry_o = custom_target(
|
|
'kernel_entry',
|
|
input: 'src/kernel/kernel_entry.asm',
|
|
output: 'kernel_entry.o',
|
|
command: [nasm, '-f', 'elf64', '@INPUT@', '-o', '@OUTPUT@'],
|
|
)
|
|
|
|
syscall_o = custom_target('syscall',
|
|
input: 'src/kernel/syscall.asm',
|
|
output: 'syscall.o',
|
|
command: [nasm, '-f', 'elf64', '@INPUT@', '-o', '@OUTPUT@'],
|
|
)
|
|
|
|
cc = meson.get_compiler('c')
|
|
|
|
kernel_sources = files(
|
|
'src/kernel/app/cat.c',
|
|
'src/kernel/app/ls.c',
|
|
'src/kernel/app/terminal.c',
|
|
'src/kernel/ata.c',
|
|
'src/kernel/fat16.c',
|
|
'src/kernel/fs.c',
|
|
'src/kernel/gdt.c',
|
|
'src/kernel/idt.c',
|
|
'src/kernel/kernel.c',
|
|
'src/kernel/keyboard.c',
|
|
'src/kernel/memory.c',
|
|
'src/kernel/panic.c',
|
|
'src/kernel/path.c',
|
|
'src/kernel/pic.c',
|
|
'src/kernel/process.c',
|
|
'src/kernel/syscall.c',
|
|
'src/kernel/tss.c',
|
|
'src/kernel/vga.c',
|
|
'src/lib/memory.c',
|
|
'src/lib/string.c',
|
|
)
|
|
|
|
kernel_elf = executable(
|
|
'kernel.elf',
|
|
sources: [kernel_entry_o, syscall_o, kernel_sources],
|
|
c_args: [
|
|
'-ffreestanding',
|
|
'-nostdlib',
|
|
'-nostartfiles',
|
|
'-mno-red-zone',
|
|
'-mgeneral-regs-only',
|
|
'-mcmodel=kernel',
|
|
'-Wno-unused-command-line-argument',
|
|
'-Wconversion',
|
|
'-DKERNEL="yes"',
|
|
'-DVERSION="' + meson.project_version() + '"',
|
|
],
|
|
link_args: [
|
|
'-T', meson.project_source_root() / 'src/kernel/linker.ld',
|
|
'-nostdlib',
|
|
],
|
|
link_depends: 'src/kernel/linker.ld',
|
|
)
|
|
|
|
custom_target(
|
|
'kernel_bin',
|
|
input: kernel_elf,
|
|
output: 'kernel.bin',
|
|
command: ['objcopy', '-O', 'binary', '@INPUT@', '@OUTPUT@'],
|
|
build_by_default: true,
|
|
)
|
|
|
|
hello_start = custom_target(
|
|
'hello_start',
|
|
input: 'src/user/start.asm',
|
|
output: 'hello_start.o',
|
|
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
|
)
|
|
|
|
hello_syscall = custom_target(
|
|
'hello_syscall',
|
|
input: 'src/user/syscall.asm',
|
|
output: 'hello_syscall.o',
|
|
command: [nasm, '-f', 'elf64', '-o', '@OUTPUT@', '@INPUT@'],
|
|
)
|
|
|
|
hello_elf = executable(
|
|
'hello.elf',
|
|
sources: [hello_start, hello_syscall, 'src/user/app/hello/hello.c'],
|
|
c_args: [
|
|
'-ffreestanding',
|
|
'-nostdlib',
|
|
'-fno-stack-protector',
|
|
'-mcmodel=large',
|
|
],
|
|
link_args: [
|
|
'-T', meson.project_source_root() / 'src/user/linker.ld',
|
|
'-nostdlib',
|
|
],
|
|
link_depends: 'src/user/linker.ld',
|
|
)
|
|
|
|
custom_target(
|
|
'hello_bin',
|
|
input: hello_elf,
|
|
output: 'hello.bin',
|
|
command: ['objcopy', '-O', 'binary', '@INPUT@', '@OUTPUT@'],
|
|
build_by_default: true,
|
|
)
|
|
|