1 # Copyright © 2017 Intel Corporation
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:
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
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
25 if with_ld_version_script
27 '-Wl,--version-script', join_paths(meson.current_source_dir(), 'opencl.sym')
29 opencl_link_deps += files('opencl.sym')
32 llvm_libdir = dep_llvm.get_configtool_variable('libdir')
33 opencl_libname = with_opencl_icd ? 'MesaOpenCL' : 'OpenCL'
36 polly_isl_dep = null_dep
37 if dep_llvm.version().version_compare('>=10.0.0')
38 polly_dep = cpp.find_library('Polly', dirs : llvm_libdir, required : false)
39 polly_isl_dep = cpp.find_library('PollyISL', dirs : llvm_libdir, required : false)
42 dep_clang = cpp.find_library('clang-cpp', dirs : llvm_libdir, required : false)
44 # meson will return clang-cpp from system dirs if it's not found in llvm_libdir
45 linker_rpath_arg = '-Wl,--rpath=@0@'.format(llvm_libdir)
47 #include <clang/Basic/Version.h>
49 size_t found_pos = clang::getClangFullVersion().find(CLANG_VERSION_STRING);
50 return found_pos == ::std::string::npos ? 1 : 0;
53 can_check_clang = (not meson.is_cross_build() or meson.has_exe_wrapper()) and cpp.has_link_argument(linker_rpath_arg)
55 test_run = cpp.run(clang_test_code, name : 'dep-clang-usable',
56 dependencies : [dep_llvm, dep_clang], args : linker_rpath_arg)
57 dep_clang_usable = test_run.compiled() and test_run.returncode() == 0
59 dep_clang_usable = true
61 if not (dep_clang.found() and dep_clang_usable)
63 cpp.find_library('clangCodeGen', dirs : llvm_libdir),
64 cpp.find_library('clangFrontendTool', dirs : llvm_libdir),
65 cpp.find_library('clangFrontend', dirs : llvm_libdir),
66 cpp.find_library('clangDriver', dirs : llvm_libdir),
67 cpp.find_library('clangSerialization', dirs : llvm_libdir),
68 cpp.find_library('clangParse', dirs : llvm_libdir),
69 cpp.find_library('clangSema', dirs : llvm_libdir),
70 cpp.find_library('clangAnalysis', dirs : llvm_libdir),
71 cpp.find_library('clangAST', dirs : llvm_libdir),
72 cpp.find_library('clangASTMatchers', dirs : llvm_libdir),
73 cpp.find_library('clangEdit', dirs : llvm_libdir),
74 cpp.find_library('clangLex', dirs : llvm_libdir),
75 cpp.find_library('clangBasic', dirs : llvm_libdir),
76 polly_dep, polly_isl_dep,
78 # check clang once more
80 test_run = cpp.run(clang_test_code, name : 'dep-clang-usable',
81 dependencies : [dep_llvm, dep_clang], args : linker_rpath_arg)
82 if not test_run.compiled() or test_run.returncode() != 0
83 error('No usable clang found!')
88 libopencl = shared_library(
91 link_args : [ld_args_gc_sections, opencl_link_args],
92 link_depends : opencl_link_deps,
93 link_whole : libclover,
94 link_with : [libpipe_loader_dynamic, libgallium],
97 dep_clock, dep_dl, dep_unwind, dep_elf, dep_clang
99 version : '@0@.0.0'.format(opencl_version),
104 _config = configuration_data()
105 _config.set('OPENCL_LIBNAME', 'MesaOpenCL')
106 _config.set('OPENCL_VERSION', opencl_version)
108 configuration : _config,
109 input : 'mesa.icd.in',
112 install_dir : join_paths(get_option('sysconfdir'), 'OpenCL', 'vendors'),