app-eselect/eselect-opencl: x86 stable (bug #649316)
[gentoo.git] / app-eselect / eselect-opencl / eselect-opencl-1.1.0-r4.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 inherit multilib
7
8 DESCRIPTION="Utility to change the OpenCL implementation being used"
9 HOMEPAGE="https://www.gentoo.org/"
10
11 # Source:
12 # http://www.khronos.org/registry/cl/api/${CL_ABI}/opencl.h
13 # http://www.khronos.org/registry/cl/api/${CL_ABI}/cl_platform.h
14 # http://www.khronos.org/registry/cl/api/${CL_ABI}/cl.h
15 # http://www.khronos.org/registry/cl/api/${CL_ABI}/cl_ext.h
16 # http://www.khronos.org/registry/cl/api/${CL_ABI}/cl_gl.h
17 # http://www.khronos.org/registry/cl/api/${CL_ABI}/cl_gl_ext.h
18 # http://www.khronos.org/registry/cl/api/${CL_ABI}/cl.hpp
19
20 # Using copy by Mario Kicherer #496418
21
22 SRC_URI="
23         https://dev.gentoo.org/~xarthisius/distfiles/${P}-r1.tar.xz
24         https://github.com/KhronosGroup/OpenCL-Headers/archive/opencl10.zip
25         https://github.com/KhronosGroup/OpenCL-Headers/archive/opencl11.zip
26         https://github.com/KhronosGroup/OpenCL-Headers/archive/opencl12.zip
27         https://github.com/KhronosGroup/OpenCL-Headers/archive/opencl20.zip
28         https://github.com/KhronosGroup/OpenCL-Headers/archive/opencl21.zip
29         http://packages.gentooexperimental.org/opencl-cpp-headers.tar
30         "
31 LICENSE="GPL-2"
32 SLOT="0"
33 KEYWORDS="amd64 ~arm64 x86 ~amd64-fbsd ~x86-fbsd"
34 IUSE=""
35
36 DEPEND="app-arch/xz-utils"
37 RDEPEND=">=app-admin/eselect-1.2.4"
38
39 pkg_postinst() {
40         local impl="$(eselect opencl show)"
41         if [[ -n "${impl}"  && "${impl}" != '(none)' ]] ; then
42                 eselect opencl set "${impl}"
43         fi
44 }
45
46 src_install() {
47         insinto /usr/share/eselect/modules
48         doins opencl.eselect
49         #doman opencl.eselect.5
50
51         local headers=( opencl.h cl_platform.h cl.h cl_ext.h cl_gl.h cl_gl_ext.h cl_egl.h )
52
53         # We install all versions of OpenCL headers
54         for CL_ABI in 1.0 1.1 1.2 2.0 2.1; do
55                 mkdir -p "${ED}/usr/$(get_libdir)/OpenCL/global/include/CL-${CL_ABI}"
56                 for f in ${headers[@]}; do
57                         cp "${WORKDIR}"/OpenCL-Headers-opencl${CL_ABI/./}/${f} "${ED}/usr/$(get_libdir)/OpenCL/global/include/CL-${CL_ABI}/${f}" > /dev/null
58                 done
59         done
60
61         for i in 1.1 1.2 2.1; do
62                 cp "${WORKDIR}"/$i/cl.hpp "${ED}/usr/$(get_libdir)/OpenCL/global/include/CL-${CL_ABI}/"
63         done
64         # Create symlinks to newest. Maybe this should be switchable?
65         for f in ${headers[@]}; do
66                 dosym "${ED}/usr/$(get_libdir)/OpenCL/global/include/CL-1.2/${f}" "/usr/include/CL/${f}"
67         done
68 }