Emil Velikov | cd0f11b | 2018-12-09 19:51:15 +0000 | [diff] [blame] | 1 | # Copyright © 2017 Intel Corporation |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 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 | |
Dylan Baker | 6f62895 | 2018-03-06 10:36:42 -0800 | [diff] [blame] | 21 | inc_egl = include_directories('.', 'main') |
| 22 | inc_egl_dri2 = include_directories('drivers/dri2') |
| 23 | |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 24 | c_args_for_egl = [] |
| 25 | link_for_egl = [] |
| 26 | deps_for_egl = [] |
Eric Engestrom | f137480 | 2019-02-12 18:18:03 +0000 | [diff] [blame] | 27 | incs_for_egl = [inc_include, inc_src, inc_egl] |
Alexander von Gluck IV | 834d221 | 2018-02-16 16:56:31 -0600 | [diff] [blame] | 28 | |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 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', |
Emil Velikov | 7552fcb | 2015-07-24 16:19:55 +0200 | [diff] [blame] | 41 | 'main/egldevice.c', |
| 42 | 'main/egldevice.h', |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 43 | 'main/egldisplay.c', |
| 44 | 'main/egldisplay.h', |
| 45 | 'main/egldriver.c', |
| 46 | 'main/egldriver.h', |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 47 | 'main/eglglobals.c', |
| 48 | 'main/eglglobals.h', |
| 49 | 'main/eglimage.c', |
| 50 | 'main/eglimage.h', |
| 51 | 'main/egllog.c', |
| 52 | 'main/egllog.h', |
| 53 | 'main/eglsurface.c', |
| 54 | 'main/eglsurface.h', |
| 55 | 'main/eglsync.c', |
| 56 | 'main/eglsync.h', |
| 57 | 'main/eglentrypoint.h', |
| 58 | 'main/egltypedefs.h', |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 59 | ) |
| 60 | |
Dylan Baker | 035ec7a | 2017-10-18 15:11:39 -0700 | [diff] [blame] | 61 | g_egldispatchstubs_c = custom_target( |
| 62 | 'g_egldispatchstubs.c', |
| 63 | input : [ |
Eric Engestrom | bdf6a5c | 2018-11-07 13:07:09 +0000 | [diff] [blame] | 64 | 'generate/gen_egl_dispatch.py', |
Dylan Baker | 035ec7a | 2017-10-18 15:11:39 -0700 | [diff] [blame] | 65 | 'generate/egl.xml', 'generate/egl_other.xml' |
| 66 | ], |
| 67 | output : 'g_egldispatchstubs.c', |
| 68 | command : [ |
Eric Engestrom | bdf6a5c | 2018-11-07 13:07:09 +0000 | [diff] [blame] | 69 | prog_python, '@INPUT0@', 'source', '@INPUT1@', '@INPUT2@', |
Dylan Baker | 035ec7a | 2017-10-18 15:11:39 -0700 | [diff] [blame] | 70 | ], |
Emil Velikov | cd0f11b | 2018-12-09 19:51:15 +0000 | [diff] [blame] | 71 | depend_files : [ files('generate/eglFunctionList.py'), genCommon_py, ], |
Dylan Baker | 035ec7a | 2017-10-18 15:11:39 -0700 | [diff] [blame] | 72 | capture : true, |
| 73 | ) |
| 74 | |
| 75 | g_egldispatchstubs_h = custom_target( |
| 76 | 'g_egldispatchstubs.h', |
| 77 | input : [ |
Eric Engestrom | bdf6a5c | 2018-11-07 13:07:09 +0000 | [diff] [blame] | 78 | 'generate/gen_egl_dispatch.py', |
Dylan Baker | 035ec7a | 2017-10-18 15:11:39 -0700 | [diff] [blame] | 79 | 'generate/egl.xml', 'generate/egl_other.xml' |
| 80 | ], |
| 81 | output : 'g_egldispatchstubs.h', |
| 82 | command : [ |
Eric Engestrom | bdf6a5c | 2018-11-07 13:07:09 +0000 | [diff] [blame] | 83 | prog_python, '@INPUT0@', 'header', '@INPUT1@', '@INPUT2@', |
Dylan Baker | 035ec7a | 2017-10-18 15:11:39 -0700 | [diff] [blame] | 84 | ], |
Emil Velikov | cd0f11b | 2018-12-09 19:51:15 +0000 | [diff] [blame] | 85 | depend_files : [ files('generate/eglFunctionList.py'), genCommon_py, ], |
Dylan Baker | 035ec7a | 2017-10-18 15:11:39 -0700 | [diff] [blame] | 86 | capture : true, |
| 87 | ) |
| 88 | |
Alexander von Gluck IV | 834d221 | 2018-02-16 16:56:31 -0600 | [diff] [blame] | 89 | if with_dri2 |
| 90 | files_egl += files( |
| 91 | 'drivers/dri2/egl_dri2.c', |
| 92 | 'drivers/dri2/egl_dri2.h', |
| 93 | 'drivers/dri2/egl_dri2_fallbacks.h', |
| 94 | ) |
Emil Velikov | f0a7b46 | 2019-02-14 11:23:58 +0000 | [diff] [blame] | 95 | link_for_egl += [libloader, libxmlconfig] |
| 96 | incs_for_egl += inc_loader |
Alexander von Gluck IV | 834d221 | 2018-02-16 16:56:31 -0600 | [diff] [blame] | 97 | |
Emil Velikov | d6edcce | 2019-05-16 18:01:40 +0100 | [diff] [blame] | 98 | files_egl += files('drivers/dri2/platform_device.c') |
Emil Velikov | 83c7fbb | 2018-08-18 13:23:11 +0100 | [diff] [blame] | 99 | if with_platform_x11 |
| 100 | files_egl += files('drivers/dri2/platform_x11.c') |
Emil Velikov | 83c7fbb | 2018-08-18 13:23:11 +0100 | [diff] [blame] | 101 | if with_dri3 |
| 102 | files_egl += files('drivers/dri2/platform_x11_dri3.c') |
| 103 | link_for_egl += libloader_dri3_helper |
| 104 | endif |
| 105 | deps_for_egl += [dep_x11_xcb, dep_xcb_dri2, dep_xcb_xfixes] |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 106 | endif |
Emil Velikov | 83c7fbb | 2018-08-18 13:23:11 +0100 | [diff] [blame] | 107 | if with_platform_drm |
| 108 | files_egl += files('drivers/dri2/platform_drm.c') |
Emil Velikov | f0a7b46 | 2019-02-14 11:23:58 +0000 | [diff] [blame] | 109 | link_for_egl += libgbm |
| 110 | incs_for_egl += [inc_gbm, include_directories('../gbm/main')] |
Emil Velikov | 83c7fbb | 2018-08-18 13:23:11 +0100 | [diff] [blame] | 111 | deps_for_egl += dep_libdrm |
| 112 | endif |
| 113 | if with_platform_surfaceless |
| 114 | files_egl += files('drivers/dri2/platform_surfaceless.c') |
Emil Velikov | 83c7fbb | 2018-08-18 13:23:11 +0100 | [diff] [blame] | 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') |
Emil Velikov | 83c7fbb | 2018-08-18 13:23:11 +0100 | [diff] [blame] | 130 | endif |
| 131 | elif with_platform_haiku |
Alexander von Gluck IV | 834d221 | 2018-02-16 16:56:31 -0600 | [diff] [blame] | 132 | incs_for_egl += inc_haikugl |
| 133 | c_args_for_egl += [ |
| 134 | '-D_EGL_BUILT_IN_DRIVER_HAIKU', |
| 135 | ] |
| 136 | files_egl += files('drivers/haiku/egl_haiku.cpp') |
| 137 | link_for_egl += libgl |
| 138 | deps_for_egl += cpp.find_library('be') |
| 139 | endif |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 140 | |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 141 | if cc.has_function('mincore') |
| 142 | c_args_for_egl += '-DHAVE_MINCORE' |
| 143 | endif |
| 144 | |
Dylan Baker | 035ec7a | 2017-10-18 15:11:39 -0700 | [diff] [blame] | 145 | if not with_glvnd |
Benjamin Gordon | b30aad5 | 2018-06-13 16:17:32 -0600 | [diff] [blame] | 146 | egl_lib_name = 'EGL' + get_option('egl-lib-suffix') |
Dylan Baker | 035ec7a | 2017-10-18 15:11:39 -0700 | [diff] [blame] | 147 | egl_lib_version = '1.0.0' |
| 148 | else |
| 149 | egl_lib_name = 'EGL_mesa' |
Eric Engestrom | 5be1b1a | 2017-11-02 23:24:00 +0000 | [diff] [blame] | 150 | egl_lib_version = '0.0.0' |
Dylan Baker | 035ec7a | 2017-10-18 15:11:39 -0700 | [diff] [blame] | 151 | files_egl += [g_egldispatchstubs_h, g_egldispatchstubs_c] |
| 152 | files_egl += files('main/eglglvnd.c', 'main/egldispatchstubs.c') |
| 153 | install_data( |
| 154 | 'main/50_mesa.json', |
| 155 | install_dir : join_paths(get_option('datadir'), 'glvnd', 'egl_vendor.d') |
| 156 | ) |
| 157 | endif |
| 158 | |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 159 | libegl = shared_library( |
Dylan Baker | 035ec7a | 2017-10-18 15:11:39 -0700 | [diff] [blame] | 160 | egl_lib_name, |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 161 | files_egl, |
| 162 | c_args : [ |
| 163 | c_vis_args, |
| 164 | c_args_for_egl, |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 165 | '-D_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_@0@'.format(egl_native_platform.to_upper()), |
| 166 | ], |
Dylan Baker | 77f7ef0 | 2017-10-20 17:34:51 -0700 | [diff] [blame] | 167 | include_directories : incs_for_egl, |
Emil Velikov | f0a7b46 | 2019-02-14 11:23:58 +0000 | [diff] [blame] | 168 | link_with : [link_for_egl, libglapi, libmesa_util], |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 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, |
Dylan Baker | 035ec7a | 2017-10-18 15:11:39 -0700 | [diff] [blame] | 172 | version : egl_lib_version, |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 173 | ) |
| 174 | |
Dylan Baker | 5c46033 | 2018-02-20 10:36:44 -0800 | [diff] [blame] | 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. |
| 179 | if with_glvnd |
| 180 | _egl = '-L${libdir} -lEGL' |
| 181 | else |
| 182 | _egl = libegl |
| 183 | endif |
| 184 | |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 185 | pkg.generate( |
| 186 | name : 'egl', |
| 187 | description : 'Mesa EGL Library', |
| 188 | version : meson.project_version(), |
Dylan Baker | 5c46033 | 2018-02-20 10:36:44 -0800 | [diff] [blame] | 189 | libraries : _egl, |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 190 | libraries_private: gl_priv_libs, |
| 191 | requires_private : gl_priv_reqs, |
| 192 | extra_cflags : gl_pkgconfig_c_flags, |
| 193 | ) |
| 194 | |
Dylan Baker | ff9bf22 | 2018-05-17 13:44:30 -0700 | [diff] [blame] | 195 | if with_tests and prog_nm.found() |
Eric Engestrom | 64f1744 | 2017-10-30 15:43:10 +0000 | [diff] [blame] | 196 | if with_glvnd |
| 197 | # TODO: add glvnd symbol check |
| 198 | else |
| 199 | test('egl-symbols-check', |
| 200 | find_program('egl-symbols-check'), |
Eric Engestrom | 11d4530 | 2018-02-23 17:02:08 +0000 | [diff] [blame] | 201 | env : env_test, |
Dylan Baker | a999798 | 2018-11-19 13:44:15 -0800 | [diff] [blame] | 202 | args : libegl, |
| 203 | suite : ['egl'], |
Eric Engestrom | 64f1744 | 2017-10-30 15:43:10 +0000 | [diff] [blame] | 204 | ) |
| 205 | endif |
Eric Engestrom | 1946de2 | 2017-10-30 15:42:16 +0000 | [diff] [blame] | 206 | test('egl-entrypoint-check', |
| 207 | find_program('egl-entrypoint-check'), |
Dylan Baker | a999798 | 2018-11-19 13:44:15 -0800 | [diff] [blame] | 208 | env : ['srcdir=' + meson.current_source_dir()], |
| 209 | suite : ['egl'], |
Eric Engestrom | 1946de2 | 2017-10-30 15:42:16 +0000 | [diff] [blame] | 210 | ) |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 211 | endif |