metal-cos/sys/SConscript

141 lines
3.1 KiB
Python

import sys
Import('env')
kern_env = env.Clone()
src = [ ]
src_amd64 = [
# Multiboot requires multiboot.S to be the first file
"amd64/multiboot.S",
"amd64/mbentry.c",
# AMD64
"amd64/debug.c",
"amd64/disasm.c",
"amd64/ioapic.c",
"amd64/irq.c",
"amd64/lapic.c",
"amd64/machine.c",
"amd64/mp.c",
"amd64/mpboot.S",
"amd64/pci.c",
"amd64/pmap.c",
"amd64/support.S",
"amd64/switch.S",
"amd64/thread.c",
"amd64/time.c",
"amd64/trap.c",
"amd64/trapentry.S",
# Devices
"dev/x86/debugcons.c",
"dev/x86/ps2.c",
"dev/x86/rtc.c",
"dev/x86/sercons.c",
"dev/x86/vgacons.c",
]
src_arm64 = [
# Multiboot requires multiboot.S to be the first file
"arm64/locore.S",
"arm64/mbentry.c",
# ARM64
"arm64/debug.c",
"arm64/disasm.c",
"arm64/trap.c",
"arm64/machine.c",
"arm64/mp.c",
"arm64/pci.c",
"arm64/pmap.c",
"arm64/support.S",
"arm64/switch.S",
"arm64/thread.c",
"arm64/timer.c",
"arm64/trapentry.S",
"arm64/pdcache.c",
"arm64/gic.c",
# Devices
"dev/arm64/uart.c",
# Metal
"arm64/metal.c",
"arm64/paging.c",
"arm64/mrt/init.c",
"arm64/mrt/paging.c",
]
src_common = [
"kern/copy.c",
"kern/critical.c",
"kern/bufcache.c",
"kern/cv.c",
"kern/debug.c",
"kern/disk.c",
"kern/handle.c",
"kern/ktime.c",
"kern/ktimer.c",
"kern/libc.c",
"kern/loader.c",
"kern/mutex.c",
"kern/nic.c",
"kern/palloc.c",
"kern/printf.c",
"kern/process.c",
"kern/sched.c",
"kern/semaphore.c",
"kern/sga.c",
"kern/slab.c",
"kern/spinlock.c",
"kern/syscall.c",
"kern/sysctl.c",
"kern/thread.c",
"kern/vfs.c",
"kern/vfsuio.c",
"kern/waitchannel.c",
"kern/xmem.c",
"dev/ahci.c",
"dev/console.c",
"dev/e1000.c",
"dev/pci.c",
"dev/ide.c",
"fs/o2fs/o2fs.c",
]
src_contrib = [
'contrib/libfdt/fdt.c',
'contrib/libfdt/fdt_addresses.c',
'contrib/libfdt/fdt_check.c',
'contrib/libfdt/fdt_empty_tree.c',
'contrib/libfdt/fdt_overlay.c',
'contrib/libfdt/fdt_ro.c',
'contrib/libfdt/fdt_rw.c',
'contrib/libfdt/fdt_strerror.c',
'contrib/libfdt/fdt_sw.c',
'contrib/libfdt/fdt_wip.c',
]
if (env["ARCH"] == "amd64"):
src.append(src_amd64)
ldscript = "#sys/amd64/kernel.lds"
elif (env["ARCH"] == "arm64"):
src.append(src_arm64)
ldscript = "#sys/arm64/kernel.lds"
src.append(src_common)
src.append(src_contrib)
kern_env.Append(LINKFLAGS = ['-T', ldscript[1:], '-nostdlib'])
kern_env.Append(CPPFLAGS = ['-D_KERNEL'])
kern_env.Append(CPPFLAGS = ['-ffreestanding', '-fno-builtin', '-nostdinc',
'-mno-red-zone', '-std=c2x', "-Wno-c2x-extensions"])
if env["ARCH"] == "amd64":
kern_env.Append(CPPFLAGS = ['-mno-mmx', '-mno-sse', '-mcmodel=large'])
# '-target', 'amd64-orion-eabi'
elif env["ARCH"] == "arm64":
kern_env.Append(CPPFLAGS = ['-mcmodel=large'])
kern_env.Append(CPPPATH = ['#build/include'])
kernel = kern_env.Program("castor", src)
Depends(kernel, ldscript)