File OpenCL-ICD-Loader.spec of Package OpenCL-ICD-Loader
#
# spec file for package OpenCL-ICD-Loader
#
# Copyright (c) 2020, Martin Hauke <mardnh@gmx.de>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: OpenCL-ICD-Loader
Version: 2020.06.16
Release: 0
Summary: OpenCL ICD Loader by The Khronos Group
License: Apache-2.0
URL: https://github.com/KhronosGroup/OpenCL-ICD-Loader
Source: https://github.com/KhronosGroup/OpenCL-ICD-Loader/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Patch0: 0001-Use-usr-etc-OpenCL-vendors-as-ICD_VENDOR_PATH.patch
BuildRequires: cmake
BuildRequires: gcc-c++
BuildRequires: opencl-headers >= 2.2
BuildRequires: pkgconfig
%description
OpenCL is a royalty-free standard for cross-platform, parallel programming
of modern processors found in personal computers, servers and
handheld/embedded devices.
This package provides the Installable Client Driver Bindings (ICD Bindings).
The provided libOpenCL library is able to load any free or non-free installed
ICD (driver backend).
%package -n libOpenCL1
Summary: OpenCL ICD Bindings by The Khronos Group
Suggests: pocl
%if (0%{?sle_version} >= 150100 || 0%{?suse_version} >= 1550)
Requires(post): update-alternatives
Requires(pre): update-alternatives
%endif
%description -n libOpenCL1
OpenCL is a royalty-free standard for cross-platform, parallel programming
of modern processors found in personal computers, servers and
handheld/embedded devices.
This package provides an Installable Client Driver Bindings (ICD Bindings).
The provided libOpenCL library is able to load any free or non-free installed
ICD (driver backend).
%package devel
Summary: Development files for the Khronos Group ICD Loader
Requires: libOpenCL1 = %{version}
Requires: opencl-headers >= 2.2
%description devel
This package provides the files needed to build OpenCL client drivers that
use the official Khronos Group OpenCL-ICD-Loader for ICD functionality.
%prep
%setup -q
%patch0 -p1
%build
%cmake \
-DOPENCL_INCLUDE_DIRS=/usr/include
%cmake_build
%install
%cmake_install
%if (0%{?sle_version} >= 150100 || 0%{?suse_version} >= 1550)
install -d %{buildroot}/%{_sysconfdir}/alternatives \
%{buildroot}/%{_libdir}/OpenCL-ICD-Loader
mv %{buildroot}/%{_libdir}/libOpenCL.so.1* %{buildroot}/%{_libdir}/OpenCL-ICD-Loader/
ln -snf OpenCL-ICD-Loader/libOpenCL.so.1 %{buildroot}/%{_libdir}/libOpenCL.so
# dummy target for update-alternatives
ln -s %{_sysconfdir}/alternatives/libOpenCL.so.1 %{buildroot}/%{_libdir}/libOpenCL.so.1
ln -s %{_libdir}/OpenCL-ICD-Loader/libOpenCL.so.1 %{buildroot}/%{_sysconfdir}/alternatives/libOpenCL.so.1
%endif
%if (0%{?sle_version} >= 150100 || 0%{?suse_version} >= 1550)
%post -n libOpenCL1
# apparently needed when updating from a pre update-alternatives package ...
rm -f %{_libdir}/libOpenCL.so.1.*
%{_sbindir}/update-alternatives --force --install \
%{_libdir}/libOpenCL.so.1 libOpenCL.so.1 %{_libdir}/OpenCL-ICD-Loader/libOpenCL.so.1 50
/sbin/ldconfig
%preun -n libOpenCL1
if [ "$1" = 0 ] ; then
%{_sbindir}/update-alternatives --remove libOpenCL.so.1 %{_libdir}/OpenCL-ICD-Loader/libOpenCL.so.1
fi
%else
%post -n libOpenCL1 -p /sbin/ldconfig
%endif
%postun -n libOpenCL1 -p /sbin/ldconfig
%if (0%{?sle_version} >= 150100 || 0%{?suse_version} >= 1550)
%posttrans -n libOpenCL1
if [ "$1" = 0 ] ; then
if ! [ -f %{_libdir}/libOpenCl.so.1 ] ; then
"%{_sbindir}/update-alternatives" --auto libOpenCL.so.1
fi
fi
%endif
%files -n libOpenCL1
%license LICENSE
%doc README.md
%if (0%{?sle_version} >= 150100 || 0%{?suse_version} >= 1550)
%dir %{_libdir}/OpenCL-ICD-Loader
%{_libdir}/OpenCL-ICD-Loader/libOpenCL.so.1*
%ghost %{_libdir}/libOpenCL.so.1
%ghost %{_sysconfdir}/alternatives/libOpenCL.so.1
%else
%{_libdir}/libOpenCL.so.1*
%endif
%files devel
%{_libdir}/libOpenCL.so
%changelog