NetBSD support: Initial build machinery.

Make kqueue/libepoll-shim detection independent of FreeBSD.

Signed-off-by: Nia Alarie <nia@NetBSD.org>
This commit is contained in:
nia 2022-08-06 10:48:21 +02:00
parent 60827b862e
commit e29469463b

View file

@ -19,6 +19,9 @@ cc_args = []
if host_machine.system() != 'freebsd' if host_machine.system() != 'freebsd'
cc_args += ['-D_POSIX_C_SOURCE=200809L'] cc_args += ['-D_POSIX_C_SOURCE=200809L']
endif endif
if host_machine.system() == 'netbsd'
cc_args += ['-D_NETBSD_SOURCE']
endif
add_project_arguments(cc_args, language: 'c') add_project_arguments(cc_args, language: 'c')
compiler_flags = [ compiler_flags = [
@ -41,12 +44,16 @@ endforeach
have_funcs = [ have_funcs = [
'accept4', 'accept4',
'mkostemp', 'mkostemp',
'posix_fallocate',
'prctl', 'prctl',
'memfd_create', 'memfd_create',
'mremap', 'mremap',
'strndup', 'strndup',
] ]
# NetBSD defines posix_fallocate(), but it's unimplemented for most file
# systems as of NetBSD 9.
if host_machine.system() != 'netbsd'
have_funcs += [ 'posix_fallocate' ]
endif
foreach f: have_funcs foreach f: have_funcs
config_h.set('HAVE_' + f.underscorify().to_upper(), cc.has_function(f)) config_h.set('HAVE_' + f.underscorify().to_upper(), cc.has_function(f))
endforeach endforeach
@ -69,8 +76,8 @@ endif
config_h.set10('HAVE_BROKEN_MSG_CMSG_CLOEXEC', have_broken_msg_cmsg_cloexec) config_h.set10('HAVE_BROKEN_MSG_CMSG_CLOEXEC', have_broken_msg_cmsg_cloexec)
if get_option('libraries') if get_option('libraries')
if host_machine.system() == 'freebsd' if cc.has_function('kqueue', prefix: '#include <sys/event.h>')
# When building for FreeBSD, epoll(7) is provided by a userspace # When building for BSD, epoll(7) is provided by a userspace
# wrapper around kqueue(2). # wrapper around kqueue(2).
epoll_dep = dependency('epoll-shim') epoll_dep = dependency('epoll-shim')
else else