1# Copyright © 2017-2019 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
21inc_egl = include_directories('.', 'main')
22inc_egl_dri2 = include_directories('drivers/dri2')
23
24c_args_for_egl = [asan_c_args]
25cpp_args_for_egl = []
26link_for_egl = []
27deps_for_egl = []
28incs_for_egl = [inc_include, inc_src, inc_egl]
29
30files_egl = files(
31  'main/eglapi.c',
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/egldevice.c',
42  'main/egldevice.h',
43  'main/egldisplay.c',
44  'main/egldisplay.h',
45  'main/egldriver.h',
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
60g_egldispatchstubs_c = custom_target(
61  'g_egldispatchstubs.c',
62  input : [
63    'generate/gen_egl_dispatch.py',
64    'generate/egl.xml', 'generate/egl_other.xml'
65  ],
66  output : 'g_egldispatchstubs.c',
67  command : [
68    prog_python, '@INPUT0@', 'source', '@INPUT1@', '@INPUT2@',
69  ],
70  depend_files : [ files('generate/eglFunctionList.py'), genCommon_py, ],
71  capture : true,
72)
73
74g_egldispatchstubs_h = custom_target(
75  'g_egldispatchstubs.h',
76  input : [
77    'generate/gen_egl_dispatch.py',
78    'generate/egl.xml', 'generate/egl_other.xml'
79  ],
80  output : 'g_egldispatchstubs.h',
81  command : [
82    prog_python, '@INPUT0@', 'header', '@INPUT1@', '@INPUT2@',
83  ],
84  depend_files : [ files('generate/eglFunctionList.py'), genCommon_py, ],
85  capture : true,
86)
87
88if with_dri2
89  files_egl += files(
90    'drivers/dri2/egl_dri2.c',
91    'drivers/dri2/egl_dri2.h',
92  )
93  deps_for_egl += idep_xmlconfig
94  link_for_egl += libloader
95  incs_for_egl += inc_loader
96
97  files_egl += files(
98    'drivers/dri2/platform_device.c',
99    'drivers/dri2/platform_surfaceless.c',
100  )
101  if with_platform_x11
102    files_egl += files('drivers/dri2/platform_x11.c')
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_gbm and not with_platform_android
110    files_egl += files('drivers/dri2/platform_drm.c')
111    link_for_egl += libgbm
112    incs_for_egl += [inc_gbm, include_directories('../gbm/main')]
113    deps_for_egl += dep_libdrm
114  endif
115  if with_platform_wayland
116    deps_for_egl += [dep_wayland_client, dep_wayland_server, dep_wayland_egl_headers]
117    link_for_egl += libwayland_drm
118    files_egl += files('drivers/dri2/platform_wayland.c')
119    files_egl += [
120      linux_dmabuf_unstable_v1_protocol_c,
121      linux_dmabuf_unstable_v1_client_protocol_h,
122      wayland_drm_client_protocol_h,
123    ]
124    incs_for_egl += include_directories('wayland/wayland-drm')
125  endif
126  if with_platform_android
127    deps_for_egl += dep_android
128    files_egl += files('drivers/dri2/platform_android.c')
129    if dep_android_mapper4.found()
130      files_egl += files('drivers/dri2/platform_android_mapper.cpp')
131      c_args_for_egl += '-DUSE_IMAPPER4_METADATA_API'
132      cpp_args_for_egl += ['-std=c++17', '-DUSE_IMAPPER4_METADATA_API']
133    endif
134  endif
135elif with_platform_haiku
136  incs_for_egl += inc_haikugl
137  c_args_for_egl += [
138    '-D_EGL_BUILT_IN_DRIVER_HAIKU',
139  ]
140  files_egl += files('drivers/haiku/egl_haiku.cpp')
141  link_for_egl += libgl
142  deps_for_egl += cpp.find_library('be')
143elif with_platform_windows
144  c_args_for_egl += [
145    '-DEGLAPI=', '-DPUBLIC='
146  ]
147  files_egl += files('drivers/wgl/egl_wgl.c')
148  incs_for_egl += [inc_wgl, inc_gallium, inc_gallium_aux]
149  link_for_egl += libgallium_wgl
150endif
151
152if cc.has_function('mincore')
153  c_args_for_egl += '-DHAVE_MINCORE'
154endif
155
156if not with_glvnd
157  egl_lib_name = 'EGL' + get_option('egl-lib-suffix')
158  egl_lib_version = '1.0.0'
159  egl_lib_soversion = host_machine.system() == 'windows' ? '' : '1'
160else
161  egl_lib_name = 'EGL_@0@'.format(glvnd_vendor_name)
162  egl_lib_version = '0.0.0'
163  egl_lib_soversion = '0'
164  deps_for_egl += dep_glvnd
165  files_egl += [g_egldispatchstubs_h, g_egldispatchstubs_c]
166  files_egl += files('main/eglglvnd.c', 'main/egldispatchstubs.c')
167  glvnd_config = configuration_data()
168  glvnd_config.set('glvnd_vendor_name', get_option('glvnd-vendor-name'))
169  configure_file(
170    configuration: glvnd_config,
171    input : 'main/50_mesa.json',
172    output: '50_@0@.json'.format(glvnd_vendor_name),
173    install : true,
174    install_dir : join_paths(get_option('datadir'), 'glvnd', 'egl_vendor.d')
175  )
176endif
177
178libegl = shared_library(
179  egl_lib_name,
180  files_egl,
181  c_args : [
182    c_args_for_egl,
183    '-D_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_@0@'.format(egl_native_platform.to_upper()),
184  ],
185  cpp_args : [cpp_args_for_egl],
186  gnu_symbol_visibility : 'hidden',
187  include_directories : incs_for_egl,
188  link_with : [link_for_egl, libglapi],
189  link_args : [ld_args_bsymbolic, ld_args_gc_sections],
190  dependencies : [deps_for_egl, dep_dl, dep_libdrm, dep_clock, dep_thread, idep_mesautil],
191  install : true,
192  version : egl_lib_version,
193  soversion : egl_lib_soversion,
194  name_prefix : 'lib', # even on windows
195  vs_module_defs : 'main/egl.def'
196)
197
198if not with_glvnd
199  pkg.generate(
200    name : 'egl',
201    description : 'Mesa EGL Library',
202    version : meson.project_version(),
203    libraries : libegl,
204    libraries_private: gl_priv_libs,
205    requires_private : gl_priv_reqs,
206    extra_cflags : gl_pkgconfig_c_flags,
207  )
208endif
209
210if with_symbols_check
211  if with_glvnd
212    egl_symbols = files('egl-glvnd-symbols.txt')
213  else
214    egl_symbols = files('egl-symbols.txt')
215  endif
216  test('egl-symbols-check',
217    symbols_check,
218    args : [
219      '--lib', libegl,
220      '--symbols-file', egl_symbols,
221      symbols_check_args,
222    ],
223    suite : ['egl'],
224  )
225  test('egl-entrypoint-check',
226    prog_python,
227    args : files('egl-entrypoint-check.py', 'main/eglentrypoint.h'),
228    suite : ['egl'],
229  )
230endif
231