xref: /OK3568_Linux_fs/external/libmali/hook/meson.build (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1# The gbm functions that might be missing
2gbm_check_funcs = [
3  'gbm_bo_map',
4  'gbm_bo_unmap',
5  'gbm_bo_get_offset',
6  'gbm_bo_get_plane_count',
7  'gbm_device_get_format_modifier_plane_count',
8  'gbm_bo_get_handle_for_plane',
9  'gbm_bo_get_stride_for_plane',
10  'gbm_bo_get_fd_for_plane',
11  'gbm_bo_get_modifier',
12  'gbm_bo_create_with_modifiers',
13  'gbm_surface_create_with_modifiers',
14  'gbm_bo_get_bpp',
15  'gbm_format_get_name',
16]
17
18libhook_cflags = [
19  '-DLIBMALI_SO="libmali.so.' + mali_version.split('.')[0] + '"',
20]
21
22libhook_dep = [mali]
23libhook_dep += dependency('threads')
24libhook_dep += cc.find_library('dl', required : false)
25libhook_dep += dependency('libdrm', version : '>= 2.4.0')
26
27libhook_inc = []
28
29gbm_symbol = map['gbm'][0]
30if cc.has_function(gbm_symbol, dependencies : mali)
31  # Add hooks to support new GBM APIs
32  libhook_inc += include_directories('../include/GBM')
33  libhook_cflags += '-DHAS_GBM'
34  foreach symbol : gbm_check_funcs
35    if cc.has_function(symbol, dependencies : mali)
36      libhook_cflags += '-DHAS_' + symbol
37    endif
38  endforeach
39endif
40
41egl_symbol = map['egl'][0]
42if cc.has_function(egl_symbol, dependencies : mali)
43  # Add hooks to support default winsys
44  libhook_inc += include_directories('../include')
45  libhook_cflags += '-DHAS_EGL'
46
47  wayland_symbol = map['wayland-egl'][0]
48  if cc.has_function(wayland_symbol, dependencies : mali)
49    libhook_cflags += '-DHAS_WAYLAND'
50  endif
51
52  if has_x11
53    # Add hooks to init X11 threads
54    libhook_dep += dependency('x11')
55    libhook_cflags += '-DHAS_X11'
56  endif
57endif
58
59libhook = shared_library(
60  'mali_hook',
61  'hook.c',
62  c_args : libhook_cflags,
63  include_directories : libhook_inc,
64  dependencies : libhook_dep,
65  install : true,
66  version : mali_version)
67
68libhook_ldflags = ['-L${libdir}', '-lmali_hook']
69
70# A dummy library to ensure that the hook library would not be removed as unused
71libinjector = static_library(
72  'mali_hook_injector',
73  'injector.c',
74  install : true)
75
76# Ensure that the hook library would not be removed as unused
77libhook_ldflags += \
78  ['-Wl,--whole-archive', '-lmali_hook_injector', '-Wl,--no-whole-archive']
79