meson.build revision 7e102996
17e102996Smaya# Copyright © 2017 Intel Corporation
201e04c3fSmrg
301e04c3fSmrg# Permission is hereby granted, free of charge, to any person obtaining a copy
401e04c3fSmrg# of this software and associated documentation files (the "Software"), to deal
501e04c3fSmrg# in the Software without restriction, including without limitation the rights
601e04c3fSmrg# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
701e04c3fSmrg# copies of the Software, and to permit persons to whom the Software is
801e04c3fSmrg# furnished to do so, subject to the following conditions:
901e04c3fSmrg
1001e04c3fSmrg# The above copyright notice and this permission notice shall be included in
1101e04c3fSmrg# all copies or substantial portions of the Software.
1201e04c3fSmrg
1301e04c3fSmrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1401e04c3fSmrg# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1501e04c3fSmrg# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1601e04c3fSmrg# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1701e04c3fSmrg# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1801e04c3fSmrg# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1901e04c3fSmrg# SOFTWARE.
2001e04c3fSmrg
2101e04c3fSmrginc_egl = include_directories('.', 'main')
2201e04c3fSmrginc_egl_dri2 = include_directories('drivers/dri2')
2301e04c3fSmrg
2401e04c3fSmrgc_args_for_egl = []
2501e04c3fSmrglink_for_egl = []
2601e04c3fSmrgdeps_for_egl = []
277e102996Smayaincs_for_egl = [inc_include, inc_src, inc_egl]
2801e04c3fSmrg
2901e04c3fSmrgfiles_egl = files(
3001e04c3fSmrg  'main/eglapi.c',
3101e04c3fSmrg  'main/eglapi.h',
3201e04c3fSmrg  'main/eglarray.c',
3301e04c3fSmrg  'main/eglarray.h',
3401e04c3fSmrg  'main/eglconfig.c',
3501e04c3fSmrg  'main/eglconfig.h',
3601e04c3fSmrg  'main/eglcontext.c',
3701e04c3fSmrg  'main/eglcontext.h',
3801e04c3fSmrg  'main/eglcurrent.c',
3901e04c3fSmrg  'main/eglcurrent.h',
4001e04c3fSmrg  'main/egldefines.h',
4101e04c3fSmrg  'main/egldevice.c',
4201e04c3fSmrg  'main/egldevice.h',
4301e04c3fSmrg  'main/egldisplay.c',
4401e04c3fSmrg  'main/egldisplay.h',
4501e04c3fSmrg  'main/egldriver.c',
4601e04c3fSmrg  'main/egldriver.h',
4701e04c3fSmrg  'main/eglfallbacks.c',
4801e04c3fSmrg  'main/eglglobals.c',
4901e04c3fSmrg  'main/eglglobals.h',
5001e04c3fSmrg  'main/eglimage.c',
5101e04c3fSmrg  'main/eglimage.h',
5201e04c3fSmrg  'main/egllog.c',
5301e04c3fSmrg  'main/egllog.h',
5401e04c3fSmrg  'main/eglsurface.c',
5501e04c3fSmrg  'main/eglsurface.h',
5601e04c3fSmrg  'main/eglsync.c',
5701e04c3fSmrg  'main/eglsync.h',
5801e04c3fSmrg  'main/eglentrypoint.h',
5901e04c3fSmrg  'main/egltypedefs.h',
6001e04c3fSmrg)
6101e04c3fSmrg
6201e04c3fSmrgg_egldispatchstubs_c = custom_target(
6301e04c3fSmrg  'g_egldispatchstubs.c',
6401e04c3fSmrg  input : [
657e102996Smaya    'generate/gen_egl_dispatch.py',
6601e04c3fSmrg    'generate/egl.xml', 'generate/egl_other.xml'
6701e04c3fSmrg  ],
6801e04c3fSmrg  output : 'g_egldispatchstubs.c',
6901e04c3fSmrg  command : [
707e102996Smaya    prog_python, '@INPUT0@', 'source', '@INPUT1@', '@INPUT2@',
7101e04c3fSmrg  ],
727e102996Smaya  depend_files : [ files('generate/eglFunctionList.py'), genCommon_py, ],
7301e04c3fSmrg  capture : true,
7401e04c3fSmrg)
7501e04c3fSmrg
7601e04c3fSmrgg_egldispatchstubs_h = custom_target(
7701e04c3fSmrg  'g_egldispatchstubs.h',
7801e04c3fSmrg  input : [
797e102996Smaya    'generate/gen_egl_dispatch.py',
8001e04c3fSmrg    'generate/egl.xml', 'generate/egl_other.xml'
8101e04c3fSmrg  ],
8201e04c3fSmrg  output : 'g_egldispatchstubs.h',
8301e04c3fSmrg  command : [
847e102996Smaya    prog_python, '@INPUT0@', 'header', '@INPUT1@', '@INPUT2@',
8501e04c3fSmrg  ],
867e102996Smaya  depend_files : [ files('generate/eglFunctionList.py'), genCommon_py, ],
8701e04c3fSmrg  capture : true,
8801e04c3fSmrg)
8901e04c3fSmrg
9001e04c3fSmrgif with_dri2
9101e04c3fSmrg  files_egl += files(
9201e04c3fSmrg    'drivers/dri2/egl_dri2.c',
9301e04c3fSmrg    'drivers/dri2/egl_dri2.h',
9401e04c3fSmrg    'drivers/dri2/egl_dri2_fallbacks.h',
9501e04c3fSmrg  )
96993e1d59Smrg  link_for_egl += [libloader, libxmlconfig]
97993e1d59Smrg  incs_for_egl += inc_loader
9801e04c3fSmrg
9901e04c3fSmrg  if with_platform_x11
10001e04c3fSmrg    files_egl += files('drivers/dri2/platform_x11.c')
10101e04c3fSmrg    if with_dri3
10201e04c3fSmrg      files_egl += files('drivers/dri2/platform_x11_dri3.c')
10301e04c3fSmrg      link_for_egl += libloader_dri3_helper
10401e04c3fSmrg    endif
10501e04c3fSmrg    deps_for_egl += [dep_x11_xcb, dep_xcb_dri2, dep_xcb_xfixes]
10601e04c3fSmrg  endif
10701e04c3fSmrg  if with_platform_drm
10801e04c3fSmrg    files_egl += files('drivers/dri2/platform_drm.c')
109993e1d59Smrg    link_for_egl += libgbm
110993e1d59Smrg    incs_for_egl += [inc_gbm, include_directories('../gbm/main')]
11101e04c3fSmrg    deps_for_egl += dep_libdrm
11201e04c3fSmrg  endif
11301e04c3fSmrg  if with_platform_surfaceless
11401e04c3fSmrg    files_egl += files('drivers/dri2/platform_surfaceless.c')
11501e04c3fSmrg  endif
11601e04c3fSmrg  if with_platform_wayland
11701e04c3fSmrg    deps_for_egl += [dep_wayland_client, dep_wayland_server, dep_wayland_egl_headers]
11801e04c3fSmrg    link_for_egl += libwayland_drm
11901e04c3fSmrg    files_egl += files('drivers/dri2/platform_wayland.c')
12001e04c3fSmrg    files_egl += [
12101e04c3fSmrg      linux_dmabuf_unstable_v1_protocol_c,
12201e04c3fSmrg      linux_dmabuf_unstable_v1_client_protocol_h,
12301e04c3fSmrg      wayland_drm_client_protocol_h,
12401e04c3fSmrg    ]
12501e04c3fSmrg    incs_for_egl += include_directories('wayland/wayland-drm')
12601e04c3fSmrg  endif
12701e04c3fSmrg  if with_platform_android
12801e04c3fSmrg    deps_for_egl += dep_android
12901e04c3fSmrg    files_egl += files('drivers/dri2/platform_android.c')
13001e04c3fSmrg  endif
13101e04c3fSmrgelif with_platform_haiku
13201e04c3fSmrg  incs_for_egl += inc_haikugl
13301e04c3fSmrg  c_args_for_egl += [
13401e04c3fSmrg    '-D_EGL_BUILT_IN_DRIVER_HAIKU',
13501e04c3fSmrg  ]
13601e04c3fSmrg  files_egl += files('drivers/haiku/egl_haiku.cpp')
13701e04c3fSmrg  link_for_egl += libgl
13801e04c3fSmrg  deps_for_egl += cpp.find_library('be')
13901e04c3fSmrgendif
14001e04c3fSmrg
14101e04c3fSmrgif cc.has_function('mincore')
14201e04c3fSmrg  c_args_for_egl += '-DHAVE_MINCORE'
14301e04c3fSmrgendif
14401e04c3fSmrg
14501e04c3fSmrgif not with_glvnd
1467e102996Smaya  egl_lib_name = 'EGL' + get_option('egl-lib-suffix')
14701e04c3fSmrg  egl_lib_version = '1.0.0'
14801e04c3fSmrgelse
14901e04c3fSmrg  egl_lib_name = 'EGL_mesa'
15001e04c3fSmrg  egl_lib_version = '0.0.0'
15101e04c3fSmrg  files_egl += [g_egldispatchstubs_h, g_egldispatchstubs_c]
15201e04c3fSmrg  files_egl += files('main/eglglvnd.c', 'main/egldispatchstubs.c')
15301e04c3fSmrg  install_data(
15401e04c3fSmrg    'main/50_mesa.json',
15501e04c3fSmrg    install_dir : join_paths(get_option('datadir'), 'glvnd', 'egl_vendor.d')
15601e04c3fSmrg  )
15701e04c3fSmrgendif
15801e04c3fSmrg
15901e04c3fSmrglibegl = shared_library(
16001e04c3fSmrg  egl_lib_name,
16101e04c3fSmrg  files_egl,
16201e04c3fSmrg  c_args : [
16301e04c3fSmrg    c_vis_args,
16401e04c3fSmrg    c_args_for_egl,
16501e04c3fSmrg    '-D_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_@0@'.format(egl_native_platform.to_upper()),
16601e04c3fSmrg  ],
16701e04c3fSmrg  include_directories : incs_for_egl,
168993e1d59Smrg  link_with : [link_for_egl, libglapi, libmesa_util],
16901e04c3fSmrg  link_args : [ld_args_bsymbolic, ld_args_gc_sections],
17001e04c3fSmrg  dependencies : [deps_for_egl, dep_dl, dep_libdrm, dep_clock, dep_thread],
17101e04c3fSmrg  install : true,
17201e04c3fSmrg  version : egl_lib_version,
17301e04c3fSmrg)
17401e04c3fSmrg
17501e04c3fSmrg# If using glvnd the pkg-config header should not point to EGL_mesa, it should
17601e04c3fSmrg# point to EGL. glvnd is only available on unix like platforms so adding -l
17701e04c3fSmrg# should be safe here
17801e04c3fSmrg# TODO: in the glvnd case glvnd itself should really be providing this.
17901e04c3fSmrgif with_glvnd
18001e04c3fSmrg  _egl = '-L${libdir} -lEGL'
18101e04c3fSmrgelse
18201e04c3fSmrg  _egl = libegl
18301e04c3fSmrgendif
18401e04c3fSmrg
18501e04c3fSmrgpkg.generate(
18601e04c3fSmrg  name : 'egl',
18701e04c3fSmrg  description : 'Mesa EGL Library',
18801e04c3fSmrg  version : meson.project_version(),
18901e04c3fSmrg  libraries : _egl,
19001e04c3fSmrg  libraries_private: gl_priv_libs,
19101e04c3fSmrg  requires_private : gl_priv_reqs,
19201e04c3fSmrg  extra_cflags : gl_pkgconfig_c_flags,
19301e04c3fSmrg)
19401e04c3fSmrg
1957e102996Smayaif with_tests and prog_nm.found()
19601e04c3fSmrg  if with_glvnd
19701e04c3fSmrg    # TODO: add glvnd symbol check
19801e04c3fSmrg  else
19901e04c3fSmrg    test('egl-symbols-check',
20001e04c3fSmrg      find_program('egl-symbols-check'),
20101e04c3fSmrg      env : env_test,
2027e102996Smaya      args : libegl,
2037e102996Smaya      suite : ['egl'],
20401e04c3fSmrg    )
20501e04c3fSmrg  endif
20601e04c3fSmrg  test('egl-entrypoint-check',
20701e04c3fSmrg    find_program('egl-entrypoint-check'),
2087e102996Smaya    env : ['srcdir=' + meson.current_source_dir()],
2097e102996Smaya    suite : ['egl'],
21001e04c3fSmrg  )
21101e04c3fSmrgendif
212