121 lines
2.6 KiB
Meson
121 lines
2.6 KiB
Meson
project(
|
|
'zinnia',
|
|
license: 'ISC',
|
|
version: '0.1.0',
|
|
meson_version: '>=1.3.0',
|
|
default_options: [
|
|
'c_std=gnu23',
|
|
'werror=true',
|
|
'warning_level=2',
|
|
'strip=true',
|
|
],
|
|
)
|
|
|
|
if get_option('headers_only')
|
|
install_subdir('include/uapi', install_dir: get_option('includedir'))
|
|
pkg = import('pkgconfig')
|
|
pkg.generate(name: 'zinnia', description: 'Zinnia user API')
|
|
subdir_done()
|
|
endif
|
|
|
|
add_languages('c', native: false)
|
|
|
|
# Check if we're using a sane compiler.
|
|
c_compiler = meson.get_compiler('c')
|
|
|
|
# Check for LP64
|
|
assert(c_compiler.sizeof('short') == 2)
|
|
assert(c_compiler.sizeof('int') == 4)
|
|
assert(c_compiler.sizeof('long') == 8)
|
|
assert(c_compiler.sizeof('long long') == 8)
|
|
|
|
# We require a compiler that supports the GNU C dialect.
|
|
assert(c_compiler.has_define('__GNUC__'))
|
|
|
|
add_project_arguments(
|
|
'-Wno-unused',
|
|
'-Wno-unused-parameter',
|
|
'-fno-stack-protector',
|
|
'-ffunction-sections',
|
|
'-fdata-sections',
|
|
language: 'c',
|
|
)
|
|
|
|
add_project_link_arguments(
|
|
'-znoexecstack',
|
|
'-Wl,--gc-sections',
|
|
'-Wl,--build-id=none',
|
|
language: 'c',
|
|
)
|
|
|
|
common_includes = include_directories('include')
|
|
|
|
cfg = configuration_data()
|
|
cfg.set_quoted('ZINNIA_VERSION', meson.project_version())
|
|
cfg.set_quoted('ZINNIA_ARCH', target_machine.cpu_family())
|
|
cfg.set_quoted('ZINNIA_COMPILER_ID', c_compiler.get_id() + ' ' + c_compiler.version())
|
|
cfg.set_quoted('ZINNIA_LINKER_ID', c_compiler.get_linker_id())
|
|
|
|
# Parse kernel config
|
|
kv = import('keyval')
|
|
kconfig = kv.load(get_option('config_path'))
|
|
foreach k, v : kconfig
|
|
if v == 'y'
|
|
cfg.set10(k, true)
|
|
else
|
|
cfg.set(k, v)
|
|
endif
|
|
endforeach
|
|
|
|
kernel_c_args = [
|
|
'-ffreestanding',
|
|
'-nostdinc', # We provide our own headers.
|
|
'-fno-stack-protector',
|
|
'-fno-pie',
|
|
]
|
|
|
|
kernel_lds = meson.current_source_dir() / 'boot' / 'kernel.ld'
|
|
|
|
kernel_link_args = [
|
|
'-ffreestanding',
|
|
'-nostdlib',
|
|
'-static',
|
|
'-T' + kernel_lds,
|
|
]
|
|
|
|
kernel_includes = [
|
|
include_directories('arch' / target_machine.cpu_family() / 'include'),
|
|
]
|
|
|
|
kernel_sources = []
|
|
|
|
# Goes first so we can add arch-specific flags to drivers.
|
|
subdir('arch' / target_machine.cpu_family())
|
|
subdir('boot')
|
|
subdir('core')
|
|
|
|
# Device and file system drivers.
|
|
subdir('dev')
|
|
subdir('fs')
|
|
|
|
configure_file(
|
|
configuration: cfg,
|
|
output: 'config.h',
|
|
)
|
|
|
|
executable(
|
|
'zinnia',
|
|
include_directories: [
|
|
common_includes,
|
|
kernel_includes,
|
|
],
|
|
c_args: kernel_c_args,
|
|
link_args: kernel_link_args,
|
|
link_depends: kernel_lds,
|
|
sources: [
|
|
kernel_sources,
|
|
],
|
|
install: true,
|
|
install_dir: get_option('datadir') / 'zinnia',
|
|
)
|