1b8e80941Smrg# Copyright © 2017 Intel Corporation
2b8e80941Smrg
3b8e80941Smrg# Permission is hereby granted, free of charge, to any person obtaining a copy
4b8e80941Smrg# of this software and associated documentation files (the "Software"), to deal
5b8e80941Smrg# in the Software without restriction, including without limitation the rights
6b8e80941Smrg# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7b8e80941Smrg# copies of the Software, and to permit persons to whom the Software is
8b8e80941Smrg# furnished to do so, subject to the following conditions:
9b8e80941Smrg
10b8e80941Smrg# The above copyright notice and this permission notice shall be included in
11b8e80941Smrg# all copies or substantial portions of the Software.
12b8e80941Smrg
13b8e80941Smrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14b8e80941Smrg# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15b8e80941Smrg# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16b8e80941Smrg# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17b8e80941Smrg# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18b8e80941Smrg# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19b8e80941Smrg# SOFTWARE.
20b8e80941Smrg
21b8e80941Smrgopencl_link_args = []
22b8e80941Smrgopencl_link_deps = []
23b8e80941Smrgopencl_version = '1'
24b8e80941Smrg
25b8e80941Smrgif with_ld_version_script
26b8e80941Smrg  opencl_link_args += [
27b8e80941Smrg    '-Wl,--version-script', join_paths(meson.current_source_dir(), 'opencl.sym')
28b8e80941Smrg  ]
29b8e80941Smrg  opencl_link_deps += files('opencl.sym')
30b8e80941Smrgendif
31b8e80941Smrg
32b8e80941Smrgllvm_libdir = dep_llvm.get_configtool_variable('libdir')
33b8e80941Smrg
34b8e80941Smrgopencl_libname = with_opencl_icd ? 'MesaOpenCL' : 'OpenCL'
35b8e80941Smrg
36b8e80941Smrglibopencl = shared_library(
37b8e80941Smrg  opencl_libname,
38b8e80941Smrg  [],
39b8e80941Smrg  link_args : [ld_args_gc_sections, opencl_link_args],
40b8e80941Smrg  link_depends : opencl_link_deps,
41b8e80941Smrg  link_whole : libclover,
42b8e80941Smrg  link_with : [libpipe_loader_dynamic, libgallium, libmesa_util],
43b8e80941Smrg  dependencies : [
44b8e80941Smrg    dep_thread, dep_clock, dep_dl, dep_unwind, dep_elf, dep_expat,
45b8e80941Smrg    cpp.find_library('clangCodeGen', dirs : llvm_libdir),
46b8e80941Smrg    cpp.find_library('clangFrontendTool', dirs : llvm_libdir),
47b8e80941Smrg    cpp.find_library('clangFrontend', dirs : llvm_libdir),
48b8e80941Smrg    cpp.find_library('clangDriver', dirs : llvm_libdir),
49b8e80941Smrg    cpp.find_library('clangSerialization', dirs : llvm_libdir),
50b8e80941Smrg    cpp.find_library('clangParse', dirs : llvm_libdir),
51b8e80941Smrg    cpp.find_library('clangSema', dirs : llvm_libdir),
52b8e80941Smrg    cpp.find_library('clangAnalysis', dirs : llvm_libdir),
53b8e80941Smrg    cpp.find_library('clangAST', dirs : llvm_libdir),
54b8e80941Smrg    cpp.find_library('clangEdit', dirs : llvm_libdir),
55b8e80941Smrg    cpp.find_library('clangLex', dirs : llvm_libdir),
56b8e80941Smrg    cpp.find_library('clangBasic', dirs : llvm_libdir),
57b8e80941Smrg  ],
58b8e80941Smrg  version : '@0@.0.0'.format(opencl_version),
59b8e80941Smrg  install : true,
60b8e80941Smrg)
61b8e80941Smrg
62b8e80941Smrgif with_opencl_icd
63b8e80941Smrg  _config = configuration_data()
64b8e80941Smrg  _config.set('OPENCL_LIBNAME', 'MesaOpenCL')
65b8e80941Smrg  _config.set('OPENCL_VERSION', opencl_version)
66b8e80941Smrg  configure_file(
67b8e80941Smrg    configuration : _config,
68b8e80941Smrg    input : 'mesa.icd.in',
69b8e80941Smrg    output : 'mesa.icd',
70b8e80941Smrg    install : true,
71b8e80941Smrg    install_dir : join_paths(get_option('sysconfdir'), 'OpenCL', 'vendors'),
72b8e80941Smrg  )
73b8e80941Smrgendif
74