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