1
0

meson.build 3.7 KB

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