main meson.build
  1project('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
 12cc = meson.get_compiler('c')
 13os = host_machine.system()
 14pkg = import('pkgconfig')
 15wl = import('wayland')
 16
 17add_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
 30requires = [
 31  dependency('wayland-server', version: '>=1.6.0'),
 32]
 33requires_private = [
 34  dependency('pixman-1'),
 35  dependency('wayland-protocols'),
 36  dependency('wld'),
 37  dependency('xkbcommon'),
 38]
 39
 40video_backend = get_option('video')
 41framebuffer_backend = get_option('fb')
 42drm = disabler()
 43if video_backend == 'drm'
 44  if framebuffer_backend != 'auto'
 45    error('-Dfb applies only when -Dvideo=fb')
 46  endif
 47  drm = dependency('libdrm')
 48  requires_private += drm
 49  add_project_arguments('-DENABLE_DRM=1', language: 'c')
 50elif video_backend == 'fb'
 51  if framebuffer_backend == 'auto'
 52    if os == 'linux'
 53      framebuffer_backend = 'fbdev'
 54    elif os == 'netbsd' or os == 'openbsd'
 55      framebuffer_backend = 'wsdisplay'
 56    else
 57      error('Failed to determine framebuffer interface for ' + os)
 58    endif
 59  endif
 60
 61  if framebuffer_backend == 'fbdev'
 62    if os != 'linux'
 63      error('The fbdev framebuffer interface is supported only on Linux')
 64    endif
 65    add_project_arguments([
 66      '-DENABLE_FBDEV=1',
 67      '-DFBDEV_DEVICE="@0@"'.format(get_option('fbdev-device')),
 68    ], language: 'c')
 69  elif framebuffer_backend == 'wsdisplay'
 70    if os != 'netbsd' and os != 'openbsd'
 71      error('The wsdisplay framebuffer interface is supported only on NetBSD and OpenBSD')
 72    endif
 73    add_project_arguments([
 74      '-DENABLE_WSDISPLAY=1',
 75      '-DWSDISPLAY_DEVICE="@0@"'.format(get_option('wsdisplay-device')),
 76    ], language: 'c')
 77  endif
 78endif
 79
 80if video_backend != 'drm' and get_option('xwayland').enabled()
 81  error('Xwayland requires the DRM video backend')
 82endif
 83xwayland = video_backend == 'drm' \
 84  ? dependency('xwayland', required: get_option('xwayland')) \
 85  : disabler()
 86xwayland_deps = [
 87  'xcb',
 88  'xcb-composite',
 89  'xcb-ewmh',
 90  'xcb-icccm',
 91]
 92if xwayland.found()
 93  add_project_arguments('-DENABLE_XWAYLAND', language: 'c')
 94  requires_private += xwayland
 95  foreach dep : xwayland_deps
 96    requires_private += dependency(dep, required: xwayland.found())
 97	endforeach
 98endif
 99
100input_backend = get_option('input')
101libinput = dependency('libinput', version: '>=0.4', required: input_backend == 'libinput')
102
103if input_backend == 'auto'
104  if os == 'linux'
105    if not libinput.found()
106      error('libinput is required for the Linux input backend')
107    endif
108    input_backend = 'libinput'
109  elif os == 'netbsd' or os == 'openbsd'
110    input_backend = 'wscons'
111  else
112    error('Failed to determine input backend for ' + os)
113  endif
114endif  
115
116if input_backend == 'libinput'
117  udev = dependency('libudev', required: get_option('udev'))
118  if udev.found()
119    add_project_arguments('-DENABLE_LIBUDEV', language: 'c')
120  endif
121  requires_private += [libinput, udev]
122endif
123
124subdir('protocol')
125subdir('cursor')
126subdir('launch')
127subdir('libswc')
128
129if get_option('extra')
130  subdir('extra')
131endif
132
133if get_option('example')
134  subdir('example')
135endif
136
137summary({
138  'Xwayland support': xwayland.found(),
139  'Input backend': input_backend,
140  'Video backend': video_backend,
141  'Framebuffer interface': video_backend == 'fb' ? framebuffer_backend : 'n/a',
142}, bool_yn: true)