blob: a23cc36fc2b8b1ead88c0cb299ea4875cc8d3061 [file] [log] [blame]
Emil Velikovcd0f11b2018-12-09 19:51:15 +00001# Copyright © 2017 Intel Corporation
Dylan Baker108d2572017-10-18 12:20:43 -07002
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
Dylan Baker6f628952018-03-06 10:36:42 -080021inc_egl = include_directories('.', 'main')
22inc_egl_dri2 = include_directories('drivers/dri2')
23
Dylan Baker108d2572017-10-18 12:20:43 -070024c_args_for_egl = []
25link_for_egl = []
26deps_for_egl = []
Eric Anholt4ba478d2018-07-16 15:57:24 -070027incs_for_egl = [inc_include, inc_drm_uapi, inc_src, inc_egl]
Alexander von Gluck IV834d2212018-02-16 16:56:31 -060028
Dylan Baker108d2572017-10-18 12:20:43 -070029files_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',
Emil Velikov7552fcb2015-07-24 16:19:55 +020041 'main/egldevice.c',
42 'main/egldevice.h',
Dylan Baker108d2572017-10-18 12:20:43 -070043 'main/egldisplay.c',
44 'main/egldisplay.h',
45 'main/egldriver.c',
46 'main/egldriver.h',
47 'main/eglfallbacks.c',
48 'main/eglglobals.c',
49 'main/eglglobals.h',
50 'main/eglimage.c',
51 'main/eglimage.h',
52 'main/egllog.c',
53 'main/egllog.h',
54 'main/eglsurface.c',
55 'main/eglsurface.h',
56 'main/eglsync.c',
57 'main/eglsync.h',
58 'main/eglentrypoint.h',
59 'main/egltypedefs.h',
Dylan Baker108d2572017-10-18 12:20:43 -070060)
61
Dylan Baker035ec7a2017-10-18 15:11:39 -070062g_egldispatchstubs_c = custom_target(
63 'g_egldispatchstubs.c',
64 input : [
Eric Engestrombdf6a5c2018-11-07 13:07:09 +000065 'generate/gen_egl_dispatch.py',
Dylan Baker035ec7a2017-10-18 15:11:39 -070066 'generate/egl.xml', 'generate/egl_other.xml'
67 ],
68 output : 'g_egldispatchstubs.c',
69 command : [
Eric Engestrombdf6a5c2018-11-07 13:07:09 +000070 prog_python, '@INPUT0@', 'source', '@INPUT1@', '@INPUT2@',
Dylan Baker035ec7a2017-10-18 15:11:39 -070071 ],
Emil Velikovcd0f11b2018-12-09 19:51:15 +000072 depend_files : [ files('generate/eglFunctionList.py'), genCommon_py, ],
Dylan Baker035ec7a2017-10-18 15:11:39 -070073 capture : true,
74)
75
76g_egldispatchstubs_h = custom_target(
77 'g_egldispatchstubs.h',
78 input : [
Eric Engestrombdf6a5c2018-11-07 13:07:09 +000079 'generate/gen_egl_dispatch.py',
Dylan Baker035ec7a2017-10-18 15:11:39 -070080 'generate/egl.xml', 'generate/egl_other.xml'
81 ],
82 output : 'g_egldispatchstubs.h',
83 command : [
Eric Engestrombdf6a5c2018-11-07 13:07:09 +000084 prog_python, '@INPUT0@', 'header', '@INPUT1@', '@INPUT2@',
Dylan Baker035ec7a2017-10-18 15:11:39 -070085 ],
Emil Velikovcd0f11b2018-12-09 19:51:15 +000086 depend_files : [ files('generate/eglFunctionList.py'), genCommon_py, ],
Dylan Baker035ec7a2017-10-18 15:11:39 -070087 capture : true,
88)
89
Alexander von Gluck IV834d2212018-02-16 16:56:31 -060090if with_dri2
91 files_egl += files(
92 'drivers/dri2/egl_dri2.c',
93 'drivers/dri2/egl_dri2.h',
94 'drivers/dri2/egl_dri2_fallbacks.h',
95 )
Alexander von Gluck IV834d2212018-02-16 16:56:31 -060096
Emil Velikov83c7fbb2018-08-18 13:23:11 +010097 if with_platform_x11
98 files_egl += files('drivers/dri2/platform_x11.c')
99 incs_for_egl += inc_loader
100 if with_dri3
101 files_egl += files('drivers/dri2/platform_x11_dri3.c')
102 link_for_egl += libloader_dri3_helper
103 endif
104 deps_for_egl += [dep_x11_xcb, dep_xcb_dri2, dep_xcb_xfixes]
Dylan Baker108d2572017-10-18 12:20:43 -0700105 endif
Emil Velikov83c7fbb2018-08-18 13:23:11 +0100106 if with_platform_drm
107 files_egl += files('drivers/dri2/platform_drm.c')
108 link_for_egl += [libloader, libgbm, libxmlconfig]
109 incs_for_egl += [inc_loader, inc_gbm, include_directories('../gbm/main')]
110 deps_for_egl += dep_libdrm
111 endif
112 if with_platform_surfaceless
113 files_egl += files('drivers/dri2/platform_surfaceless.c')
114 incs_for_egl += [inc_loader]
115 endif
116 if with_platform_wayland
117 deps_for_egl += [dep_wayland_client, dep_wayland_server, dep_wayland_egl_headers]
118 link_for_egl += libwayland_drm
119 files_egl += files('drivers/dri2/platform_wayland.c')
120 files_egl += [
121 linux_dmabuf_unstable_v1_protocol_c,
122 linux_dmabuf_unstable_v1_client_protocol_h,
123 wayland_drm_client_protocol_h,
124 ]
125 incs_for_egl += include_directories('wayland/wayland-drm')
126 endif
127 if with_platform_android
128 deps_for_egl += dep_android
129 files_egl += files('drivers/dri2/platform_android.c')
130 incs_for_egl += [inc_loader]
131 endif
132elif with_platform_haiku
Alexander von Gluck IV834d2212018-02-16 16:56:31 -0600133 incs_for_egl += inc_haikugl
134 c_args_for_egl += [
135 '-D_EGL_BUILT_IN_DRIVER_HAIKU',
136 ]
137 files_egl += files('drivers/haiku/egl_haiku.cpp')
138 link_for_egl += libgl
139 deps_for_egl += cpp.find_library('be')
140endif
Dylan Baker108d2572017-10-18 12:20:43 -0700141
Dylan Baker108d2572017-10-18 12:20:43 -0700142if cc.has_function('mincore')
143 c_args_for_egl += '-DHAVE_MINCORE'
144endif
145
Dylan Baker035ec7a2017-10-18 15:11:39 -0700146if not with_glvnd
147 egl_lib_name = 'EGL'
148 egl_lib_version = '1.0.0'
149else
150 egl_lib_name = 'EGL_mesa'
Eric Engestrom5be1b1a2017-11-02 23:24:00 +0000151 egl_lib_version = '0.0.0'
Dylan Baker035ec7a2017-10-18 15:11:39 -0700152 files_egl += [g_egldispatchstubs_h, g_egldispatchstubs_c]
153 files_egl += files('main/eglglvnd.c', 'main/egldispatchstubs.c')
154 install_data(
155 'main/50_mesa.json',
156 install_dir : join_paths(get_option('datadir'), 'glvnd', 'egl_vendor.d')
157 )
158endif
159
Dylan Baker108d2572017-10-18 12:20:43 -0700160libegl = shared_library(
Dylan Baker035ec7a2017-10-18 15:11:39 -0700161 egl_lib_name,
Dylan Baker108d2572017-10-18 12:20:43 -0700162 files_egl,
163 c_args : [
164 c_vis_args,
165 c_args_for_egl,
Dylan Baker108d2572017-10-18 12:20:43 -0700166 '-D_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_@0@'.format(egl_native_platform.to_upper()),
167 ],
Dylan Baker77f7ef02017-10-20 17:34:51 -0700168 include_directories : incs_for_egl,
Dylan Baker108d2572017-10-18 12:20:43 -0700169 link_with : [link_for_egl, libloader, libxmlconfig, libglapi, libmesa_util],
170 link_args : [ld_args_bsymbolic, ld_args_gc_sections],
171 dependencies : [deps_for_egl, dep_dl, dep_libdrm, dep_clock, dep_thread],
172 install : true,
Dylan Baker035ec7a2017-10-18 15:11:39 -0700173 version : egl_lib_version,
Dylan Baker108d2572017-10-18 12:20:43 -0700174)
175
Dylan Baker5c460332018-02-20 10:36:44 -0800176# If using glvnd the pkg-config header should not point to EGL_mesa, it should
177# point to EGL. glvnd is only available on unix like platforms so adding -l
178# should be safe here
179# TODO: in the glvnd case glvnd itself should really be providing this.
180if with_glvnd
181 _egl = '-L${libdir} -lEGL'
182else
183 _egl = libegl
184endif
185
Dylan Baker108d2572017-10-18 12:20:43 -0700186pkg.generate(
187 name : 'egl',
188 description : 'Mesa EGL Library',
189 version : meson.project_version(),
Dylan Baker5c460332018-02-20 10:36:44 -0800190 libraries : _egl,
Dylan Baker108d2572017-10-18 12:20:43 -0700191 libraries_private: gl_priv_libs,
192 requires_private : gl_priv_reqs,
193 extra_cflags : gl_pkgconfig_c_flags,
194)
195
196if with_tests
Eric Engestrom64f17442017-10-30 15:43:10 +0000197 if with_glvnd
198 # TODO: add glvnd symbol check
199 else
200 test('egl-symbols-check',
201 find_program('egl-symbols-check'),
Eric Engestrom11d45302018-02-23 17:02:08 +0000202 env : env_test,
Dylan Bakera9997982018-11-19 13:44:15 -0800203 args : libegl,
204 suite : ['egl'],
Eric Engestrom64f17442017-10-30 15:43:10 +0000205 )
206 endif
Eric Engestrom1946de22017-10-30 15:42:16 +0000207 test('egl-entrypoint-check',
208 find_program('egl-entrypoint-check'),
Dylan Bakera9997982018-11-19 13:44:15 -0800209 env : ['srcdir=' + meson.current_source_dir()],
210 suite : ['egl'],
Eric Engestrom1946de22017-10-30 15:42:16 +0000211 )
Dylan Baker108d2572017-10-18 12:20:43 -0700212endif