• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#############################################################################
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',
26   version: '0.8.2',
27   license : 'MIT',
28   meson_version : '>= 0.46',
29   default_options : ['buildtype=release', 'b_ndebug=if-release',
30                      'warning_level=3', 'c_std=gnu11']
31)
32
33# 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
41binary_age    = 1
42interface_age = 4
43revision      = 2
44
45cc = meson.get_compiler('c')
46
47add_project_arguments('-DHAVE_CONFIG_H=1', language : 'c')
48add_project_arguments('-D_GNU_SOURCE=1', language : 'c')
49add_project_arguments('-DVIRGL_RENDERER_UNSTABLE_APIS', language : 'c')
50
51warnings = [
52   '-Werror=implicit-function-declaration',
53   '-Werror=missing-prototypes',
54   '-Wmissing-prototypes',
55   '-Werror=int-to-pointer-cast',
56   '-Wno-overlength-strings',
57]
58
59foreach w : warnings
60   if cc.has_argument(w)
61      add_project_arguments(w, language : 'c')
62   endif
63endforeach
64
65flags = [
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
75prog_python = import('python').find_installation('python3')
76
77libdrm_dep = dependency('libdrm', version : '>=2.4.50')
78thread_dep = dependency('threads')
79epoxy_dep = dependency('epoxy', version: '>= 1.5.4')
80m_dep = cc.find_library('m')
81
82conf_data = configuration_data()
83conf_data.set('VERSION', '0.8.1')
84
85with_tracing = get_option('tracing')
86
87if with_tracing != 'none'
88  if not cc.compiles('void f(void* v){} int main () { void *dummy __attribute__((cleanup (f))) = 0;}')
89     error('Tracing requires compiler support for __attribute__((cleanup))')
90endif
91
92endif
93
94if 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
102if with_tracing == 'perfetto'
103   vperfetto_min_dep = dependency('vperfetto_min')
104   conf_data.set('ENABLE_TRACING', 'TRACE_WITH_PERFETTO')
105endif
106
107if with_tracing == 'stderr'
108   conf_data.set('ENABLE_TRACING', 'TRACE_WITH_STDERR')
109endif
110
111if 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
127if cc.has_header('sys/select.h')
128  conf_data.set('HAVE_SYS_SELECT_H', 1)
129endif
130
131if get_option('buildtype') == 'debug'
132   add_global_arguments('-DDEBUG=1', language : 'c')
133endif
134
135platforms = get_option('platforms')
136
137require_egl = platforms.contains('egl')
138require_glx = platforms.contains('glx')
139auto_egl_glx = platforms.contains('auto')
140
141with_egl = require_egl or auto_egl_glx
142with_glx = require_glx or auto_egl_glx
143
144have_egl = false
145have_glx = false
146
147with_minigbm_allocation = get_option('minigbm_allocation')
148if with_minigbm_allocation
149   conf_data.set('ENABLE_MINIGBM_ALLOCATION', 1)
150   _gbm_ver = '18.0.0'
151else
152   _gbm_ver = '0.0.0'
153endif
154
155if with_egl
156   if cc.has_header('epoxy/egl.h', dependencies: epoxy_dep) and epoxy_dep.get_pkgconfig_variable('epoxy_has_egl') == '1'
157      gbm_dep = dependency('gbm', version: '>= ' + _gbm_ver, required: require_egl)
158      have_egl = gbm_dep.found()
159      conf_data.set('HAVE_EPOXY_EGL_H', 1)
160   else
161      assert(not require_egl,
162             'egl was explicitely requested but it is not supported by epoxy')
163   endif
164endif
165
166if with_glx
167   if cc.has_header('epoxy/glx.h', dependencies: epoxy_dep) and epoxy_dep.get_pkgconfig_variable('epoxy_has_glx') == '1'
168      glx_dep = dependency('x11', required: require_glx)
169      have_glx = glx_dep.found()
170      conf_data.set('HAVE_EPOXY_GLX_H', 1)
171   else
172      assert(not require_glx,
173             'glx was explicitely requested but it is not supported by epoxy')
174   endif
175endif
176
177if cc.compiles('void __attribute__((hidden)) func() {}')
178   conf_data.set('HAVE_FUNC_ATTRIBUTE_VISIBILITY', 1)
179endif
180
181configure_file(input : 'config.h.meson',
182               output : 'config.h',
183               configuration : conf_data)
184
185pkgconf_data = configuration_data()
186pkgconf_data.set('PACKAGE_VERSION', meson.project_version())
187pkgconf_data.set('prefix', get_option('prefix'))
188pkgconf_data.set('exec_prefix', '${prefix}')
189pkgconf_data.set('libdir', '${prefix}/' + get_option('libdir'))
190pkgconf_data.set('includedir', '${prefix}/' + get_option('includedir'))
191
192pkg_config = configure_file(input : 'virglrenderer.pc.in',
193                            output : 'virglrenderer.pc',
194                            configuration : pkgconf_data)
195
196install_data(pkg_config,
197             install_dir: get_option('libdir') + '/pkgconfig')
198
199inc_configuration = include_directories('.')
200
201with_fuzzer = get_option('fuzzer')
202with_tests = get_option('tests')
203with_valgrind = get_option('valgrind')
204
205subdir('src')
206subdir('vtest')
207
208if with_tests
209   subdir('tests')
210endif
211
212lines = [
213   '',
214   'prefix:    ' + get_option('prefix'),
215   'libdir:    ' + get_option('libdir'),
216   '',
217   'c_args:    ' + (' ').join(get_option('c_args')),
218   '',
219]
220
221lines += 'egl:       ' + (have_egl ? 'yes' : 'no')
222lines += 'glx:       ' + (have_glx ? 'yes' : 'no')
223lines += ''
224lines += 'minigbm_alloc: ' + (with_minigbm_allocation ? 'yes' : 'no' )
225lines += ''
226lines += 'tests:     ' + (with_tests ? 'yes' : 'no' )
227lines += 'fuzzer:    ' + (with_fuzzer ? 'yes' : 'no' )
228lines += 'tracing:   ' + with_tracing
229
230indent = '   '
231summary = indent + ('\n' + indent).join(lines)
232message('\n\nConfiguration summary:\n@0@\n'.format(summary))
233