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.9.0', 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 = 5 43revision = 3 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 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 159if get_option('buildtype') == 'debug' 160 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 175with_minigbm_allocation = get_option('minigbm_allocation') 176if with_minigbm_allocation 177 conf_data.set('ENABLE_MINIGBM_ALLOCATION', 1) 178 _gbm_ver = '18.0.0' 179else 180 _gbm_ver = '0.0.0' 181endif 182 183if with_egl 184 if cc.has_header('epoxy/egl.h', dependencies: epoxy_dep) and epoxy_dep.get_pkgconfig_variable('epoxy_has_egl') == '1' 185 gbm_dep = dependency('gbm', version: '>= ' + _gbm_ver, required: require_egl) 186 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 195 if cc.has_header('epoxy/glx.h', dependencies: epoxy_dep) and epoxy_dep.get_pkgconfig_variable('epoxy_has_glx') == '1' 196 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 205with_venus = get_option('venus-experimental') 206with_venus_validate = get_option('venus-validate') 207if with_venus 208 venus_dep = dependency('vulkan') 209 conf_data.set('ENABLE_VENUS', 1) 210 211 if with_venus_validate 212 conf_data.set('ENABLE_VENUS_VALIDATE', 1) 213 endif 214endif 215 216if cc.compiles('void __attribute__((hidden)) func() {}') 217 conf_data.set('HAVE_FUNC_ATTRIBUTE_VISIBILITY', 1) 218endif 219 220configure_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 238inc_configuration = include_directories(['.', 'src']) 239 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 += '' 263lines += 'minigbm_alloc: ' + (with_minigbm_allocation ? 'yes' : 'no' ) 264lines += '' 265lines += 'venus: ' + (with_venus ? 'yes' : 'no' ) 266lines += '' 267lines += 'tests: ' + (with_tests ? 'yes' : 'no' ) 268lines += 'fuzzer: ' + (with_fuzzer ? 'yes' : 'no' ) 269lines += 'tracing: ' + with_tracing 270 271indent = ' ' 272summary = indent + ('\n' + indent).join(lines) 273message('\n\nConfiguration summary:\n@0@\n'.format(summary)) 274