meson: Add support for EGL glvnd
[mesa.git] / src / egl / meson.build
1 # Copyright © 2017 Intel Corporation
2
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to deal
5 # in the Software without restriction, including without limitation the rights
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 # copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
9
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
12
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 # SOFTWARE.
20
21 c_args_for_egl = []
22 link_for_egl = []
23 deps_for_egl = []
24 incs_for_egl = []
25 files_egl = files(
26 'main/eglapi.c',
27 'main/eglapi.h',
28 'main/eglarray.c',
29 'main/eglarray.h',
30 'main/eglconfig.c',
31 'main/eglconfig.h',
32 'main/eglcontext.c',
33 'main/eglcontext.h',
34 'main/eglcurrent.c',
35 'main/eglcurrent.h',
36 'main/egldefines.h',
37 'main/egldisplay.c',
38 'main/egldisplay.h',
39 'main/egldriver.c',
40 'main/egldriver.h',
41 'main/eglfallbacks.c',
42 'main/eglglobals.c',
43 'main/eglglobals.h',
44 'main/eglimage.c',
45 'main/eglimage.h',
46 'main/egllog.c',
47 'main/egllog.h',
48 'main/eglsurface.c',
49 'main/eglsurface.h',
50 'main/eglsync.c',
51 'main/eglsync.h',
52 'main/eglentrypoint.h',
53 'main/egltypedefs.h',
54 'drivers/dri2/egl_dri2.c',
55 'drivers/dri2/egl_dri2.h',
56 'drivers/dri2/egl_dri2_fallbacks.h',
57 )
58
59 linux_dmabuf_unstable_v1_protocol_c = custom_target(
60 'linux-dmabuf-unstable-v1-protocol.c',
61 input : wayland_dmabuf_xml,
62 output : 'linux-dmabuf-unstable-v1-protocol.c',
63 command : [prog_wl_scanner, 'code', '@INPUT@', '@OUTPUT@'],
64 )
65
66 linux_dmabuf_unstable_v1_client_protocol_h = custom_target(
67 'linux-dmabuf-unstable-v1-client-protocol.h',
68 input : wayland_dmabuf_xml,
69 output : 'linux-dmabuf-unstable-v1-client-protocol.h',
70 command : [prog_wl_scanner, 'client-header', '@INPUT@', '@OUTPUT@'],
71 )
72
73 g_egldispatchstubs_c = custom_target(
74 'g_egldispatchstubs.c',
75 input : [
76 'generate/gen_egl_dispatch.py', 'generate/eglFunctionList.py',
77 'generate/egl.xml', 'generate/egl_other.xml'
78 ],
79 output : 'g_egldispatchstubs.c',
80 command : [
81 prog_python2, '@INPUT0@', 'source', '@INPUT1@', '@INPUT2@', '@INPUT3@'
82 ],
83 depend_files : files('generate/genCommon.py'),
84 capture : true,
85 )
86
87 g_egldispatchstubs_h = custom_target(
88 'g_egldispatchstubs.h',
89 input : [
90 'generate/gen_egl_dispatch.py', 'generate/eglFunctionList.py',
91 'generate/egl.xml', 'generate/egl_other.xml'
92 ],
93 output : 'g_egldispatchstubs.h',
94 command : [
95 prog_python2, '@INPUT0@', 'header', '@INPUT1@', '@INPUT2@', '@INPUT3@'
96 ],
97 depend_files : files('generate/genCommon.py'),
98 capture : true,
99 )
100
101 if with_platform_x11
102 files_egl += files('drivers/dri2/platform_x11.c')
103 if with_dri3
104 files_egl += files('drivers/dri2/platform_x11_dri3.c')
105 link_for_egl += libloader_dri3_helper
106 endif
107 deps_for_egl += [dep_xcb_dri2, dep_xcb_xfixes]
108 endif
109 if with_platform_drm
110 files_egl += files('drivers/dri2/platform_drm.c')
111 link_for_egl += libgbm
112 incs_for_egl += include_directories('../gbm/main')
113 endif
114 if with_platform_surfaceless
115 files_egl += files('drivers/dri2/platform_surfaceless.c')
116 endif
117 if with_platform_wayland
118 deps_for_egl += [dep_wayland_client, dep_wayland_server]
119 link_for_egl += libwayland_drm
120 files_egl += files('drivers/dri2/platform_wayland.c')
121 files_egl += [
122 linux_dmabuf_unstable_v1_protocol_c,
123 linux_dmabuf_unstable_v1_client_protocol_h,
124 wayland_drm_client_protocol_h,
125 ]
126 incs_for_egl += include_directories(
127 'wayland/wayland-egl', 'wayland/wayland-drm',
128 )
129 endif
130 # TODO: android
131
132 # TODO: glvnd
133
134 if cc.has_function('mincore')
135 c_args_for_egl += '-DHAVE_MINCORE'
136 endif
137
138 if not with_glvnd
139 egl_lib_name = 'EGL'
140 egl_lib_version = '1.0.0'
141 else
142 egl_lib_name = 'EGL_mesa'
143 egl_lib_version = '0'
144 files_egl += [g_egldispatchstubs_h, g_egldispatchstubs_c]
145 files_egl += files('main/eglglvnd.c', 'main/egldispatchstubs.c')
146 install_data(
147 'main/50_mesa.json',
148 install_dir : join_paths(get_option('datadir'), 'glvnd', 'egl_vendor.d')
149 )
150 endif
151
152 libegl = shared_library(
153 egl_lib_name,
154 files_egl,
155 c_args : [
156 c_vis_args,
157 c_args_for_egl,
158 '-DDEFAULT_DRIVER_DIR="@0@"'.format(dri_driver_dir),
159 '-D_EGL_BUILT_IN_DRIVER_DRI2',
160 '-D_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_@0@'.format(egl_native_platform.to_upper()),
161 ],
162 include_directories : [
163 incs_for_egl, inc_include, inc_src, inc_loader, inc_gbm,
164 include_directories('main'),
165 ],
166 link_with : [link_for_egl, libloader, libxmlconfig, libglapi, libmesa_util],
167 link_args : [ld_args_bsymbolic, ld_args_gc_sections],
168 dependencies : [deps_for_egl, dep_dl, dep_libdrm, dep_clock, dep_thread],
169 install : true,
170 version : egl_lib_version,
171 )
172
173 pkg.generate(
174 name : 'egl',
175 description : 'Mesa EGL Library',
176 version : meson.project_version(),
177 libraries : libegl,
178 libraries_private: gl_priv_libs,
179 requires_private : gl_priv_reqs,
180 extra_cflags : gl_pkgconfig_c_flags,
181 )
182
183 if with_tests
184 test('egl-symbols-check', find_program('egl-symbols-check'))
185 test('egl-entrypoint-check', find_program('egl-entrypoint-check'))
186 endif