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