media-libs/aalib: revbump to fix undefined behavior
[gentoo.git] / sci-libs / gsl / gsl-2.3.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=6
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/19.3"
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 +deprecated static-libs"
17
18 RDEPEND="cblas-external? ( virtual/cblas )"
19 DEPEND="${RDEPEND}
20         app-eselect/eselect-cblas
21         virtual/pkgconfig"
22
23 PATCHES=( "${FILESDIR}"/${P}-cblas.patch )
24
25 pkg_pretend() {
26         # prevent to use external cblas from a previously installed gsl
27         local current_lib
28         if use cblas-external; then
29                 current_lib=$(eselect cblas show | cut -d' ' -f2)
30                 if [[ ${current_lib} == gsl ]]; then
31                         ewarn "USE flag cblas-external is set: linking gsl with an external cblas."
32                         ewarn "However the current selected external cblas is gsl."
33                         ewarn "Please install and/or eselect another cblas"
34                         die "Circular gsl dependency"
35                 fi
36         fi
37 }
38
39 src_prepare() {
40         ESELECT_PROF="gsl"
41
42         # bug 349005
43         [[ $(tc-getCC)$ == *gcc* ]] && \
44                 [[ $(tc-getCC)$ != *apple* ]] && \
45                 [[ $(gcc-major-version)$(gcc-minor-version) -eq 44 ]] \
46                 && filter-mfpmath sse
47         filter-flags -ffast-math
48
49         default
50         if use deprecated; then
51                 sed -i -e "/GSL_DISABLE_DEPRECATED/,+2d" configure.ac || die
52         fi
53         eautoreconf
54
55         cp "${FILESDIR}"/eselect.cblas.gsl "${T}"/ || die
56         sed -i -e "s:/usr:${EPREFIX}/usr:" "${T}"/eselect.cblas.gsl || die
57         if [[ ${CHOST} == *-darwin* ]] ; then
58                 sed -i -e 's/\.so\([\.0-9]\+\)\?/\1.dylib/g' \
59                         "${T}"/eselect.cblas.gsl || die
60         fi
61 }
62
63 src_configure() {
64         if use cblas-external; then
65                 export CBLAS_LIBS="$($(tc-getPKG_CONFIG) --libs cblas)"
66                 export CBLAS_CFLAGS="$($(tc-getPKG_CONFIG) --cflags cblas)"
67         fi
68         econf \
69                 --enable-shared \
70                 $(use_with cblas-external) \
71                 $(use_enable static-libs static)
72 }
73
74 src_test() {
75         local MAKEOPTS="${MAKEOPTS} -j1"
76         default
77 }
78
79 src_install() {
80         default
81
82         find "${ED}" -name '*.la' -exec rm -f {} +
83
84         # take care of pkgconfig file for cblas implementation.
85         sed \
86                 -e "s/@LIBDIR@/$(get_libdir)/" \
87                 -e "s/@PV@/${PV}/" \
88                 -e "/^prefix=/s:=:=${EPREFIX}:" \
89                 -e "/^libdir=/s:=:=${EPREFIX}:" \
90                 "${FILESDIR}"/cblas.pc.in > cblas.pc \
91                 || die "sed cblas.pc failed"
92         insinto /usr/$(get_libdir)/blas/gsl
93         doins cblas.pc
94         eselect cblas add $(get_libdir) "${T}"/eselect.cblas.gsl \
95                 ${ESELECT_PROF}
96 }
97
98 pkg_postinst() {
99         local p=cblas
100         local current_lib=$(eselect ${p} show | cut -d' ' -f2)
101         if [[ ${current_lib} == ${ESELECT_PROF} || -z ${current_lib} ]]; then
102                 # work around eselect bug #189942
103                 local configfile="${EROOT}"/etc/env.d/${p}/$(get_libdir)/config
104                 [[ -e ${configfile} ]] && rm -f ${configfile}
105                 eselect ${p} set ${ESELECT_PROF}
106                 elog "${p} has been eselected to ${ESELECT_PROF}"
107         else
108                 elog "Current eselected ${p} is ${current_lib}"
109                 elog "To use ${p} ${ESELECT_PROF} implementation, you have to issue (as root):"
110                 elog "\t eselect ${p} set ${ESELECT_PROF}"
111         fi
112 }