aboutsummaryrefslogtreecommitdiff
blob: 86c5eed79d5d8693218716f22765c7b5f2d1a2da (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
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=4
inherit eutils toolchain-funcs cmake-utils alternatives-2

MYP=lapack-3.3.1

DESCRIPTION="Reference implementation of BLAS"
HOMEPAGE="http://www.netlib.org/lapack/"
SRC_URI="http://www.netlib.org/lapack/${MYP}.tgz"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="static-libs test"

RDEPEND="virtual/fortran"
DEPEND="${RDEPEND}
	dev-util/pkgconfig"

DOCS=( README )

S="${WORKDIR}/${MYP}"

src_prepare() {
	# avoid collision with other blas
	sed -i \
		-e 's:blas:refblas:g' \
		CMakeLists.txt BLAS/blas.pc.in BLAS/{SRC,TESTING}/CMakeLists.txt || die
	sed -i \
		-e 's:BINARY_DIR}/blas:BINARY_DIR}/refblas:' \
		BLAS/CMakeLists.txt || die
	export FC=$(tc-getFC) F77=$(tc-getF77)
	use static-libs && mkdir "${WORKDIR}/${PN}_static"
}

lapack_configure() {
	mycmakeargs+=(
		-DUSE_OPTIMIZED_BLAS=OFF
		$(cmake-utils_use_build test TESTING)
	)
	cmake-utils_src_configure
}

src_configure() {
	mycmakeargs=( -DBUILD_SHARED_LIBS=ON )
	lapack_configure
	if use static-libs; then
		mycmakeargs=( -DBUILD_SHARED_LIBS=OFF )
		CMAKE_BUILD_DIR="${WORKDIR}/${PN}_static" lapack_configure
	fi
}

src_compile() {
	cmake-utils_src_compile -C BLAS
	if use static-libs; then
		CMAKE_BUILD_DIR="${WORKDIR}/${PN}_static" \
			cmake-utils_src_compile -C BLAS
	fi
}

src_test() {
	pushd "${CMAKE_BUILD_DIR}/BLAS" > /dev/null
	local ctestargs
	[[ -n ${TEST_VERBOSE} ]] && ctestargs="--extra-verbose --output-on-failure"
	ctest ${ctestargs} || die
	popd > /dev/null
}

src_install() {
	cmake-utils_src_install -C BLAS
	if use static-libs; then
		CMAKE_BUILD_DIR="${WORKDIR}/${PN}_static" \
			cmake-utils_src_install -C BLAS
	fi
	alternatives_for blas reference 0 \
				"/usr/$(get_libdir)/pkgconfig/blas.pc" "refblas.pc"
}