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

EAPI=4
inherit eutils fortran-2 toolchain-funcs versionator

MYP=${PN}_${PV}

DESCRIPTION="Parallel Linear Algebra for Scalable Multi-core Architecture"
HOMEPAGE="http://icl.cs.utk.edu/plasma/"
SRC_URI="http://icl.cs.utk.edu/projectsfiles/plasma/pubs/${MYP}.tar.gz"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="doc examples fortran static-libs"

RDEPEND="sys-apps/hwloc
	virtual/blas
	virtual/cblas
	virtual/lapack
	virtual/lapacke"

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

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

make_shared_lib() {
	local libstatic=${1}
	local soname=$(basename "${1%.a}").so.$(get_major_version)
	shift
	einfo "Making ${soname}"
	${LINK:-$(tc-getCC)} ${LDFLAGS}  \
		-shared -Wl,-soname="${soname}" \
		-Wl,--whole-archive "${libstatic}" -Wl,--no-whole-archive \
		"$@" -o $(dirname "${libstatic}")/"${soname}" \
		|| die "${soname} failed"
	ln -s "${soname}" $(dirname "${libstatic}")/"${soname%.*}"
}

src_prepare() {
	# distributed pc file not so useful
	cat <<-EOF > ${PN}.pc
		prefix=${EPREFIX}/usr
		libdir=\${prefix}/$(get_libdir)
		includedir=\${prefix}/include/${PN}
		Name: ${PN}
		Description: ${DESCRIPTION}
		Version: ${PV}
		URL: ${HOMEPAGE}
		Libs: -L\${libdir} -lplasma -lcoreblas -lquark
		Libs.private: -lm
		Cflags: -I\${includedir}
		Requires: blas cblas lapack lapacke hwloc
	EOF
}

src_configure() {
	cat <<-EOF > make.inc
		ARCH = $(tc-getAR)
		ARCHFLAGS = cr
		RANLIB = $(tc-getRANLIB)
		CC = $(tc-getCC)
		FC = $(tc-getFC)
		CFLAGS = ${CFLAGS} -DADD_ -fPIC
		FFLAGS = ${FFLAGS} -fPIC
		LOADER = $(tc-getFC)
		LIBBLAS = $(pkg-config --libs blas)
		LIBCBLAS = $(pkg-config --libs cblas)
		LIBLAPACK = $(pkg-config --libs lapack)
		LIBCLAPACK = $(pkg-config --libs lapacke)
		$(use fortran && echo "PLASMA_F90 = 1")
	EOF
}

src_compile() {
	emake lib
	make_shared_lib quark/libquark.a $(pkg-config --libs hwloc) -pthread
	make_shared_lib lib/libcoreblas.a quark/libquark.so $(pkg-config --libs cblas lapacke)
	make_shared_lib lib/libplasma.a quark/libquark.so lib/libcoreblas.so
	if use static-libs; then
		emake cleanall
		sed 's/-fPIC//g' make.inc
		emake lib
	fi
}

src_install() {
	dolib.so lib/lib*.so* quark/libquark.so*
	use static-libs && dolib.a lib/lib*.a quark/libquark.a
	insinto /usr/include/${PN}
	doins quark/quark{,_unpack_args}.h quark/icl_{hash,list}.h include/*.h
	use fortran && doins include/*.mod
	insinto /usr/$(get_libdir)/pkgconfig
	doins ${PN}.pc
	dodoc README ToDo ReleaseNotes
	use doc && dodoc docs/pdf/*.pdf && dohtml docs/doxygen/out/html/*
	if use examples; then
		emake -C examples cleanall
		insinto /usr/share/doc/${PF}
		doins -r examples
	fi
}