-
-
Notifications
You must be signed in to change notification settings - Fork 49
/
meson.build
103 lines (96 loc) · 3.85 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
## Experimetal meson build system for dinit
project(
'dinit',
'cpp',
version : run_command('grep', '^VERSION=', 'build/version.conf',
check: true).stdout().strip().split('=')[1],
license : 'Apache-2.0',
meson_version : '>= 0.61.0',
default_options : [
'cpp_std=c++11',
'optimization=s',
'debug=false'
]
)
## Import variables from build/version.conf
version_conf = import('keyval').load('build/version.conf')
## General Defines
compiler = meson.get_compiler('cpp')
mconfig_data = configuration_data()
version = meson.project_version()
platform = host_machine.system()
month = version_conf.get('MONTH')
year = version_conf.get('YEAR')
build_shutdown = get_option('build-shutdown')
shutdown_prefix = get_option('shutdown-prefix')
dinit_control_socket_path = get_option('dinit-control-socket-path')
unit_tests = get_option('unit-tests')
igr_tests = get_option('igr-tests')
fuzzer = get_option('fuzzer')
man_pages = get_option('man-pages')
support_cgroups = get_option('support-cgroups')
support_capabilities = get_option('support-capabilities')
support_ioprio = get_option('support-ioprio')
support_oom_adj = get_option('support-oom-adj')
use_utmpx = get_option('use-utmpx')
use_initgroups = get_option('use-initgroups')
default_auto_restart = get_option('default-auto-restart')
default_start_timeout = get_option('default-start-timeout').to_string()
default_stop_timeout = get_option('default-stop-timeout').to_string()
# We have custom sbindir for install programs (/sbin instead of /usr/sbin/ by default)
# By default: Prefix = /usr
# By default: Sbin = /sbin
# By default: you find dinit on /sbin/dinit
# Note: Dinit dont follow Meson's default sbindir; Use dinit-sbindir option instead!
prefix = get_option('prefix')
sbindir = get_option('dinit-sbindir')
mandir = get_option('mandir')
## If Meson's default sbindir is modifed; Warn users about it:
if get_option('sbindir') != 'sbin'
warning('It appears that "sbindir" has been set/modified. Dinit\'s build doesn\'t use the "sbindir" option. Please use "dinit-sbindir" option instead!')
endif
## Use -lrt?
# We need to pass -lrt to c++ linker on FreeBSD. see BUILD_MESON
if platform == 'freebsd' and compiler.has_link_argument('-lrt')
add_project_link_arguments('-lrt', language : 'cpp')
endif
## Dependencies
libcap_dep = dependency('libcap', required: support_capabilities)
## Prepare mconfig.h
mconfig_data.set_quoted('DINIT_VERSION', version)
mconfig_data.set_quoted('SYSCONTROLSOCKET', dinit_control_socket_path)
mconfig_data.set_quoted('SBINDIR', sbindir)
mconfig_data.set_quoted('SHUTDOWN_PREFIX', shutdown_prefix)
mconfig_data.set('DEFAULT_AUTO_RESTART', default_auto_restart)
mconfig_data.set('DEFAULT_START_TIMEOUT', default_start_timeout)
mconfig_data.set('DEFAULT_STOP_TIMEOUT', default_stop_timeout)
mconfig_data.set10('USE_INITGROUPS', use_initgroups)
mconfig_data.set10('SUPPORT_CGROUPS', support_cgroups.auto() and platform == 'linux' or support_cgroups.enabled())
mconfig_data.set10('SUPPORT_CAPABILITIES', libcap_dep.found() and not support_capabilities.disabled())
mconfig_data.set10('SUPPORT_IOPRIO', support_ioprio.auto() and platform == 'linux' or support_ioprio.enabled())
mconfig_data.set10('SUPPORT_OOM_ADJ', support_oom_adj.auto() and platform == 'linux' or support_oom_adj.enabled())
if use_utmpx.enabled() or (use_utmpx.auto() and compiler.has_header_symbol('utmpx.h', '_PATH_UTMPX') and
compiler.has_header_symbol('utmpx.h', '_PATH_WTMPX'))
mconfig_data.set('USE_UTMPX', '1')
else
mconfig_data.set('USE_UTMPX', '0')
endif
configure_file(
input : 'build/mconfig.mesontemplate',
output : 'mconfig.h',
configuration : mconfig_data
)
## Outputs
subdir('src')
if unit_tests
subdir('src/tests/')
endif
if unit_tests or fuzzer
subdir('src/tests/cptests/')
endif
if igr_tests
subdir('src/igr-tests/')
endif
if man_pages
subdir('doc/manpages/')
endif