c7c22d363714169b544e0d590c1f5a227f3a9318
[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 endif
118 if with_platform_wayland
119 deps_for_egl += [dep_wayland_client, dep_wayland_server, dep_wayland_egl_headers]
120 link_for_egl += libwayland_drm
121 files_egl += files('drivers/dri2/platform_wayland.c')
122 files_egl += [
123 linux_dmabuf_unstable_v1_protocol_c,
124 linux_dmabuf_unstable_v1_client_protocol_h,
125 wayland_drm_client_protocol_h,
126 ]
127 incs_for_egl += include_directories('wayland/wayland-drm')
128 endif
129 if with_platform_android
130 deps_for_egl += dep_android
131 files_egl += files('drivers/dri2/platform_android.c')
132 endif
133 if with_platform_haiku
134 incs_for_egl += inc_haikugl
135 c_args_for_egl += [
136 '-D_EGL_BUILT_IN_DRIVER_HAIKU',
137 ]
138 files_egl += files('drivers/haiku/egl_haiku.cpp')
139 link_for_egl += libgl
140 deps_for_egl += cpp.find_library('be')
141 endif
142
143 if cc.has_function('mincore')
144 c_args_for_egl += '-DHAVE_MINCORE'
145 endif
146
147 if not with_glvnd
148 egl_lib_name = 'EGL'
149 egl_lib_version = '1.0.0'
150 else
151 egl_lib_name = 'EGL_mesa'
152 egl_lib_version = '0.0.0'
153 files_egl += [g_egldispatchstubs_h, g_egldispatchstubs_c]
154 files_egl += files('main/eglglvnd.c', 'main/egldispatchstubs.c')
155 install_data(
156 'main/50_mesa.json',
157 install_dir : join_paths(get_option('datadir'), 'glvnd', 'egl_vendor.d')
158 )
159 endif
160
161 libegl = shared_library(
162 egl_lib_name,
163 files_egl,
164 c_args : [
165 c_vis_args,
166 c_args_for_egl,
167 '-D_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_@0@'.format(egl_native_platform.to_upper()),
168 ],
169 include_directories : incs_for_egl,
170 link_with : [link_for_egl, libloader, libxmlconfig, libglapi, libmesa_util],
171 link_args : [ld_args_bsymbolic, ld_args_gc_sections],
172 dependencies : [deps_for_egl, dep_dl, dep_libdrm, dep_clock, dep_thread],
173 install : true,
174 version : egl_lib_version,
175 )
176
177 # If using glvnd the pkg-config header should not point to EGL_mesa, it should
178 # point to EGL. glvnd is only available on unix like platforms so adding -l
179 # should be safe here
180 # TODO: in the glvnd case glvnd itself should really be providing this.
181 if with_glvnd
182 _egl = '-L${libdir} -lEGL'
183 else
184 _egl = libegl
185 endif
186
187 pkg.generate(
188 name : 'egl',
189 description : 'Mesa EGL Library',
190 version : meson.project_version(),
191 libraries : _egl,
192 libraries_private: gl_priv_libs,
193 requires_private : gl_priv_reqs,
194 extra_cflags : gl_pkgconfig_c_flags,
195 )
196
197 if with_tests
198 if with_glvnd
199 # TODO: add glvnd symbol check
200 else
201 test('egl-symbols-check',
202 find_program('egl-symbols-check'),
203 env : env_test,
204 args : libegl
205 )
206 endif
207 test('egl-entrypoint-check',
208 find_program('egl-entrypoint-check'),
209 env : [ 'srcdir=' + meson.current_source_dir() ]
210 )
211 endif