1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit autotools eutils flag-o-matic toolchain-funcs
9 DESCRIPTION="The GNU Scientific Library"
10 HOMEPAGE="https://www.gnu.org/software/gsl/"
11 SRC_URI="mirror://gnu/${PN}/${P}.tar.gz"
15 KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 s390 sh sparc x86 ~x86-fbsd ~x86-interix ~amd64-linux ~x86-linux ~x86-macos ~sparc-solaris ~x86-solaris"
18 RDEPEND="cblas-external? ( virtual/cblas )"
20 app-eselect/eselect-cblas
25 # prevent to use external cblas from a previously installed gsl
26 local current_lib=$(eselect cblas show | cut -d' ' -f2)
27 if use cblas-external && [[ ${current_lib} == gsl ]]; then
28 ewarn "USE flag cblas-external is set: linking gsl with an external cblas."
29 ewarn "However the current selected external cblas is gsl."
30 ewarn "Please install and/or eselect another cblas"
31 die "Circular gsl dependency"
36 filter-flags -ffast-math
37 epatch "${FILESDIR}"/${P}-cblas.patch
40 cp "${FILESDIR}"/eselect.cblas.gsl "${T}"/
41 sed -i -e "s:/usr:${EPREFIX}/usr:" "${T}"/eselect.cblas.gsl || die
42 if [[ ${CHOST} == *-darwin* ]] ; then
43 sed -i -e 's/\.so\([\.0-9]\+\)\?/\1.dylib/g' \
44 "${T}"/eselect.cblas.gsl || die
49 if use cblas-external; then
50 export CBLAS_LIBS="$($(tc-getPKG_CONFIG) --libs cblas)"
51 export CBLAS_CFLAGS="$($(tc-getPKG_CONFIG) --cflags cblas)"
53 econf $(use_with cblas-external cblas)
57 emake install DESTDIR="${D}" || die "emake install failed."
58 dodoc AUTHORS BUGS ChangeLog NEWS README THANKS TODO
60 # take care of pkgconfig file for cblas implementation.
61 sed -e "s/@LIBDIR@/$(get_libdir)/" \
63 -e "/^prefix=/s:=:=${EPREFIX}:" \
64 -e "/^libdir=/s:=:=${EPREFIX}:" \
65 "${FILESDIR}"/cblas.pc.in > cblas.pc \
66 || die "sed cblas.pc failed"
67 insinto /usr/$(get_libdir)/blas/gsl
68 doins cblas.pc || die "installing cblas.pc failed"
69 eselect cblas add $(get_libdir) "${T}"/eselect.cblas.gsl \
75 local current_lib=$(eselect ${p} show | cut -d' ' -f2)
76 if [[ ${current_lib} == ${ESELECT_PROF} || -z ${current_lib} ]]; then
77 # work around eselect bug #189942
78 local configfile="${EROOT}"/etc/env.d/${p}/$(get_libdir)/config
79 [[ -e ${configfile} ]] && rm -f ${configfile}
80 eselect ${p} set ${ESELECT_PROF}
81 elog "${p} has been eselected to ${ESELECT_PROF}"
83 elog "Current eselected ${p} is ${current_lib}"
84 elog "To use ${p} ${ESELECT_PROF} implementation, you have to issue (as root):"
85 elog "\t eselect ${p} set ${ESELECT_PROF}"
90 emake -j1 check || die