1project( 2 'wayland', 'c', 3 version: '1.22.0', 4 license: 'MIT', 5 meson_version: '>= 0.56.0', 6 default_options: [ 7 'warning_level=2', 8 'buildtype=debugoptimized', 9 'c_std=c99', 10 ] 11) 12wayland_version = meson.project_version().split('.') 13 14config_h = configuration_data() 15config_h.set_quoted('PACKAGE', meson.project_name()) 16config_h.set_quoted('PACKAGE_VERSION', meson.project_version()) 17 18cc_args = [] 19if host_machine.system() != 'freebsd' 20 cc_args += ['-D_POSIX_C_SOURCE=200809L'] 21endif 22add_project_arguments(cc_args, language: 'c') 23 24compiler_flags = [ 25 '-Wno-unused-parameter', 26 '-Wstrict-prototypes', 27 '-Wmissing-prototypes', 28 '-fvisibility=hidden', 29] 30 31cc = meson.get_compiler('c') 32add_project_arguments( 33 cc.get_supported_arguments(compiler_flags), 34 language: 'c' 35) 36 37foreach h: [ 'sys/prctl.h', 'sys/procctl.h', 'sys/ucred.h' ] 38 config_h.set('HAVE_' + h.underscorify().to_upper(), cc.has_header(h)) 39endforeach 40 41have_funcs = [ 42 'accept4', 43 'mkostemp', 44 'posix_fallocate', 45 'prctl', 46 'memfd_create', 47 'mremap', 48 'strndup', 49] 50foreach f: have_funcs 51 config_h.set('HAVE_' + f.underscorify().to_upper(), cc.has_function(f)) 52endforeach 53config_h.set10('HAVE_XUCRED_CR_PID', cc.has_member('struct xucred', 'cr_pid', prefix : '#include <sys/ucred.h>')) 54have_broken_msg_cmsg_cloexec = false 55if host_machine.system() == 'freebsd' 56 have_broken_msg_cmsg_cloexec = not cc.compiles(''' 57#include <sys/param.h> /* To get __FreeBSD_version. */ 58#if __FreeBSD_version < 1300502 || \ 59 (__FreeBSD_version >= 1400000 && __FreeBSD_version < 1400006) 60/* 61 * FreeBSD had a broken implementation of MSG_CMSG_CLOEXEC between 2015 and 62 * 2021. Check if we are compiling against a version that includes the fix 63 * (https://cgit.freebsd.org/src/commit/?id=6ceacebdf52211). 64 */ 65#error "Broken MSG_CMSG_CLOEXEC" 66#endif 67''', name : 'MSG_CMSG_CLOEXEC works correctly') 68endif 69config_h.set10('HAVE_BROKEN_MSG_CMSG_CLOEXEC', have_broken_msg_cmsg_cloexec) 70 71if get_option('libraries') 72 if host_machine.system() == 'freebsd' 73 # When building for FreeBSD, epoll(7) is provided by a userspace 74 # wrapper around kqueue(2). 75 epoll_dep = dependency('epoll-shim') 76 else 77 # Otherwise, assume that epoll(7) is supported natively. 78 epoll_dep = [] 79 endif 80 ffi_dep = dependency('libffi') 81 82 decls = [ 83 { 'header': 'sys/signalfd.h', 'symbol': 'SFD_CLOEXEC' }, 84 { 'header': 'sys/timerfd.h', 'symbol': 'TFD_CLOEXEC' }, 85 { 'header': 'time.h', 'symbol': 'CLOCK_MONOTONIC' }, 86 ] 87 88 foreach d: decls 89 if not cc.has_header_symbol(d['header'], d['symbol'], dependencies: epoll_dep, args: cc_args) 90 error('@0@ is needed to compile Wayland libraries'.format(d['symbol'])) 91 endif 92 endforeach 93 94 rt_dep = [] 95 if not cc.has_function('clock_gettime', prefix: '#include <time.h>') 96 rt_dep = cc.find_library('rt') 97 if not cc.has_function('clock_gettime', prefix: '#include <time.h>', dependencies: rt_dep, args: cc_args) 98 error('clock_gettime not found') 99 endif 100 endif 101endif 102 103configure_file( 104 output: 'config.h', 105 configuration: config_h, 106) 107 108pkgconfig = import('pkgconfig') 109 110wayland_protocol_xml = files('protocol/wayland.xml') 111 112root_inc = include_directories('.') 113protocol_inc = include_directories('protocol') 114src_inc = include_directories('src') 115 116subdir('src') 117 118if get_option('libraries') 119 subdir('cursor') 120 subdir('egl') 121endif 122if get_option('tests') 123 subdir('tests') 124endif 125if get_option('documentation') 126 subdir('doc') 127endif 128 129if get_option('scanner') 130 install_data([ 131 'wayland-scanner.mk', 132 'protocol/wayland.xml', 133 'protocol/wayland.dtd', 134 ]) 135 136 install_data( 137 [ 'wayland-scanner.m4' ], 138 install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'aclocal'), 139 ) 140endif 141