5 kx if not (get_option('scanner') or get_option('libraries'))
5 kx error('Either -Dscanner=true or -Dlibraries=true is required')
5 kx endif
5 kx
5 kx wayland_version_h = configuration_data()
5 kx wayland_version_h.set('WAYLAND_VERSION', meson.project_version())
5 kx wayland_version_h.set('WAYLAND_VERSION_MAJOR', wayland_version[0].to_int())
5 kx wayland_version_h.set('WAYLAND_VERSION_MINOR', wayland_version[1].to_int())
5 kx wayland_version_h.set('WAYLAND_VERSION_MICRO', wayland_version[2].to_int())
5 kx configure_file(
5 kx input: 'wayland-version.h.in',
5 kx output: 'wayland-version.h',
5 kx configuration: wayland_version_h,
5 kx install: get_option('libraries'),
5 kx install_dir: join_paths(get_option('prefix'), get_option('includedir'))
5 kx )
5 kx
5 kx
5 kx wayland_util = static_library(
5 kx 'wayland-util',
5 kx sources: 'wayland-util.c'
5 kx )
5 kx
5 kx wayland_util_dep = declare_dependency(
5 kx link_with: wayland_util,
5 kx include_directories: include_directories('.')
5 kx )
5 kx
5 kx if get_option('scanner')
5 kx # wayland-scanner
5 kx
5 kx scanner_deps = [ dependency('expat') ]
5 kx scanner_args = [ '-include', 'config.h' ]
5 kx
5 kx if get_option('dtd_validation')
5 kx scanner_deps += dependency('libxml-2.0')
5 kx scanner_args += '-DHAVE_LIBXML=1'
5 kx endif
5 kx
5 kx prog_embed = find_program('embed.py', native: true)
5 kx
5 kx embed_dtd = custom_target(
5 kx 'wayland.dtd.h',
5 kx input: '../protocol/wayland.dtd',
5 kx output: 'wayland.dtd.h',
5 kx command: [ prog_embed, '@INPUT@', 'wayland_dtd' ],
5 kx capture: true
5 kx )
5 kx
5 kx wayland_scanner_sources = [ 'scanner.c', embed_dtd ]
5 kx wayland_scanner_includes = [ root_inc, protocol_inc ]
5 kx
5 kx wayland_scanner = executable(
5 kx 'wayland-scanner',
5 kx wayland_scanner_sources,
5 kx c_args: scanner_args,
5 kx include_directories: wayland_scanner_includes,
5 kx dependencies: [ scanner_deps, wayland_util_dep, ],
5 kx install: true
5 kx )
5 kx
5 kx pkgconfig.generate(
5 kx name: 'Wayland Scanner',
5 kx description: 'Wayland scanner',
5 kx version: meson.project_version(),
5 kx variables: [
5 kx 'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
5 kx 'pkgdatadir=' + join_paths('${datarootdir}', meson.project_name()),
5 kx 'bindir=' + join_paths('${prefix}', get_option('bindir')),
5 kx 'wayland_scanner=${bindir}/wayland-scanner'
5 kx ],
5 kx filebase: 'wayland-scanner'
5 kx )
5 kx
5 kx if meson.can_run_host_binaries()
5 kx meson.override_find_program('wayland-scanner', wayland_scanner)
5 kx endif
5 kx endif
5 kx
5 kx if get_option('scanner_for_build') != 'none'
5 kx wayland_scanner_for_build = get_option('scanner_for_build')
5 kx else
5 kx if meson.is_cross_build() or not get_option('scanner')
5 kx scanner_dep = dependency('wayland-scanner', native: true, version: meson.project_version())
5 kx wayland_scanner_for_build = find_program(scanner_dep.get_variable(pkgconfig: 'wayland_scanner'))
5 kx else
5 kx wayland_scanner_for_build = wayland_scanner
5 kx endif
5 kx endif
5 kx
5 kx if get_option('libraries')
5 kx # wayland libraries
5 kx
5 kx mathlib_dep = cc.find_library('m', required: false)
5 kx threads_dep = dependency('threads', required: false)
5 kx
5 kx wayland_private = static_library(
5 kx 'wayland-private',
5 kx sources: [
5 kx 'connection.c',
5 kx 'wayland-os.c'
5 kx ],
5 kx dependencies: [ epoll_dep, ffi_dep, rt_dep ]
5 kx )
5 kx
5 kx wayland_private_dep = declare_dependency(
5 kx link_with: wayland_private,
5 kx include_directories: include_directories('.')
5 kx )
5 kx
5 kx generated_headers = [
5 kx {
5 kx 'scanner_args': ['server-header'],
5 kx 'output': 'wayland-server-protocol.h',
5 kx 'install': true,
5 kx },
5 kx {
5 kx 'scanner_args': ['server-header', '-c'],
5 kx 'output': 'wayland-server-protocol-core.h',
5 kx 'install': false,
5 kx },
5 kx {
5 kx 'scanner_args': ['client-header'],
5 kx 'output': 'wayland-client-protocol.h',
5 kx 'install': true,
5 kx },
5 kx {
5 kx 'scanner_args': ['client-header', '-c'],
5 kx 'output': 'wayland-client-protocol-core.h',
5 kx 'install': false,
5 kx },
5 kx ]
5 kx
5 kx foreach gen: generated_headers
5 kx scanner_args = gen['scanner_args']
5 kx output_file = gen['output']
5 kx install_file = gen['install']
5 kx install_dir = join_paths(get_option('prefix'), get_option('includedir'))
5 kx target_name = output_file.underscorify()
5 kx
5 kx target = custom_target(
5 kx target_name,
5 kx command: [
5 kx wayland_scanner_for_build, '-s', scanner_args,
5 kx '@INPUT@', '@OUTPUT@'
5 kx ],
5 kx input: wayland_protocol_xml,
5 kx output: output_file,
5 kx install: install_file,
5 kx install_dir: install_dir
5 kx )
5 kx
5 kx set_variable(target_name, target)
5 kx endforeach
5 kx
5 kx wayland_protocol_c = custom_target(
5 kx 'protocol source',
5 kx command: [
5 kx wayland_scanner_for_build, '-s', 'public-code', '@INPUT@', '@OUTPUT@'
5 kx ],
5 kx input: wayland_protocol_xml,
5 kx output: 'wayland-protocol.c'
5 kx )
5 kx
5 kx if wayland_version[0] != '1'
5 kx # The versioning used for the shared libraries assumes that the major
5 kx # version of Wayland as a whole will increase to 2 if and only if there
5 kx # is an ABI break, at which point we should probably bump the SONAME of
5 kx # all libraries to .so.2. For more details see
5 kx # https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/177
5 kx error('We probably need to bump the SONAME of libwayland-server and -client')
5 kx endif
5 kx
5 kx wayland_server = library(
5 kx 'wayland-server',
5 kx sources: [
5 kx wayland_server_protocol_core_h,
5 kx wayland_server_protocol_h,
5 kx wayland_protocol_c,
5 kx 'wayland-server.c',
5 kx 'wayland-shm.c',
5 kx 'event-loop.c'
5 kx ],
5 kx # To avoid an unnecessary SONAME bump, wayland 1.x.y produces
5 kx # libwayland-server.so.0.x.y.
5 kx version: '.'.join(['0', wayland_version[1], wayland_version[2]]),
5 kx dependencies: [
5 kx epoll_dep,
5 kx ffi_dep,
5 kx wayland_private_dep,
5 kx wayland_util_dep,
5 kx mathlib_dep,
5 kx threads_dep,
5 kx rt_dep
5 kx ],
5 kx include_directories: root_inc,
5 kx install: true
5 kx )
5 kx
5 kx wayland_server_dep = declare_dependency(
5 kx link_with: wayland_server,
5 kx include_directories: [ root_inc, include_directories('.') ],
5 kx dependencies: [ epoll_dep, ffi_dep, mathlib_dep, threads_dep ],
5 kx sources: [
5 kx wayland_server_protocol_core_h,
5 kx wayland_server_protocol_h
5 kx ]
5 kx )
5 kx
5 kx pkgconfig.generate(
5 kx wayland_server,
5 kx name: 'Wayland Server',
5 kx description: 'Server side implementation of the Wayland protocol',
5 kx version: meson.project_version(),
5 kx filebase: 'wayland-server',
5 kx variables: [
5 kx 'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
5 kx 'pkgdatadir=' + join_paths('${datarootdir}', meson.project_name())
5 kx ]
5 kx )
5 kx
5 kx if meson.version().version_compare('>= 0.54.0')
5 kx meson.override_dependency('wayland-server', wayland_server_dep)
5 kx endif
5 kx
5 kx wayland_client = library(
5 kx 'wayland-client',
5 kx sources: [
5 kx wayland_client_protocol_core_h,
5 kx wayland_client_protocol_h,
5 kx wayland_protocol_c,
5 kx 'wayland-client.c'
5 kx ],
5 kx # To avoid an unnecessary SONAME bump, wayland 1.x.y produces
5 kx # libwayland-client.so.0.x.y.
5 kx version: '.'.join(['0', wayland_version[1], wayland_version[2]]),
5 kx dependencies: [
5 kx epoll_dep,
5 kx ffi_dep,
5 kx wayland_private_dep,
5 kx wayland_util_dep,
5 kx mathlib_dep,
5 kx threads_dep
5 kx ],
5 kx include_directories: root_inc,
5 kx install: true
5 kx )
5 kx
5 kx pkgconfig.generate(
5 kx wayland_client,
5 kx name: 'Wayland Client',
5 kx description: 'Wayland client side library',
5 kx version: meson.project_version(),
5 kx filebase: 'wayland-client',
5 kx variables: [
5 kx 'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
5 kx 'pkgdatadir=' + join_paths('${datarootdir}', meson.project_name())
5 kx ]
5 kx )
5 kx
5 kx wayland_client_dep = declare_dependency(
5 kx link_with: wayland_client,
5 kx include_directories: [ root_inc, include_directories('.') ],
5 kx sources: [
5 kx wayland_client_protocol_core_h,
5 kx wayland_client_protocol_h
5 kx ]
5 kx )
5 kx
5 kx if meson.version().version_compare('>= 0.54.0')
5 kx meson.override_dependency('wayland-client', wayland_client_dep)
5 kx endif
5 kx
5 kx install_headers([
5 kx 'wayland-util.h',
5 kx 'wayland-server.h',
5 kx 'wayland-server-core.h',
5 kx 'wayland-client.h',
5 kx 'wayland-client-core.h',
5 kx ])
5 kx endif