Gentoo Archives: gentoo-commits

From: Marius Brehler <marbre@××××××××××××××.de>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/sci:master commit in: sci-mathematics/petsc/
Date: Wed, 31 Aug 2016 06:56:26
Message-Id: 1472518349.7d46fb1d005394c121a9fab2585d50b13660e74e.marbre@gentoo
1 commit: 7d46fb1d005394c121a9fab2585d50b13660e74e
2 Author: Matthias Maier <tamiko <AT> gentoo <DOT> org>
3 AuthorDate: Tue Aug 30 00:52:06 2016 +0000
4 Commit: Marius Brehler <marbre <AT> linux <DOT> sungazer <DOT> de>
5 CommitDate: Tue Aug 30 00:52:29 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/sci.git/commit/?id=7d46fb1d
7
8 sci-mathematics/petsc: version bump to 3.7.3
9
10 Package-Manager: portage-2.2.28
11
12 sci-mathematics/petsc/petsc-3.7.3.ebuild | 255 +++++++++++++++++++++++++++++++
13 1 file changed, 255 insertions(+)
14
15 diff --git a/sci-mathematics/petsc/petsc-3.7.3.ebuild b/sci-mathematics/petsc/petsc-3.7.3.ebuild
16 new file mode 100644
17 index 0000000..357189f
18 --- /dev/null
19 +++ b/sci-mathematics/petsc/petsc-3.7.3.ebuild
20 @@ -0,0 +1,255 @@
21 +# Copyright 1999-2016 Gentoo Foundation
22 +# Distributed under the terms of the GNU General Public License v2
23 +# $Id$
24 +
25 +EAPI=5
26 +
27 +PYTHON_COMPAT=( python2_7 )
28 +
29 +inherit eutils flag-o-matic fortran-2 python-any-r1 toolchain-funcs versionator
30 +
31 +MY_P="${PN}-$(replace_version_separator _ -)"
32 +
33 +DESCRIPTION="Portable, Extensible Toolkit for Scientific Computation"
34 +HOMEPAGE="http://www.mcs.anl.gov/petsc/"
35 +SRC_URI="http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/${MY_P}.tar.gz"
36 +
37 +LICENSE="petsc"
38 +SLOT="0"
39 +KEYWORDS="~x86 ~amd64"
40 +IUSE="afterimage boost complex-scalars cxx debug doc fftw
41 + fortran hdf5 hypre mpi mumps scotch sparse superlu threads X"
42 +# Failed: imagemagick metis
43 +
44 +# hypre and superlu curretly exclude each other due to missing linking to hypre
45 +# if both are enabled
46 +REQUIRED_USE="
47 + afterimage? ( X )
48 + hdf5? ( mpi )
49 + hypre? ( cxx mpi )
50 + mumps? ( mpi scotch )
51 + scotch? ( mpi )
52 + ^^ ( hypre superlu )
53 +"
54 +# imagemagick? ( X )
55 +
56 +RDEPEND="
57 + virtual/blas
58 + virtual/lapack
59 + afterimage? ( media-libs/libafterimage )
60 + boost? ( dev-libs/boost )
61 + fftw? ( sci-libs/fftw:3.0[mpi?] )
62 + hdf5? ( sci-libs/hdf5[mpi?] )
63 + hypre? ( >=sci-libs/hypre-2.8.0b[mpi?] )
64 + mpi? ( virtual/mpi[cxx?,fortran?] )
65 + mumps? ( sci-libs/mumps[mpi?] sci-libs/scalapack )
66 + scotch? ( sci-libs/scotch[mpi?] )
67 + sparse? ( sci-libs/suitesparse >=sci-libs/cholmod-1.7.0 )
68 + superlu? ( sci-libs/superlu )
69 + X? ( x11-libs/libX11 )
70 +"
71 +# metis? ( sci-libs/parmetis )
72 +# imagemagick? ( media-gfx/imagemagick )
73 +
74 +DEPEND="${RDEPEND}
75 + ${PYTHON_DEPS}
76 + virtual/pkgconfig
77 + dev-util/cmake
78 +"
79 +# cmake is used for parallel building
80 +# in some configuration setups, legacy build is used (slow)
81 +
82 +#
83 +# PETSc does not want its Makefiles to be invoked with anything higher than
84 +# -j1. The underlying build system does automatically invoke a parallel
85 +# build. This might not be what you want, but *hey* not your choice.
86 +#
87 +# V=1 enables verbose output with full compiler and linker invocation
88 +#
89 +MAKEOPTS="${MAKEOPTS} -j1 V=1"
90 +
91 +S="${WORKDIR}/${MY_P}"
92 +
93 +src_prepare() {
94 + epatch \
95 + "${FILESDIR}"/${PN}-3.7.0-disable-rpath.patch \
96 + "${FILESDIR}"/${PN}-3.7.0-fix_sandbox_violation.patch
97 +
98 + sed -i -e 's%/usr/bin/env python%/usr/bin/env python2%' configure || die
99 +}
100 +
101 +src_configure() {
102 + # bug 548498
103 + # PETSc runs mpi processes during configure that result in a sandbox
104 + # violation by trying to open /proc/mtrr rw. This is not easy to
105 + # mitigate because it happens in libpciaccess.so called by libhwloc.so,
106 + # which is used by libmpi.so.
107 + addpredict /proc/mtrr
108 +
109 + # petsc uses --with-blah=1 and --with-blah=0 to en/disable options
110 + petsc_enable() {
111 + use "$1" && echo "--with-${2:-$1}=1" || echo "--with-${2:-$1}=0"
112 + }
113 + # add external library:
114 + # petsc_with use_flag libname libdir
115 + # petsc_with use_flag libname include linking_libs
116 + petsc_with() {
117 + local myuse p=${2:-${1}}
118 + if use ${1}; then
119 + myuse="--with-${p}=1"
120 + if [[ $# -ge 4 ]]; then
121 + myuse="${myuse} --with-${p}-include=${EPREFIX}${3}"
122 + shift 3
123 + myuse="${myuse} --with-${p}-lib=$@"
124 + else
125 + myuse="${myuse} --with-${p}-dir=${EPREFIX}${3:-/usr}"
126 + fi
127 + else
128 + myuse="--with-${p}=0"
129 + fi
130 + echo ${myuse}
131 + }
132 +
133 + # select between configure options depending on use flag
134 + petsc_select() {
135 + use "$1" && echo "--with-$2=$3" || echo "--with-$2=$4"
136 + }
137 +
138 + local mylang
139 + local myopt
140 +
141 + use cxx && mylang="cxx" || mylang="c"
142 + use debug && myopt="debug" || myopt="opt"
143 +
144 + # environmental variables expected by petsc during build
145 + export PETSC_DIR="${S}"
146 + export PETSC_ARCH="linux-gnu-${mylang}-${myopt}"
147 +
148 + if use debug; then
149 + strip-flags
150 + filter-flags -O*
151 + fi
152 +
153 + # C Support on Cxx builds is enabled if possible
154 + # i.e. when not using complex scalars
155 + # (no complex type for both available at the same time)
156 +
157 + # run petsc configure script
158 + econf \
159 + scrollOutput=1 \
160 + FFLAGS="${FFLAGS} -fPIC" \
161 + CFLAGS="${CFLAGS} -fPIC" \
162 + CXXFLAGS="${CXXFLAGS} -fPIC" \
163 + LDFLAGS="${LDFLAGS}" \
164 + --with-shared-libraries \
165 + --with-single-library \
166 + --with-clanguage=${mylang} \
167 + $(use cxx && ! use complex-scalars && echo "with-c-support=1") \
168 + --with-petsc-arch=${PETSC_ARCH} \
169 + --with-precision=double \
170 + --with-gnu-compilers \
171 + --with-blas-lapack-lib="$($(tc-getPKG_CONFIG) --libs lapack)" \
172 + $(petsc_enable debug debugging) \
173 + $(petsc_enable mpi) \
174 + $(petsc_select mpi cc mpicc $(tc-getCC)) \
175 + $(petsc_select mpi cxx mpicxx $(tc-getCXX)) \
176 + $(petsc_enable fortran) \
177 + $(use fortran && echo "$(petsc_select mpi fc mpif77 $(tc-getF77))") \
178 + $(petsc_enable mpi mpi-compilers) \
179 + $(petsc_select complex-scalars scalar-type complex real) \
180 + --with-windows-graphics=0 \
181 + --with-matlab=0 \
182 + --with-cmake=cmake \
183 + $(petsc_enable threads pthread) \
184 + $(petsc_with afterimage afterimage \
185 + /usr/include/libAfterImage -lAfterImage) \
186 + $(petsc_with hdf5) \
187 + $(petsc_with hypre hypre \
188 + /usr/include/hypre -lHYPRE) \
189 + $(petsc_with sparse suitesparse) \
190 + $(petsc_with superlu superlu \
191 + /usr/include/superlu -lsuperlu) \
192 + $(petsc_with X x) \
193 + $(petsc_with X x11) \
194 + $(petsc_with scotch ptscotch \
195 + /usr/include/scotch \
196 + [-lptesmumps,-lptscotch,-lptscotcherr,-lscotch,-lscotcherr]) \
197 + $(petsc_with mumps scalapack \
198 + /usr/include/scalapack -lscalapack) \
199 + $(petsc_with mumps mumps \
200 + /usr/include \
201 + [-lcmumps,-ldmumps,-lsmumps,-lzmumps,-lmumps_common,-lpord]) \
202 + --with-imagemagick=0 \
203 + --with-python=0 \
204 + $(petsc_with boost) \
205 + $(petsc_with fftw)
206 +
207 +# not yet tested:
208 +# python bindings, netcdf, fftw
209 +
210 +# failed dependencies, perhaps fixed in upstream soon:
211 +# $(petsc_with metis parmetis) \ # needs metis too (>=5.0.2)
212 +# $(petsc_with imagemagick imagemagick \
213 +# /usr/include/ImageMagick $($(tc-getPKG_CONFIG) --libs MagickCore)) \
214 +# $(petsc_enable threads pthreadclasses) \
215 +}
216 +
217 +src_install() {
218 + # petsc install structure is very different from
219 + # installing headers to /usr/include/petsc and lib to /usr/lib
220 + # it also installs many unneeded executables and scripts
221 + # so manual install is easier than cleanup after "emake install"
222 + insinto /usr/include/${PN}
223 + doins include/*.h*
224 + insinto /usr/include/${PN}/${PETSC_ARCH}/include
225 + doins ${PETSC_ARCH}/include/*
226 + if use fortran; then
227 + insinto /usr/include/${PN}/finclude
228 + doins -r include/${PN}/finclude/*
229 + fi
230 + if ! use mpi ; then
231 + insinto /usr/include/${PN}/mpiuni
232 + doins include/mpiuni/*.h
233 + fi
234 + insinto /usr/include/${PN}/conf
235 + doins lib/${PN}/conf/{variables,rules,test}
236 + insinto /usr/include/${PN}/${PETSC_ARCH}/conf
237 + doins ${PETSC_ARCH}/lib/${PN}/conf/{petscrules,petscvariables,RDict.db}
238 + insinto /usr/include/${PN}/private
239 + doins include/${PN}/private/*.h
240 +
241 + # fix configuration files: replace "${S}" by installed location
242 + sed -i \
243 + -e "s:"${S}"::g" \
244 + "${ED}"/usr/include/${PN}/${PETSC_ARCH}/include/petscconf.h \
245 + "${ED}"/usr/include/${PN}/${PETSC_ARCH}/conf/petscvariables || die
246 + sed -i \
247 + -e "s:-I/include:-I${EPREFIX}/usr/include/${PN}:g" \
248 + -e "s:-I/linux-gnu-cxx-opt/include:-I${EPREFIX}/usr/include/${PN}/${PETSC_ARCH}/include/:g" \
249 + "${ED}"/usr/include/${PN}/${PETSC_ARCH}/conf/petscvariables || die
250 + sed -i \
251 + -e "s:usr/lib:usr/$(get_libdir):g" \
252 + "${ED}"/usr/include/${PN}/${PETSC_ARCH}/include/petscconf.h || die
253 +
254 + # fix the include path of petscvariables in lib/${PN}/conf/variables
255 + # bug #559172
256 + sed -i -e 's#lib/petsc/conf/#conf/#g' \
257 + "${ED}"/usr/include/${PN}/conf/variables || die
258 +
259 + # add information about installation directory and
260 + # PETSC_ARCH to environmental variables
261 + cat >> 99petsc <<- EOF
262 + PETSC_ARCH=${PETSC_ARCH}
263 + PETSC_DIR=${EPREFIX}/usr/include/${PN}
264 + EOF
265 + doenvd 99petsc
266 +
267 + dolib.so ${PETSC_ARCH}/lib/*.so
268 + dolib.so ${PETSC_ARCH}/lib/*.so.*
269 +
270 + if use doc ; then
271 + einfo "installing documentation (this could take a while)"
272 + dodoc docs/manual.pdf
273 + dohtml -r docs/*.html docs/changes docs/manualpages
274 + fi
275 +}