2021-08-22 23:39:30 +05:30
|
|
|
project('OpenRC', 'c',
|
2021-09-08 02:46:51 +05:30
|
|
|
version : '0.44',
|
2021-08-22 23:39:30 +05:30
|
|
|
license: 'BSD-2',
|
|
|
|
default_options : [
|
|
|
|
'c_std=c99',
|
2021-12-31 22:26:42 +05:30
|
|
|
'prefix=/usr',
|
2021-08-22 23:39:30 +05:30
|
|
|
'warning_level=3',
|
|
|
|
],
|
2022-04-17 01:43:08 +05:30
|
|
|
meson_version : '>=0.53.2')
|
2021-08-22 23:39:30 +05:30
|
|
|
|
|
|
|
cc = meson.get_compiler('c')
|
2021-11-29 00:05:29 +05:30
|
|
|
fs = import('fs')
|
2021-08-22 23:39:30 +05:30
|
|
|
|
|
|
|
audit_dep = dependency('audit', required : get_option('audit'))
|
|
|
|
if audit_dep.found()
|
|
|
|
cc_audit_flags = '-DHAVE_AUDIT'
|
2021-12-25 00:03:00 +05:30
|
|
|
else
|
2021-08-22 23:39:30 +05:30
|
|
|
cc_audit_flags = []
|
2021-12-25 00:03:00 +05:30
|
|
|
endif
|
2021-08-22 23:39:30 +05:30
|
|
|
|
|
|
|
if get_option('branding') != ''
|
|
|
|
cc_branding_flags = '-DBRANDING=' + get_option('branding')
|
|
|
|
else
|
|
|
|
cc_branding_flags = []
|
|
|
|
endif
|
|
|
|
|
|
|
|
libname = get_option('libdir').split('/')[-1]
|
|
|
|
|
|
|
|
option_local_prefix = get_option('local_prefix')
|
|
|
|
if option_local_prefix == ''
|
|
|
|
local_prefix = get_option('prefix') / 'usr' / 'local'
|
|
|
|
else
|
|
|
|
local_prefix = option_local_prefix
|
|
|
|
endif
|
|
|
|
|
|
|
|
option_os = get_option('os')
|
|
|
|
if option_os == ''
|
|
|
|
uname = find_program('uname')
|
|
|
|
r = run_command(uname, '-s')
|
|
|
|
os = r.stdout().strip()
|
|
|
|
os = '-'.join(os.split('/'))
|
|
|
|
else
|
|
|
|
os = option_os
|
|
|
|
endif
|
|
|
|
|
2021-12-31 06:15:39 +05:30
|
|
|
if os != 'Linux'
|
|
|
|
kvm_dep = cc.find_library('kvm', required: true)
|
|
|
|
else
|
|
|
|
kvm_dep = []
|
|
|
|
endif
|
|
|
|
|
2021-10-09 03:09:21 +05:30
|
|
|
pam_dep = dependency('pam', required: false)
|
2021-10-08 21:16:42 +05:30
|
|
|
if not pam_dep.found()
|
2021-10-09 03:09:21 +05:30
|
|
|
pam_dep = cc.find_library('pam', required: false)
|
2021-10-08 21:16:42 +05:30
|
|
|
endif
|
2021-11-07 06:07:37 +05:30
|
|
|
if pam_dep.found() and get_option('pam')
|
2021-08-22 23:39:30 +05:30
|
|
|
cc_pam_flags = '-DHAVE_PAM'
|
|
|
|
else
|
|
|
|
cc_pam_flags = []
|
|
|
|
endif
|
|
|
|
|
2021-10-09 03:09:21 +05:30
|
|
|
if not pam_dep.found() and get_option('pam')
|
|
|
|
error('Pam was requested but could not be located')
|
2021-12-25 00:03:00 +05:30
|
|
|
endif
|
2021-10-09 03:09:21 +05:30
|
|
|
|
2021-06-13 22:56:24 +05:30
|
|
|
cap_dep = dependency('libcap', version: '>=2.33', required : get_option('capabilities'))
|
|
|
|
if cap_dep.found()
|
|
|
|
cc_cap_flags = '-DHAVE_CAP'
|
|
|
|
else
|
|
|
|
cc_cap_flags = []
|
|
|
|
endif
|
|
|
|
|
2021-08-22 23:39:30 +05:30
|
|
|
option_pkg_prefix = get_option('pkg_prefix')
|
|
|
|
if option_pkg_prefix == ''
|
|
|
|
if os == 'Dragonfly' or os == 'FreeBSD'
|
|
|
|
pkg_prefix = '/usr/local'
|
|
|
|
elif os == 'GNU' or os == 'GNU-kFreeBSD' or os == 'Linux'
|
|
|
|
pkg_prefix = '/usr'
|
|
|
|
elif os == 'NetBSD'
|
|
|
|
pkg_prefix = '/usr/pkg'
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
pkg_prefix = option_pkg_prefix
|
|
|
|
endif
|
|
|
|
|
2021-09-07 01:52:28 +05:30
|
|
|
if get_option('split-usr') == 'auto'
|
|
|
|
split_usr = run_command('test', '-L', '/bin').returncode() != 0
|
|
|
|
else
|
|
|
|
split_usr = get_option('split-usr') == 'true'
|
2021-08-22 23:39:30 +05:30
|
|
|
endif
|
2021-09-07 01:52:28 +05:30
|
|
|
|
2021-09-21 09:19:05 +05:30
|
|
|
rootprefix = get_option('rootprefix')
|
2021-11-29 00:05:29 +05:30
|
|
|
rootprefix_default = fs.is_symlink('/bin') ? '/usr' : '/'
|
2021-09-21 09:19:05 +05:30
|
|
|
if rootprefix == ''
|
|
|
|
rootprefix = rootprefix_default
|
|
|
|
endif
|
2021-09-07 01:52:28 +05:30
|
|
|
|
2021-09-07 01:00:30 +05:30
|
|
|
bindir = rootprefix / get_option('bindir')
|
|
|
|
libdir = rootprefix / get_option('libdir')
|
2021-09-21 09:19:05 +05:30
|
|
|
libexecdir = get_option('libexecdir')
|
|
|
|
if os == 'Linux' and libexecdir == 'libexec'
|
|
|
|
libexecdir = 'lib'
|
2021-09-07 05:22:54 +05:30
|
|
|
endif
|
2021-09-21 09:19:05 +05:30
|
|
|
libexecdir = rootprefix / libexecdir
|
2021-08-22 23:39:30 +05:30
|
|
|
rc_libexecdir = libexecdir / 'rc'
|
2021-09-21 23:04:22 +05:30
|
|
|
rc_bindir = rc_libexecdir / 'bin'
|
|
|
|
rc_sbindir = rc_libexecdir / 'sbin'
|
2021-12-30 03:27:04 +05:30
|
|
|
rc_shdir = rc_libexecdir / 'sh'
|
2021-09-07 01:00:30 +05:30
|
|
|
sbindir = rootprefix / get_option('sbindir')
|
2021-12-31 22:31:55 +05:30
|
|
|
pamdir = get_option('sysconfdir') / 'pam.d'
|
2021-08-22 23:39:30 +05:30
|
|
|
|
2021-11-22 16:00:36 +05:30
|
|
|
crypt_dep = []
|
2021-11-20 17:36:37 +05:30
|
|
|
|
2021-08-22 23:39:30 +05:30
|
|
|
selinux_dep = dependency('libselinux', required : get_option('selinux'))
|
2021-11-20 17:35:56 +05:30
|
|
|
pam_misc_dep = []
|
2021-08-22 23:39:30 +05:30
|
|
|
if selinux_dep.found()
|
|
|
|
cc_selinux_flags = '-DHAVE_SELINUX'
|
2021-10-09 03:09:21 +05:30
|
|
|
if pam_dep.found() and get_option('pam')
|
|
|
|
pam_misc_dep = dependency('pam_misc', required: false)
|
2021-10-08 21:16:42 +05:30
|
|
|
if not pam_misc_dep.found()
|
2021-10-09 03:09:21 +05:30
|
|
|
pam_misc_dep = cc.find_library('pam_misc', required: false)
|
|
|
|
endif
|
|
|
|
if not pam_misc_dep.found() and get_option('pam')
|
|
|
|
error('Pam was requested but could not be located')
|
2021-10-08 21:16:42 +05:30
|
|
|
endif
|
2021-11-22 16:00:36 +05:30
|
|
|
else
|
2021-11-25 01:12:01 +05:30
|
|
|
crypt_dep = dependency('libcrypt', required : false)
|
|
|
|
if not crypt_dep.found()
|
|
|
|
crypt_dep = cc.find_library('crypt', required : true)
|
|
|
|
endif
|
2021-10-03 02:16:12 +05:30
|
|
|
endif
|
|
|
|
else
|
2021-08-22 23:39:30 +05:30
|
|
|
cc_selinux_flags = []
|
|
|
|
endif
|
|
|
|
|
|
|
|
termcap = get_option('termcap')
|
|
|
|
if termcap != ''
|
|
|
|
termcap_dep = dependency(termcap)
|
|
|
|
termcap_flags = '-DHAVE_TERMCAP'
|
|
|
|
else
|
|
|
|
termcap_dep = []
|
|
|
|
termcap_flags = []
|
|
|
|
endif
|
|
|
|
|
|
|
|
if get_option('buildtype').startswith('debug')
|
|
|
|
cc_debug_flags = ['-DRC_DEBUG']
|
|
|
|
else
|
|
|
|
cc_debug_flags = []
|
|
|
|
endif
|
|
|
|
|
|
|
|
if os == 'Linux' or os == 'GNU-kFreeBSD'
|
|
|
|
cc_os_flags = ['-D_DEFAULT_SOURCE']
|
|
|
|
elif os == 'FreeBSD'
|
|
|
|
cc_os_flags = ['-D_BSD_SOURCE']
|
|
|
|
elif os == 'GNU'
|
|
|
|
cc_os_flags = ['-D_DEFAULT_SOURCE', '-DMAXPATHLEN=4096', '-DPATH_MAX=4096']
|
2021-12-25 00:03:00 +05:30
|
|
|
endif
|
2021-08-22 23:39:30 +05:30
|
|
|
|
|
|
|
# Try and use some good cc flags if we're building from git. We don't use
|
|
|
|
# -pedantic as it will warn about our perfectly valid use of %m in our logger.
|
|
|
|
# We should be using -Wredundant-decls, but our library hidden proto stuff gives
|
|
|
|
# loads of warnings. I don't fully understand it (the hidden proto, not the
|
|
|
|
# warning) so we just silence the warning.
|
|
|
|
cc_warning_flags_test = [
|
|
|
|
'-Wcast-align',
|
|
|
|
'-Wcast-qual',
|
|
|
|
'-Wdeclaration-after-statement',
|
|
|
|
'-Wformat=2',
|
|
|
|
'-Winline',
|
|
|
|
'-Wmissing-declarations',
|
|
|
|
'-Wmissing-format-attribute',
|
|
|
|
'-Wmissing-noreturn',
|
|
|
|
'-Wmissing-prototypes',
|
|
|
|
'-Wnested-externs',
|
|
|
|
'-Wpointer-arith',
|
|
|
|
'-Wsequence-point',
|
|
|
|
'-Wshadow',
|
|
|
|
'-Wwrite-strings',
|
|
|
|
'-Werror=implicit-function-declaration',
|
|
|
|
]
|
|
|
|
cc_warning_flags = cc.get_supported_arguments(cc_warning_flags_test)
|
|
|
|
cc_flags = [cc_debug_flags, cc_os_flags, cc_warning_flags]
|
|
|
|
add_project_arguments(cc_flags, language : 'c')
|
|
|
|
|
2022-03-31 11:55:35 +05:30
|
|
|
# Meson's has_function_attribute doesn't know about GCC's extended
|
|
|
|
# version (with arguments), so we have to build a test program instead.
|
|
|
|
malloc_attribute_test = '''#include<stdlib.h>
|
|
|
|
__attribute__ ((malloc (free, 1)))
|
|
|
|
int func() { return 0; }
|
|
|
|
'''
|
|
|
|
if cc.compiles(malloc_attribute_test, name : 'malloc attribute with arguments')
|
|
|
|
add_project_arguments('-DHAVE_MALLOC_EXTENDED_ATTRIBUTE', language: 'c')
|
|
|
|
endif
|
|
|
|
|
2022-04-06 21:21:55 +05:30
|
|
|
incdir = include_directories('src/shared')
|
2021-08-22 23:39:30 +05:30
|
|
|
einfo_incdir = include_directories('src/libeinfo')
|
|
|
|
rc_incdir = include_directories('src/librc')
|
|
|
|
|
|
|
|
init_d_conf_data = configuration_data()
|
|
|
|
init_d_conf_data.set('SBINDIR', sbindir)
|
|
|
|
init_d_conf_data.set('PKG_PREFIX', pkg_prefix)
|
|
|
|
init_d_conf_data.set('SYSCONFDIR', get_option('sysconfdir'))
|
|
|
|
|
|
|
|
dl_dep = cc.find_library('dl', required: false)
|
|
|
|
util_dep = cc.find_library('util', required: false)
|
|
|
|
|
2021-12-30 23:19:23 +05:30
|
|
|
subdir('bash-completion')
|
2021-08-22 23:39:30 +05:30
|
|
|
subdir('conf.d')
|
|
|
|
subdir('etc')
|
|
|
|
subdir('init.d')
|
|
|
|
subdir('local.d')
|
|
|
|
subdir('man')
|
|
|
|
subdir('pkgconfig')
|
|
|
|
subdir('sh')
|
|
|
|
subdir('src')
|
|
|
|
subdir('support')
|
|
|
|
subdir('sysctl.d')
|
2022-04-17 01:43:08 +05:30
|
|
|
subdir('test')
|
2021-12-30 23:19:23 +05:30
|
|
|
subdir('zsh-completion')
|
2021-08-22 23:39:30 +05:30
|
|
|
|
|
|
|
meson.add_install_script('tools/meson_runlevels.sh',
|
|
|
|
os,
|
|
|
|
get_option('newnet') ? 'yes' : 'no',
|
|
|
|
rc_libexecdir,
|
2021-09-08 22:29:25 +05:30
|
|
|
get_option('sysconfdir'),
|
|
|
|
get_option('sysvinit') ? 'yes' : 'no')
|
2021-08-22 23:39:30 +05:30
|
|
|
meson.add_install_script('tools/meson_final.sh',
|
|
|
|
rc_libexecdir,
|
|
|
|
os)
|