meson.build (5321B)
1 project('swc', 'c', 2 version: '0.0', 3 meson_version: '>=1.7.99', 4 license: 'MIT', 5 default_options: [ 6 'c_std=c11', 7 'warning_level=1', 8 'default_library=both', 9 ], 10 ) 11 12 cc = meson.get_compiler('c') 13 os = host_machine.system() 14 pkg = import('pkgconfig') 15 wl = import('wayland') 16 17 add_project_arguments(cc.get_supported_arguments([ 18 '-fvisibility=hidden', 19 20 '-Werror=implicit-function-declaration', 21 '-Werror=implicit-int', 22 '-Werror=pointer-sign', 23 '-Werror=pointer-arith', 24 '-Wno-missing-braces', 25 ]) + [ 26 '-D_GNU_SOURCE', # Required for mkostemp 27 get_option('buildtype').startswith('debug') ? '-DENABLE_DEBUG=1' : [], 28 ], language: 'c') 29 30 requires = [ 31 dependency('wayland-server', version: '>=1.6.0'), 32 ] 33 requires_private = [ 34 dependency('pixman-1'), 35 dependency('wayland-protocols'), 36 dependency('wld'), 37 dependency('xkbcommon'), 38 ] 39 40 video_backend = get_option('video') 41 framebuffer_backend = get_option('fb') 42 # 'all' builds the drm and the framebuffer backends together, and swc picks 43 # one when it starts 44 with_drm = video_backend in ['drm', 'all'] 45 with_fb = video_backend in ['fb', 'all'] 46 drm = disabler() 47 if with_drm 48 if video_backend == 'drm' and framebuffer_backend != 'auto' 49 error('-Dfb applies only when -Dvideo=fb or -Dvideo=all') 50 endif 51 drm = dependency('libdrm') 52 requires_private += drm 53 add_project_arguments('-DENABLE_DRM=1', language: 'c') 54 endif 55 if with_fb 56 if framebuffer_backend == 'auto' 57 if os == 'linux' 58 framebuffer_backend = 'fbdev' 59 elif os == 'netbsd' or os == 'openbsd' 60 framebuffer_backend = 'wsdisplay' 61 else 62 error('Failed to determine framebuffer interface for ' + os) 63 endif 64 endif 65 66 add_project_arguments('-DENABLE_FB=1', language: 'c') 67 if framebuffer_backend == 'fbdev' 68 if os != 'linux' 69 error('The fbdev framebuffer interface is supported only on Linux') 70 endif 71 add_project_arguments([ 72 '-DENABLE_FBDEV=1', 73 '-DFBDEV_DEVICE="@0@"'.format(get_option('fbdev-device')), 74 ], language: 'c') 75 elif framebuffer_backend == 'wsdisplay' 76 if os != 'netbsd' and os != 'openbsd' 77 error('The wsdisplay framebuffer interface is supported only on NetBSD and OpenBSD') 78 endif 79 add_project_arguments([ 80 '-DENABLE_WSDISPLAY=1', 81 '-DWSDISPLAY_DEVICE="@0@"'.format(get_option('wsdisplay-device')), 82 ], language: 'c') 83 endif 84 endif 85 86 if video_backend != 'drm' and get_option('xwayland').enabled() 87 error('Xwayland requires the DRM video backend alone') 88 endif 89 xwayland = video_backend == 'drm' \ 90 ? dependency('xwayland', required: get_option('xwayland')) \ 91 : disabler() 92 xwayland_deps = [ 93 'xcb', 94 'xcb-composite', 95 'xcb-ewmh', 96 'xcb-icccm', 97 ] 98 if xwayland.found() 99 add_project_arguments('-DENABLE_XWAYLAND', language: 'c') 100 requires_private += xwayland 101 foreach dep : xwayland_deps 102 requires_private += dependency(dep, required: xwayland.found()) 103 endforeach 104 endif 105 106 input_backend = get_option('input') 107 if os == 'openbsd' and input_backend == 'libinput' 108 error('OpenBSD should use the wscons input backend until libopeninput is good enough') 109 endif 110 libinput = dependency('libinput', version: '>=0.4', required: input_backend == 'libinput') 111 112 if input_backend == 'auto' 113 if os == 'linux' 114 if not libinput.found() 115 error('libinput is required for the Linux input backend') 116 endif 117 input_backend = 'libinput' 118 elif os == 'netbsd' or os == 'openbsd' 119 input_backend = 'wscons' 120 else 121 error('Failed to determine input backend for ' + os) 122 endif 123 endif 124 125 if input_backend == 'libinput' 126 udev = dependency('libudev', required: get_option('udev')) 127 if udev.found() 128 add_project_arguments('-DENABLE_LIBUDEV', language: 'c') 129 endif 130 requires_private += [libinput, udev] 131 endif 132 133 # the nested backend replaces the display and the input devices at run 134 # time, so it rides along in any build. it feeds the libinput seat, the 135 # wscons one has no virtual input path 136 wayland_client = dependency('wayland-client', required: get_option('nested')) 137 have_nested = (wayland_client.found() and input_backend == 'libinput' 138 and cc.has_header('wld/wayland.h', dependencies: dependency('wld'))) 139 if get_option('nested').enabled() and not have_nested 140 error('The nested backend needs wayland-client, the libinput input backend, and wld built with Wayland support') 141 endif 142 if have_nested 143 add_project_arguments('-DENABLE_NESTED=1', language: 'c') 144 requires_private += wayland_client 145 endif 146 147 # the peer backend feeds the libinput seat, touch and all, and shares its 148 # screen through a memfd 149 have_peer = (not get_option('peer').disabled() and input_backend == 'libinput' 150 and cc.has_function('memfd_create', prefix: '#include <sys/mman.h>', args: '-D_GNU_SOURCE')) 151 if get_option('peer').enabled() and not have_peer 152 error('The peer backend needs the libinput input backend and memfd_create') 153 endif 154 if have_peer 155 add_project_arguments('-DENABLE_PEER=1', language: 'c') 156 endif 157 158 subdir('protocol') 159 subdir('cursor') 160 subdir('launch') 161 subdir('libswc') 162 163 if get_option('extra') 164 subdir('extra') 165 endif 166 167 if get_option('example') 168 subdir('example') 169 endif 170 171 summary({ 172 'Xwayland support': xwayland.found(), 173 'Nested backend': have_nested, 174 'Input backend': input_backend, 175 'Video backend': video_backend, 176 'Framebuffer interface': with_fb ? framebuffer_backend : 'n/a', 177 }, bool_yn: true)