sci-libs/linux-gpib-modules: Version bump
[gentoo.git] / sci-libs / ipopt / ipopt-3.11.8.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 AUTOTOOLS_IN_SOURCE_BUILD=yes
7 FORTRAN_NEEDED="mumps"
8
9 inherit eutils autotools-utils multilib toolchain-funcs fortran-2
10
11 MYPN=Ipopt
12 MYP=${MYPN}-${PV}
13
14 DESCRIPTION="Interior-Point Optimizer for large-scale nonlinear optimization"
15 HOMEPAGE="https://projects.coin-or.org/Ipopt/"
16 SRC_URI="http://www.coin-or.org/download/source/${MYPN}/${MYP}.tgz"
17
18 LICENSE="EPL-1.0 hsl? ( HSL )"
19 SLOT="0/1"
20 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
21 IUSE="doc examples hsl lapack mpi mumps static-libs test"
22 RESTRICT="!test? ( test )"
23
24 RDEPEND="
25         virtual/blas
26         hsl? ( sci-libs/coinhsl:0= )
27         lapack? ( virtual/lapack )
28         mumps? ( sci-libs/mumps:0=[mpi=] )"
29 DEPEND="${RDEPEND}
30         virtual/pkgconfig
31         doc? ( app-doc/doxygen[dot] )
32         test? ( sci-libs/coinor-sample sci-libs/mumps )"
33
34 S="${WORKDIR}/${MYPN}-${PV}/${MYPN}"
35
36 src_prepare() {
37         if use mumps && ! use mpi; then
38                 ln -s "${EPREFIX}"/usr/include/mpiseq/mpi.h \
39                         src/Algorithm/LinearSolvers/
40         elif use mpi; then
41                 export CXX=mpicxx FC=mpif77 F77=mpif77 CC=mpicc
42         fi
43         sed -i \
44                 -e "s:lib/pkgconfig:$(get_libdir)/pkgconfig:g" \
45                 configure || die
46         autotools-utils_src_prepare
47 }
48
49 src_configure() {
50         # needed for the --with-coin-instdir
51         dodir /usr
52         local myeconfargs=(
53                 --enable-dependency-linking
54                 --with-blas-lib="$($(tc-getPKG_CONFIG) --libs blas)"
55                 --with-coin-instdir="${ED}"/usr
56                 $(use_with doc dot)
57         )
58
59         if use lapack; then
60                 myeconfargs+=( --with-lapack="$($(tc-getPKG_CONFIG) --libs lapack)" )
61         else
62                 myeconfargs+=( --without-lapack )
63         fi
64         if use mumps; then
65                 myeconfargs+=(
66                         --with-mumps-incdir="${EPREFIX}"/usr/include
67                         --with-mumps-lib="-lmumps_common -ldmumps -lzmumps -lsmumps -lcmumps" )
68         else
69                 myeconfargs+=( --without-mumps )
70         fi
71         if use hsl; then
72                 myeconfargs+=(
73                         --with-hsl-incdir="${EPREFIX}"/usr/include
74                         --with-hsl-lib="$($(tc-getPKG_CONFIG) --libs coinhsl)" )
75         else
76                 myeconfargs+=( --without-hsl )
77         fi
78         autotools-utils_src_configure
79 }
80
81 src_compile() {
82         autotools-utils_src_compile all $(use doc && echo doxydoc)
83 }
84
85 src_test() {
86         autotools-utils_src_test test
87 }
88
89 src_install() {
90         use doc && HTML_DOC=("${AUTOTOOLS_BUILD_DIR}/doxydocs/html/")
91         autotools-utils_src_install
92         # already installed
93         rm "${ED}"/usr/share/coin/doc/${MYPN}/{README,AUTHORS,LICENSE} || die
94         if use examples; then
95                 insinto /usr/share/doc/${PF}
96                 doins -r examples
97         fi
98 }