summaryrefslogtreecommitdiff
blob: 422a9a26bddf121e6a9188cba1a33cb04afb14b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=6

PYTHON_COMPAT=( python{2_7,3_4,3_5} )
FORTRAN_NEEDED=test

inherit cmake-utils python-single-r1 toolchain-funcs fortran-2

MYPN="clBLAS"

DESCRIPTION="Library containing BLAS routines for OpenCL"
HOMEPAGE="https://github.com/clMathLibraries/clBLAS"
SRC_URI="https://github.com/clMathLibraries/${MYPN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="Apache-2.0"
SLOT="0/2" # soname version
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
IUSE="+client doc examples ktest performance test"

REQUIRED_USE="performance? ( ${PYTHON_REQUIRED_USE} )"

RDEPEND="
	virtual/opencl
	doc? ( dev-libs/mathjax )
	performance? ( ${PYTHON_DEPS} )
"
DEPEND="${RDEPEND}
	doc? ( app-doc/doxygen )
	test? (
	   dev-cpp/gtest
	   dev-libs/boost
	   virtual/pkgconfig
	   virtual/blas
	)
"

S="${WORKDIR}/${MYPN}-${PV}"
CMAKE_USE_DIR="${S}/src"

PATCHES=(
	"${FILESDIR}"/${P}-disable-multilib-cflags.patch
	"${FILESDIR}"/${P}-fix-blas-dot-calls.patch
	"${FILESDIR}"/${P}-fix-doxygen-output-dir.patch
	"${FILESDIR}"/${P}-fix-pthread-linkage.patch
	"${FILESDIR}"/${P}-use-boost-dynamic-libs.patch
	"${FILESDIR}"/${P}-use-system-mathjax.patch
)

src_configure() {
	local mycmakeargs=(
		-DBUILD_SHARED_LIBS=ON
		-DBUILD_RUNTIME=ON
		-DBUILD_SAMPLE=OFF
		-DBUILD_CLIENT="$(usex client)"
		-DBUILD_KTEST="$(usex ktest)"
		-DBUILD_PERFORMANCE="$(usex performance)"
	)
	if use test; then
		mycmakeargs+=(
			-DBUILD_TEST=ON
			-DUSE_SYSTEM_GTEST=ON
			-DBLAS_LIBRARIES="$($(tc-getPKG_CONFIG) --libs blas)"
		)
	else
		mycmakeargs+=( -DBUILD_TEST=OFF	)
	fi
	cmake-utils_src_configure
}

src_compile() {
	cmake-utils_src_compile
	if use doc; then
		cd doc
		doxygen clBLAS.doxy || die
	fi
}

src_test() {
	pushd "${BUILD_DIR}/staging" > /dev/null
	LD_LIBRARY_PATH="${BUILD_DIR}/library:${LD_LIBRARY_PATH}" \
				   ./test-short
	popd > /dev/null

	# horrible hack to avoid installing compiled tests
	# this will trigger some overcompilation
	mycmakeargs+=( -DBUILD_TEST=OFF	)
	cmake-utils_src_configure
}

src_install() {
	use doc && HTML_DOCS=( doc/html/. )
	cmake-utils_src_install
	dodoc CHANGELOG  CONTRIBUTING.md NOTICE  README.md
	if use examples; then
		insinto /usr/share/doc/${PF}/examples
		doins -r src/samples/*
		docompress -x /usr/share/doc/${PF}/examples
	fi
}