blob: 9c878bd5b04e9a6d9da921bdf67ceae3ed3aa516 [file] [log] [blame]
Gert Wollny17c23682019-09-16 13:07:07 +02001#############################################################################
2#
3# Copyright (C) 2019 Collabora Ltd
4#
5# Permission is hereby granted, free of charge, to any person obtaining a
6# copy of this software and associated documentation files (the "Software"),
7# to deal in the Software without restriction, including without limitation
8# the rights to use, copy, modify, merge, publish, distribute, sublicense,
9# and/or sell copies of the Software, and to permit persons to whom the
10# Software is furnished to do so, subject to the following conditions:
11#
12# The above copyright notice and this permission notice shall be included
13# in all copies or substantial portions of the Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21# OTHER DEALINGS IN THE SOFTWARE.
22#
23
24project(
25 'virglrenderer', 'c',
Gert Wollny2cd08032020-11-13 17:37:29 +010026 version: '0.9.0',
Gert Wollny17c23682019-09-16 13:07:07 +020027 license : 'MIT',
28 meson_version : '>= 0.46',
Lepton Wua97a3912019-10-21 19:22:14 -070029 default_options : ['buildtype=release', 'b_ndebug=if-release',
30 'warning_level=3', 'c_std=gnu11']
Gert Wollny17c23682019-09-16 13:07:07 +020031)
32
Gert Wollny471185e2019-12-06 10:04:06 +010033# To change only before doing a release:
34#
35# 1. Incrememnt the revision
36# 2. If the interface was changed in an compatible way increment the
37# interface age
38# 3. If the ABI has changed in an incompatible way increment the binary_age
39# and set revision and interface_age to zero
40
Gert Wollny17c23682019-09-16 13:07:07 +020041binary_age = 1
Gert Wollny2cd08032020-11-13 17:37:29 +010042interface_age = 5
43revision = 3
Gert Wollny17c23682019-09-16 13:07:07 +020044
45cc = meson.get_compiler('c')
46
47add_project_arguments('-DHAVE_CONFIG_H=1', language : 'c')
48add_project_arguments('-D_GNU_SOURCE=1', language : 'c')
Chia-I Wu491afdc2020-07-07 20:27:12 -070049add_project_arguments('-DVIRGL_RENDERER_UNSTABLE_APIS', language : 'c')
Gert Wollny17c23682019-09-16 13:07:07 +020050
Gert Wollny17c23682019-09-16 13:07:07 +020051warnings = [
52 '-Werror=implicit-function-declaration',
53 '-Werror=missing-prototypes',
54 '-Wmissing-prototypes',
Chia-I Wu82d05bf2020-04-23 12:51:09 -070055 '-Werror=int-to-pointer-cast',
56 '-Wno-overlength-strings',
Gert Wollny17c23682019-09-16 13:07:07 +020057]
58
59foreach w : warnings
60 if cc.has_argument(w)
61 add_project_arguments(w, language : 'c')
62 endif
63endforeach
64
Gert Wollny1e581b62019-12-23 16:48:52 +010065flags = [
66 '-fvisibility=hidden',
67]
68
69foreach f : flags
70 if cc.has_argument(f)
71 add_project_arguments(f, language : 'c')
72 endif
73endforeach
74
Gert Wollny17c23682019-09-16 13:07:07 +020075prog_python = import('python').find_installation('python3')
76
77libdrm_dep = dependency('libdrm', version : '>=2.4.50')
78thread_dep = dependency('threads')
Gurchetan Singh256ef782019-12-03 17:41:40 -080079epoxy_dep = dependency('epoxy', version: '>= 1.5.4')
Gert Wollny17c23682019-09-16 13:07:07 +020080m_dep = cc.find_library('m')
81
82conf_data = configuration_data()
83conf_data.set('VERSION', '0.8.1')
84
Gert Wollny19d65e82020-11-09 17:17:49 +010085with_tracing = get_option('tracing')
86
87if with_tracing != 'none'
Gert Wollnyfab5e732021-01-29 16:14:52 +010088 if not cc.compiles('void f(void* v){} int main () { void *dummy __attribute__((cleanup (f))) = 0;}')
Gert Wollny19d65e82020-11-09 17:17:49 +010089 error('Tracing requires compiler support for __attribute__((cleanup))')
90endif
91
92endif
93
John Batese64afcf2021-02-04 11:04:40 -080094if with_tracing == 'percetto'
95 # percetto uses C++ internally, so we need to link with C++.
96 # TODO: remove -lstdc++ when percetto is a shared library.
97 add_project_link_arguments('-lstdc++', language : 'c')
98 percetto_dep = dependency('percetto', version : '>=0.0.8')
99 conf_data.set('ENABLE_TRACING', 'TRACE_WITH_PERCETTO')
100endif
101
Gert Wollny19d65e82020-11-09 17:17:49 +0100102if with_tracing == 'perfetto'
103 vperfetto_min_dep = dependency('vperfetto_min')
104 conf_data.set('ENABLE_TRACING', 'TRACE_WITH_PERFETTO')
105endif
106
Gert Wollny024a0d92020-11-11 10:58:01 +0100107if with_tracing == 'stderr'
108 conf_data.set('ENABLE_TRACING', 'TRACE_WITH_STDERR')
109endif
110
Gert Wollny17c23682019-09-16 13:07:07 +0200111if cc.has_header('sys/uio.h')
112 conf_data.set('HAVE_SYS_UIO_H', 1)
113endif
114
115if cc.has_header('dlfcn.h')
116 conf_data.set('HAVE_DLFCN_H', 1)
117endif
118
119if cc.has_header('pthread.h')
120 conf_data.set('HAVE_PTHREAD', 1)
121endif
122
123if cc.has_header('sys/eventfd.h')
124 conf_data.set('HAVE_EVENTFD_H', 1)
125endif
126
Nathan Owens9c3b8f42019-12-27 09:27:12 -0600127if cc.has_header('sys/select.h')
128 conf_data.set('HAVE_SYS_SELECT_H', 1)
129endif
130
Leoc6f20d82019-11-28 13:31:49 +0100131if host_machine.endian() == 'little'
132 conf_data.set('PIPE_ARCH_LITTLE_ENDIAN', true)
133elif host_machine.endian() == 'big'
134 conf_data.set('PIPE_ARCH_BIG_ENDIAN', true)
135else
136 error('It wasn\'t possible to figure out the endianess of the machine')
137endif
138
139pipe_arch = host_machine.cpu_family()
140
141if pipe_arch == 'x86'
142 conf_data.set('PIPE_ARCH_X86', true)
143elif pipe_arch == 'x86_64'
144 conf_data.set('PIPE_ARCH_X86_64', true)
145elif pipe_arch == 'ppc'
146 conf_data.set('PIPE_ARCH_PPC', true)
147elif pipe_arch == 'ppc64'
148 conf_data.set('PIPE_ARCH_PPC_64', true)
149elif pipe_arch == 's390x'
150 conf_data.set('PIPE_ARCH_S390', true)
151elif pipe_arch == 'arm'
152 conf_data.set('PIPE_ARCH_ARM', true)
153elif pipe_arch == 'aarch64'
154 conf_data.set('PIPE_ARCH_AARCH64', true)
155else
156 warning('Arch used is not supported')
157endif
158
Gurchetan Singhf3e49072020-01-03 09:31:55 -0800159if get_option('buildtype') == 'debug'
Gert Wollny17c23682019-09-16 13:07:07 +0200160 add_global_arguments('-DDEBUG=1', language : 'c')
161endif
162
163platforms = get_option('platforms')
164
165require_egl = platforms.contains('egl')
166require_glx = platforms.contains('glx')
167auto_egl_glx = platforms.contains('auto')
168
169with_egl = require_egl or auto_egl_glx
170with_glx = require_glx or auto_egl_glx
171
172have_egl = false
173have_glx = false
174
Gurchetan Singh1fcd27d2020-03-25 17:02:34 -0700175with_minigbm_allocation = get_option('minigbm_allocation')
176if with_minigbm_allocation
177 conf_data.set('ENABLE_MINIGBM_ALLOCATION', 1)
Lepton Wuc162f332019-12-10 06:06:07 +0000178 _gbm_ver = '18.0.0'
179else
180 _gbm_ver = '0.0.0'
181endif
182
Gert Wollny17c23682019-09-16 13:07:07 +0200183if with_egl
Jason Macnak9e6b3e32019-12-27 21:31:53 -0800184 if cc.has_header('epoxy/egl.h', dependencies: epoxy_dep) and epoxy_dep.get_pkgconfig_variable('epoxy_has_egl') == '1'
Lepton Wuc162f332019-12-10 06:06:07 +0000185 gbm_dep = dependency('gbm', version: '>= ' + _gbm_ver, required: require_egl)
Gert Wollny17c23682019-09-16 13:07:07 +0200186 have_egl = gbm_dep.found()
187 conf_data.set('HAVE_EPOXY_EGL_H', 1)
188 else
189 assert(not require_egl,
190 'egl was explicitely requested but it is not supported by epoxy')
191 endif
192endif
193
194if with_glx
Jason Macnak9e6b3e32019-12-27 21:31:53 -0800195 if cc.has_header('epoxy/glx.h', dependencies: epoxy_dep) and epoxy_dep.get_pkgconfig_variable('epoxy_has_glx') == '1'
Gert Wollny17c23682019-09-16 13:07:07 +0200196 glx_dep = dependency('x11', required: require_glx)
197 have_glx = glx_dep.found()
198 conf_data.set('HAVE_EPOXY_GLX_H', 1)
199 else
200 assert(not require_glx,
201 'glx was explicitely requested but it is not supported by epoxy')
202 endif
203endif
204
Chia-I Wu6e12fa62020-03-24 17:07:11 -0700205with_venus = get_option('venus-experimental')
Chia-I Wud67cfcb2021-06-14 11:30:33 -0700206with_venus_validate = get_option('venus-validate')
Chia-I Wu6e12fa62020-03-24 17:07:11 -0700207if with_venus
208 venus_dep = dependency('vulkan')
209 conf_data.set('ENABLE_VENUS', 1)
Chia-I Wud67cfcb2021-06-14 11:30:33 -0700210
211 if with_venus_validate
212 conf_data.set('ENABLE_VENUS_VALIDATE', 1)
213 endif
Chia-I Wu6e12fa62020-03-24 17:07:11 -0700214endif
215
Gert Wollny17c23682019-09-16 13:07:07 +0200216if cc.compiles('void __attribute__((hidden)) func() {}')
217 conf_data.set('HAVE_FUNC_ATTRIBUTE_VISIBILITY', 1)
218endif
219
Gert Wollny17c23682019-09-16 13:07:07 +0200220configure_file(input : 'config.h.meson',
221 output : 'config.h',
222 configuration : conf_data)
223
224pkgconf_data = configuration_data()
225pkgconf_data.set('PACKAGE_VERSION', meson.project_version())
226pkgconf_data.set('prefix', get_option('prefix'))
227pkgconf_data.set('exec_prefix', '${prefix}')
228pkgconf_data.set('libdir', '${prefix}/' + get_option('libdir'))
229pkgconf_data.set('includedir', '${prefix}/' + get_option('includedir'))
230
231pkg_config = configure_file(input : 'virglrenderer.pc.in',
232 output : 'virglrenderer.pc',
233 configuration : pkgconf_data)
234
235install_data(pkg_config,
236 install_dir: get_option('libdir') + '/pkgconfig')
237
Leo5b870792019-11-28 13:32:14 +0100238inc_configuration = include_directories(['.', 'src'])
Gert Wollny17c23682019-09-16 13:07:07 +0200239
240with_fuzzer = get_option('fuzzer')
241with_tests = get_option('tests')
242with_valgrind = get_option('valgrind')
243
244subdir('src')
245subdir('vtest')
246
247if with_tests
248 subdir('tests')
249endif
250
251lines = [
252 '',
253 'prefix: ' + get_option('prefix'),
254 'libdir: ' + get_option('libdir'),
255 '',
256 'c_args: ' + (' ').join(get_option('c_args')),
257 '',
258]
259
260lines += 'egl: ' + (have_egl ? 'yes' : 'no')
261lines += 'glx: ' + (have_glx ? 'yes' : 'no')
262lines += ''
Gurchetan Singh1fcd27d2020-03-25 17:02:34 -0700263lines += 'minigbm_alloc: ' + (with_minigbm_allocation ? 'yes' : 'no' )
Gert Wollny17c23682019-09-16 13:07:07 +0200264lines += ''
Chia-I Wu6e12fa62020-03-24 17:07:11 -0700265lines += 'venus: ' + (with_venus ? 'yes' : 'no' )
266lines += ''
Gert Wollny17c23682019-09-16 13:07:07 +0200267lines += 'tests: ' + (with_tests ? 'yes' : 'no' )
268lines += 'fuzzer: ' + (with_fuzzer ? 'yes' : 'no' )
Gert Wollny19d65e82020-11-09 17:17:49 +0100269lines += 'tracing: ' + with_tracing
Gert Wollny17c23682019-09-16 13:07:07 +0200270
271indent = ' '
272summary = indent + ('\n' + indent).join(lines)
273message('\n\nConfiguration summary:\n@0@\n'.format(summary))