9c0b6b4b4a553ce3630a2bbd9281dc8b187c6c51
[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 inc_egl = include_directories('.', 'main')
22 inc_egl_dri2 = include_directories('drivers/dri2')
23
24 c_args_for_egl = []
25 link_for_egl = []
26 deps_for_egl = []
27 incs_for_egl = [inc_include, inc_drm_uapi, inc_src, inc_egl]
28
29 files_egl = files(
30 'main/eglapi.c',
31 'main/eglapi.h',
32 'main/eglarray.c',
33 'main/eglarray.h',
34 'main/eglconfig.c',
35 'main/eglconfig.h',
36 'main/eglcontext.c',
37 'main/eglcontext.h',
38 'main/eglcurrent.c',
39 'main/eglcurrent.h',
40 'main/egldefines.h',
41 'main/egldisplay.c',
42 'main/egldisplay.h',
43 'main/egldriver.c',
44 'main/egldriver.h',
45 'main/eglfallbacks.c',
46 'main/eglglobals.c',
47 'main/eglglobals.h',
48 'main/eglimage.c',
49 'main/eglimage.h',
50 'main/egllog.c',
51 'main/egllog.h',
52 'main/eglsurface.c',
53 'main/eglsurface.h',
54 'main/eglsync.c',
55 'main/eglsync.h',
56 'main/eglentrypoint.h',
57 'main/egltypedefs.h',
58 )
59
60 g_egldispatchstubs_c = custom_target(
61 'g_egldispatchstubs.c',
62 input : [
63 'generate/gen_egl_dispatch.py', 'generate/eglFunctionList.py',
64 'generate/egl.xml', 'generate/egl_other.xml'
65 ],
66 output : 'g_egldispatchstubs.c',
67 command : [
68 prog_python, '@INPUT0@', 'source', '@INPUT1@', '@INPUT2@', '@INPUT3@'
69 ],
70 depend_files : files('generate/genCommon.py'),
71 capture : true,
72 )
73
74 g_egldispatchstubs_h = custom_target(
75 'g_egldispatchstubs.h',
76 input : [
77 'generate/gen_egl_dispatch.py', 'generate/eglFunctionList.py',
78 'generate/egl.xml', 'generate/egl_other.xml'
79 ],
80 output : 'g_egldispatchstubs.h',
81 command : [
82 prog_python, '@INPUT0@', 'header', '@INPUT1@', '@INPUT2@', '@INPUT3@'
83 ],
84 depend_files : files('generate/genCommon.py'),
85 capture : true,
86 )
87
88 if with_dri2
89 files_egl += files(
90 'drivers/dri2/egl_dri2.c',
91 'drivers/dri2/egl_dri2.h',
92 'drivers/dri2/egl_dri2_fallbacks.h',
93 )
94 c_args_for_egl += [
95 '-DDEFAULT_DRIVER_DIR="@0@"'.format(dri_search_path),
96 '-D_EGL_BUILT_IN_DRIVER_DRI2',
97 ]
98 endif
99
100 if with_platform_x11
101 files_egl += files('drivers/dri2/platform_x11.c')
102 incs_for_egl += inc_loader
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_x11_xcb, 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 += [libloader, libgbm, libxmlconfig]
112 incs_for_egl += [inc_loader, inc_gbm, include_directories('../gbm/main')]
113 deps_for_egl += dep_libdrm
114 endif
115 if with_platform_surfaceless
116 files_egl += files('drivers/dri2/platform_surfaceless.c')
117 incs_for_egl += [inc_loader]
118 endif
119 if with_platform_wayland
120 deps_for_egl += [dep_wayland_client, dep_wayland_server, dep_wayland_egl_headers]
121 link_for_egl += libwayland_drm
122 files_egl += files('drivers/dri2/platform_wayland.c')
123 files_egl += [
124 linux_dmabuf_unstable_v1_protocol_c,
125 linux_dmabuf_unstable_v1_client_protocol_h,
126 wayland_drm_client_protocol_h,
127 ]
128 incs_for_egl += include_directories('wayland/wayland-drm')
129 endif
130 if with_platform_android
131 deps_for_egl += dep_android
132 files_egl += files('drivers/dri2/platform_android.c')
133 endif
134 if with_platform_haiku
135 incs_for_egl += inc_haikugl
136 c_args_for_egl += [
137 '-D_EGL_BUILT_IN_DRIVER_HAIKU',
138 ]
139 files_egl += files('drivers/haiku/egl_haiku.cpp')
140 link_for_egl += libgl
141 deps_for_egl += cpp.find_library('be')
142 endif
143
144 if cc.has_function('mincore')
145 c_args_for_egl += '-DHAVE_MINCORE'
146 endif
147
148 if not with_glvnd
149 egl_lib_name = 'EGL'
150 egl_lib_version = '1.0.0'
151 else
152 egl_lib_name = 'EGL_mesa'
153 egl_lib_version = '0.0.0'
154 files_egl += [g_egldispatchstubs_h, g_egldispatchstubs_c]
155 files_egl += files('main/eglglvnd.c', 'main/egldispatchstubs.c')
156 install_data(
157 'main/50_mesa.json',
158 install_dir : join_paths(get_option('datadir'), 'glvnd', 'egl_vendor.d')
159 )
160 endif
161
162 libegl = shared_library(
163 egl_lib_name,
164 files_egl,
165 c_args : [
166 c_vis_args,
167 c_args_for_egl,
168 '-D_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_@0@'.format(egl_native_platform.to_upper()),
169 ],
170 include_directories : incs_for_egl,
171 link_with : [link_for_egl, libloader, libxmlconfig, libglapi, libmesa_util],
172 link_args : [ld_args_bsymbolic, ld_args_gc_sections],
173 dependencies : [deps_for_egl, dep_dl, dep_libdrm, dep_clock, dep_thread],
174 install : true,
175 version : egl_lib_version,
176 )
177
178 # If using glvnd the pkg-config header should not point to EGL_mesa, it should
179 # point to EGL. glvnd is only available on unix like platforms so adding -l
180 # should be safe here
181 # TODO: in the glvnd case glvnd itself should really be providing this.
182 if with_glvnd
183 _egl = '-L${libdir} -lEGL'
184 else
185 _egl = libegl
186 endif
187
188 pkg.generate(
189 name : 'egl',
190 description : 'Mesa EGL Library',
191 version : meson.project_version(),
192 libraries : _egl,
193 libraries_private: gl_priv_libs,
194 requires_private : gl_priv_reqs,
195 extra_cflags : gl_pkgconfig_c_flags,
196 )
197
198 if with_tests
199 if with_glvnd
200 # TODO: add glvnd symbol check
201 else
202 test('egl-symbols-check',
203 find_program('egl-symbols-check'),
204 env : env_test,
205 args : libegl
206 )
207 endif
208 test('egl-entrypoint-check',
209 find_program('egl-entrypoint-check'),
210 env : [ 'srcdir=' + meson.current_source_dir() ]
211 )
212 endif