1bf215546Sopenharmony_ci# Copyright © 2017 Dylan Baker
2bf215546Sopenharmony_ci# Copyright © 2018 Intel Corporation
3bf215546Sopenharmony_ci
4bf215546Sopenharmony_ci# Permission is hereby granted, free of charge, to any person obtaining a copy
5bf215546Sopenharmony_ci# of this software and associated documentation files (the "Software"), to deal
6bf215546Sopenharmony_ci# in the Software without restriction, including without limitation the rights
7bf215546Sopenharmony_ci# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8bf215546Sopenharmony_ci# copies of the Software, and to permit persons to whom the Software is
9bf215546Sopenharmony_ci# furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci
11bf215546Sopenharmony_ci# The above copyright notice and this permission notice shall be included in
12bf215546Sopenharmony_ci# all copies or substantial portions of the Software.
13bf215546Sopenharmony_ci
14bf215546Sopenharmony_ci# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15bf215546Sopenharmony_ci# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16bf215546Sopenharmony_ci# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17bf215546Sopenharmony_ci# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18bf215546Sopenharmony_ci# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19bf215546Sopenharmony_ci# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20bf215546Sopenharmony_ci# SOFTWARE.
21bf215546Sopenharmony_ci
22bf215546Sopenharmony_ci# TODO: support non-static targets
23bf215546Sopenharmony_ci# Static targets are always enabled in autotools (unless you modify
24bf215546Sopenharmony_ci# configure.ac)
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_cigallium_dri_c_args = []
27bf215546Sopenharmony_cigallium_dri_ld_args = []
28bf215546Sopenharmony_cigallium_dri_link_depends = []
29bf215546Sopenharmony_cigallium_dri_drivers = []
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_ciif with_ld_version_script
32bf215546Sopenharmony_ci  gallium_dri_ld_args += ['-Wl,--version-script', join_paths(meson.current_source_dir(), 'dri.sym')]
33bf215546Sopenharmony_ci  gallium_dri_link_depends += files('dri.sym')
34bf215546Sopenharmony_ciendif
35bf215546Sopenharmony_ciif with_ld_dynamic_list
36bf215546Sopenharmony_ci  gallium_dri_ld_args += ['-Wl,--dynamic-list', join_paths(meson.current_source_dir(), '../dri-vdpau.dyn')]
37bf215546Sopenharmony_ci  gallium_dri_link_depends += files('../dri-vdpau.dyn')
38bf215546Sopenharmony_ciendif
39bf215546Sopenharmony_ci
40bf215546Sopenharmony_cilibgallium_dri = shared_library(
41bf215546Sopenharmony_ci  'gallium_dri',
42bf215546Sopenharmony_ci  files('target.c'),
43bf215546Sopenharmony_ci  include_directories : [
44bf215546Sopenharmony_ci    inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_util, inc_gallium_drivers,
45bf215546Sopenharmony_ci    inc_gallium_winsys, include_directories('../../frontends/dri'),
46bf215546Sopenharmony_ci  ],
47bf215546Sopenharmony_ci  gnu_symbol_visibility : 'hidden',
48bf215546Sopenharmony_ci  link_args : [ld_args_build_id, ld_args_gc_sections, gallium_dri_ld_args],
49bf215546Sopenharmony_ci  link_depends : gallium_dri_link_depends,
50bf215546Sopenharmony_ci  link_with : [
51bf215546Sopenharmony_ci    libdri, libmesa, libgalliumvl,
52bf215546Sopenharmony_ci    libgallium, libglapi, libpipe_loader_static, libws_null, libwsw, libswdri,
53bf215546Sopenharmony_ci    libswkmsdri,
54bf215546Sopenharmony_ci  ],
55bf215546Sopenharmony_ci  dependencies : [
56bf215546Sopenharmony_ci    dep_selinux, dep_libdrm, dep_llvm, dep_thread, idep_xmlconfig, idep_mesautil,
57bf215546Sopenharmony_ci    driver_swrast, driver_r300, driver_r600, driver_radeonsi, driver_nouveau,
58bf215546Sopenharmony_ci    driver_kmsro, driver_v3d, driver_vc4, driver_freedreno, driver_etnaviv,
59bf215546Sopenharmony_ci    driver_tegra, driver_i915, driver_svga, driver_virgl,
60bf215546Sopenharmony_ci    driver_panfrost, driver_iris, driver_lima, driver_zink, driver_d3d12,
61bf215546Sopenharmony_ci    driver_asahi, driver_crocus
62bf215546Sopenharmony_ci  ],
63bf215546Sopenharmony_ci  # Will be deleted during installation, see install_megadrivers.py
64bf215546Sopenharmony_ci  install : true,
65bf215546Sopenharmony_ci  install_dir : dri_drivers_path,
66bf215546Sopenharmony_ci  name_suffix : 'so',
67bf215546Sopenharmony_ci)
68bf215546Sopenharmony_ci
69bf215546Sopenharmony_ciforeach d : [[with_gallium_kmsro, [
70bf215546Sopenharmony_ci               'armada-drm_dri.so',
71bf215546Sopenharmony_ci               'exynos_dri.so',
72bf215546Sopenharmony_ci               'hx8357d_dri.so',
73bf215546Sopenharmony_ci               'ili9225_dri.so',
74bf215546Sopenharmony_ci               'ili9341_dri.so',
75bf215546Sopenharmony_ci               'imx-drm_dri.so',
76bf215546Sopenharmony_ci               'imx-dcss_dri.so',
77bf215546Sopenharmony_ci               'imx-lcdif_dri.so',
78bf215546Sopenharmony_ci               'ingenic-drm_dri.so',
79bf215546Sopenharmony_ci               'kirin_dri.so',
80bf215546Sopenharmony_ci               'komeda_dri.so',
81bf215546Sopenharmony_ci               'mali-dp_dri.so',
82bf215546Sopenharmony_ci               'mcde_dri.so',
83bf215546Sopenharmony_ci               'mediatek_dri.so',
84bf215546Sopenharmony_ci               'meson_dri.so',
85bf215546Sopenharmony_ci               'mi0283qt_dri.so',
86bf215546Sopenharmony_ci               'mxsfb-drm_dri.so',
87bf215546Sopenharmony_ci               'pl111_dri.so',
88bf215546Sopenharmony_ci               'rcar-du_dri.so',
89bf215546Sopenharmony_ci               'repaper_dri.so',
90bf215546Sopenharmony_ci               'rockchip_dri.so',
91bf215546Sopenharmony_ci               'st7586_dri.so',
92bf215546Sopenharmony_ci               'st7735r_dri.so',
93bf215546Sopenharmony_ci               'stm_dri.so',
94bf215546Sopenharmony_ci	       'sun4i-drm_dri.so',
95bf215546Sopenharmony_ci             ]],
96bf215546Sopenharmony_ci             [with_gallium_radeonsi, 'radeonsi_dri.so'],
97bf215546Sopenharmony_ci             [with_gallium_nouveau, 'nouveau_dri.so'],
98bf215546Sopenharmony_ci             [with_gallium_freedreno, ['msm_dri.so', 'kgsl_dri.so']],
99bf215546Sopenharmony_ci             [with_gallium_softpipe, 'swrast_dri.so'],
100bf215546Sopenharmony_ci             [with_gallium_softpipe and with_gallium_drisw_kms, 'kms_swrast_dri.so'],
101bf215546Sopenharmony_ci             [with_gallium_v3d, 'v3d_dri.so'],
102bf215546Sopenharmony_ci             [with_gallium_vc4, 'vc4_dri.so'],
103bf215546Sopenharmony_ci             [with_gallium_panfrost, 'panfrost_dri.so'],
104bf215546Sopenharmony_ci             [with_gallium_etnaviv, 'etnaviv_dri.so'],
105bf215546Sopenharmony_ci             [with_gallium_tegra, 'tegra_dri.so'],
106bf215546Sopenharmony_ci             [with_gallium_crocus, 'crocus_dri.so'],
107bf215546Sopenharmony_ci             [with_gallium_iris, 'iris_dri.so'],
108bf215546Sopenharmony_ci             [with_gallium_i915, 'i915_dri.so'],
109bf215546Sopenharmony_ci             [with_gallium_r300, 'r300_dri.so'],
110bf215546Sopenharmony_ci             [with_gallium_r600, 'r600_dri.so'],
111bf215546Sopenharmony_ci             [with_gallium_svga, 'vmwgfx_dri.so'],
112bf215546Sopenharmony_ci             [with_gallium_virgl or
113bf215546Sopenharmony_ci               (with_gallium_freedreno and with_freedreno_virtio),
114bf215546Sopenharmony_ci               'virtio_gpu_dri.so'],
115bf215546Sopenharmony_ci             [with_gallium_lima, 'lima_dri.so'],
116bf215546Sopenharmony_ci             [with_gallium_zink, 'zink_dri.so'],
117bf215546Sopenharmony_ci             [with_gallium_d3d12, 'd3d12_dri.so'],
118bf215546Sopenharmony_ci             [with_gallium_asahi, 'asahi_dri.so']]
119bf215546Sopenharmony_ci  if d[0]
120bf215546Sopenharmony_ci    gallium_dri_drivers += d[1]
121bf215546Sopenharmony_ci  endif
122bf215546Sopenharmony_ciendforeach
123bf215546Sopenharmony_ci
124bf215546Sopenharmony_ciif meson.version().version_compare('>= 0.58')
125bf215546Sopenharmony_ci  # This only works on Unix-like oses, which is probably fine for dri
126bf215546Sopenharmony_ci  prog_ln = find_program('ln', required : false)
127bf215546Sopenharmony_ci  if prog_ln.found()
128bf215546Sopenharmony_ci    devenv.set('LIBGL_DRIVERS_PATH', meson.current_build_dir())
129bf215546Sopenharmony_ci
130bf215546Sopenharmony_ci    foreach d : gallium_dri_drivers
131bf215546Sopenharmony_ci      custom_target(
132bf215546Sopenharmony_ci        'devenv_@0@'.format(d),
133bf215546Sopenharmony_ci        input : libgallium_dri,
134bf215546Sopenharmony_ci        output : d,
135bf215546Sopenharmony_ci        command : [prog_ln, '-f', '@INPUT@', '@OUTPUT@'],
136bf215546Sopenharmony_ci        build_by_default : true,
137bf215546Sopenharmony_ci      )
138bf215546Sopenharmony_ci    endforeach
139bf215546Sopenharmony_ci  endif
140bf215546Sopenharmony_ciendif
141bf215546Sopenharmony_ci
142bf215546Sopenharmony_cimeson.add_install_script(
143bf215546Sopenharmony_ci  install_megadrivers_py.path(),
144bf215546Sopenharmony_ci  libgallium_dri.full_path(),
145bf215546Sopenharmony_ci  dri_drivers_path,
146bf215546Sopenharmony_ci  gallium_dri_drivers,
147bf215546Sopenharmony_ci)
148