media-libs/aalib: revbump to fix undefined behavior
[gentoo.git] / sci-libs / gsl / gsl-1.14.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="3"
6
7 inherit autotools eutils flag-o-matic toolchain-funcs
8
9 DESCRIPTION="The GNU Scientific Library"
10 HOMEPAGE="https://www.gnu.org/software/gsl/"
11 SRC_URI="mirror://gnu/${PN}/${P}.tar.gz"
12
13 LICENSE="GPL-3"
14 SLOT="0"
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"
16 IUSE="cblas-external"
17
18 RDEPEND="cblas-external? ( virtual/cblas )"
19 DEPEND="${RDEPEND}
20         app-eselect/eselect-cblas
21         virtual/pkgconfig"
22
23 pkg_setup() {
24         ESELECT_PROF="gsl"
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"
32         fi
33 }
34
35 src_prepare() {
36         filter-flags -ffast-math
37         epatch "${FILESDIR}"/${P}-cblas.patch
38         eautoreconf
39
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
45         fi
46 }
47
48 src_configure() {
49         if use cblas-external; then
50                 export CBLAS_LIBS="$($(tc-getPKG_CONFIG) --libs cblas)"
51                 export CBLAS_CFLAGS="$($(tc-getPKG_CONFIG) --cflags cblas)"
52         fi
53         econf $(use_with cblas-external cblas)
54 }
55
56 src_install() {
57         emake install DESTDIR="${D}" || die "emake install failed."
58         dodoc AUTHORS BUGS ChangeLog NEWS README THANKS TODO
59
60         # take care of pkgconfig file for cblas implementation.
61         sed -e "s/@LIBDIR@/$(get_libdir)/" \
62                 -e "s/@PV@/${PV}/" \
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 \
70                 ${ESELECT_PROF}
71 }
72
73 pkg_postinst() {
74         local p=cblas
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}"
82         else
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}"
86         fi
87 }
88
89 src_test() {
90         emake -j1 check || die
91 }