1 # Copyright © 2017 Dylan Baker
2 # Copyright © 2018-2019 Intel Corporation
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are met:
9 # - Redistributions of source code must retain the above copyright notice, this
10 # list of conditions and the following disclaimer.
12 # - Redistributions in binary form must reproduce the above copyright notice,
13 # this list of conditions and the following disclaimer in the documentation
14 # and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 meson_version : '>= 0.49',
33 default_options : ['c_std=c99', 'buildtype=debugoptimized'],
36 python = import('python').find_installation('python3')
38 waffle_name = meson.project_name() + '-1'
39 docdir = join_paths(get_option('datadir'), 'doc', meson.project_name() + '1')
45 build_surfaceless = false
46 build_nacl = get_option('nacl')
47 build_wgl = ['windows', 'cygwin'].contains(host_machine.system())
48 build_cgl = host_machine.system() == 'darwin'
58 cc = meson.get_compiler('c')
60 _dep_null = dependency('', required : false)
61 dep_threads = dependency('threads')
62 dep_dl = cc.find_library('dl', required : false)
66 dep_wayland_client = _dep_null
67 dep_wayland_egl = _dep_null
68 dep_wayland_scanner = _dep_null
69 dep_wayland_proto = _dep_null
70 dep_x11_xcb = _dep_null
74 dep_core_foundation = _dep_null
75 dep_gl_headers = _dep_null
79 if not cc.has_header('GL/wglext.h')
80 _sub = subproject('opengl_headers')
81 dep_gl_headers = _sub.get_variable('ext_headers')
83 dep_gl = cc.find_library('opengl32')
85 dep_cocoa = dependency('cocoa')
86 dep_core_foundation = dependency('corefoundation')
87 dep_gl = dependency('gl')
89 dep_gl = dependency('gl', required : get_option('glx'))
90 dep_x11_xcb = dependency('x11-xcb', required : get_option('glx'))
91 build_glx = dep_gl.found() and dep_x11_xcb.found()
93 dep_egl = dependency('egl', required : get_option('x11_egl'))
94 dep_x11_xcb = dependency('x11-xcb', required : get_option('x11_egl'))
95 build_x11_egl = dep_egl.found() and dep_x11_xcb.found()
97 dep_egl = dependency('egl', required : get_option('gbm'))
98 dep_gbm = dependency('gbm', required : get_option('gbm'))
99 dep_udev = dependency('libudev', required : get_option('gbm'))
100 build_gbm = dep_egl.found() and dep_gbm.found() and dep_udev.found()
102 dep_egl = dependency('egl', required : get_option('surfaceless_egl'))
103 build_surfaceless = dep_egl.found()
105 dep_egl = dependency('egl', required : get_option('wayland'))
106 dep_wayland_client = dependency(
107 'wayland-client', version : '>= 1.10', required : get_option('wayland'),
109 if dep_wayland_client.found()
110 wayland_core_xml = join_paths(dep_wayland_client.get_pkgconfig_variable('pkgdatadir'),
113 dep_wayland_egl = dependency(
114 'wayland-egl', version : '>= 9.1', required : get_option('wayland'),
116 dep_wayland_scanner = dependency(
117 'wayland-scanner', version : '>= 1.15', required : get_option('wayland'),
119 if dep_wayland_scanner.found()
120 prog_wayland_scanner = find_program(dep_wayland_scanner.get_pkgconfig_variable('wayland_scanner'))
122 dep_wayland_proto = dependency(
123 'wayland-protocols', version : '>= 1.12', required : get_option('wayland'),
125 if dep_wayland_proto.found()
126 wayland_xdg_shell_xml = join_paths(dep_wayland_proto.get_pkgconfig_variable('pkgdatadir'),
127 'stable/xdg-shell/xdg-shell.xml')
129 build_wayland = dep_egl.found() and dep_wayland_client.found() and dep_wayland_egl.found() and dep_wayland_scanner.found() and dep_wayland_proto.found()
131 # We're interested only in the headers provided
132 # FINISHME: make x11_xcb and udev compile-only dependency
133 _include_deps = [ dep_gl, dep_egl, dep_gbm, dep_wayland_client, dep_wayland_egl ]
134 foreach d : _include_deps
136 d = d.partial_dependency(compile_args : true)
141 dep_bash = dependency('bash-completion', required : false)
143 bashcompletiondir = dep_bash.get_pkgconfig_variable('completionsdir')
145 bashcompletiondir = join_paths(get_option('datadir'), 'bash-completion/completions')
147 install_data('shell-completion/bash/wflinfo', install_dir : bashcompletiondir)
149 # Set pre-processor flags
151 add_project_arguments('-DWAFFLE_HAS_WGL', language : ['c', 'cpp'])
153 add_project_arguments('-DWAFFLE_HAS_CGL -DGL_SILENCE_DEPRECATION', language : ['c', 'obj'])
156 add_project_arguments('-DWAFFLE_HAS_X11_EGL', language : ['c', 'cpp'])
159 add_project_arguments('-DWAFFLE_HAS_GLX', language : ['c', 'cpp'])
162 add_project_arguments('-DWAFFLE_HAS_WAYLAND', language : ['c', 'cpp'])
165 add_project_arguments('-DWAFFLE_HAS_GBM', language : ['c', 'cpp'])
168 add_project_arguments('-DWAFFLE_HAS_SURFACELESS_EGL', language : ['c', 'cpp'])
173 add_project_arguments('-DWAFFLE_HAS_NACL', language : ['c', 'cpp'])
176 if cc.get_argument_syntax() == 'gcc'
178 static __thread int x;
184 name : 'Thread Local Storage')
185 add_project_arguments('-DWAFFLE_HAS_TLS', language : ['c', 'cpp'])
188 static __thread int x __attribute__((tls_model("initial-exec")));
194 name : 'TLS model "Initial Exec"')
195 add_project_arguments('-DWAFFLE_HAS_TLS_MODEL_INITIAL_EXEC', language : ['c', 'cpp'])
199 add_project_arguments('-D_XOPEN_SOURCE=700', language : ['c', 'cpp'])
202 add_project_arguments(
203 cc.get_supported_arguments([
204 '-Werror=implicit-function-declaration',
206 language : ['c', 'cpp'],
210 add_project_arguments(
211 cc.get_supported_arguments([
212 '-Werror=incompatible-pointer-types',
213 '-Werror=int-conversion',
214 '-Werror=missing-prototypes', # TODO: breaks on MacOS?
216 language : ['c', 'cpp'],
219 if host_machine.system() == 'windows'
220 if cc.has_argument('-static-libgcc')
221 add_project_link_arguments('-static-libgcc', language : ['c', 'cpp'])
224 elif cc.get_argument_syntax() == 'msvc'
225 add_project_arguments(
226 '/D_win32_WINNT=0x0601',
228 '/D_CRT_NONSTDC_NO_WARNINGS',
229 '/D_CRT_SECURE_NO_WARNINGS',
235 add_project_arguments('-DWAFFLE_HAS_NACL', language : ['c', 'cpp'])
238 install_data('README.md', 'LICENSE.txt', 'HACKING.txt', install_dir : docdir)
239 install_subdir('doc/release-notes', install_dir : docdir)
242 '-DWAFFLE_API_VERSION=@0@'.format('0x0107'),
243 '-DWAFFLE_API_EXPERIMENTAL',
246 if get_option('build-tests')
247 dep_cmocka = dependency('cmocka', fallback : ['cmocka', 'dep_cmocka'])
249 dep_cmocka = _dep_null
253 subdir('third_party')
257 if get_option('build-tests')
260 if get_option('build-examples')