app-editors/kakoune: drop old 0_pre20160620
[gentoo.git] / sci-libs / p4est / p4est-2.0.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 # The build system currently fails with everything newer than 1.11.
7 WANT_AUTOMAKE=1.11
8
9 inherit autotools toolchain-funcs eutils
10
11 DESCRIPTION="Scalable Algorithms for Parallel Adaptive Mesh Refinement on Forests of Octrees"
12 HOMEPAGE="http://www.p4est.org/"
13
14 if [[ ${PV} = *9999* ]]; then
15         inherit git-r3
16         EGIT_REPO_URI="https://github.com/cburstedde/${PN}.git"
17         EGIT_BRANCH="develop"
18         SRC_URI=""
19         KEYWORDS=""
20 else
21         SRC_URI="
22                 https://github.com/cburstedde/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz
23                 https://github.com/cburstedde/libsc/archive/v${PV}.tar.gz -> libsc-${PV}.tar.gz"
24         KEYWORDS="~amd64 ~x86"
25 fi
26
27 LICENSE="GPL-2+"
28 SLOT="0"
29
30 # TODO petsc
31 IUSE="debug doc examples mpi openmp romio static-libs threads +vtk-binary"
32 REQUIRED_USE="romio? ( mpi )"
33
34 RDEPEND="
35         ~sci-libs/libsc-${PV}[mpi=,openmp=,romio=,static-libs=,threads=]
36         dev-lang/lua:*
37         sys-apps/util-linux
38         virtual/blas
39         virtual/lapack
40         mpi? ( virtual/mpi[romio=] )"
41
42 DEPEND="
43         ${RDEPEND}
44         sys-devel/automake:1.11
45         virtual/pkgconfig"
46
47 DOCS=( AUTHORS NEWS README )
48
49 pkg_pretend() {
50         if [[ ${MERGE_TYPE} != "binary" ]] && use openmp; then
51                 tc-has-openmp || \
52                         die "Please select an openmp capable compiler like gcc[openmp]"
53         fi
54 }
55
56 src_prepare() {
57         default
58
59         # Inject libsc to get  all parts of the build system...
60         if ! [[ ${PV} = *9999* ]]; then
61                 rmdir "${S}/sc" || die "rmdir failed"
62                 mv "${WORKDIR}/libsc-${PV}" "${S}/sc" || die "mv failed"
63         fi
64
65         # Inject a version number into the build system
66         echo "${PV}" > ${S}/.tarball-version
67
68         AT_M4DIR="${WORKDIR}/${P}/config ${WORKDIR}/${P}/sc/config"
69         eautoreconf
70
71         sed -i \
72                 "s/P4EST_SC_DIR\/etc/P4EST_SC_DIR\/share\/libsc/" \
73                 "${S}"/configure || die "sed failed"
74
75         sed -i \
76                 "s/libsc\.la/libsc\.so/" \
77                 "${S}"/configure || die "sed failed"
78
79 }
80
81 src_configure() {
82         # avoid underlinkage
83         LDFLAGS="${LDFLAGS} -lsc"
84
85         local myeconfargs=(
86                 $(use_enable debug)
87                 $(use_enable mpi)
88                 $(use_enable openmp)
89                 $(use_enable romio mpiio)
90                 $(use_enable static-libs static)
91                 $(use_enable threads pthread)
92                 $(use_enable vtk-binary)
93                 --with-blas="$($(tc-getPKG_CONFIG) --libs blas)"
94                 --with-lapack="$($(tc-getPKG_CONFIG) --libs lapack)"
95                 --with-sc="${EPREFIX}/usr"
96         )
97         econf "${myeconfargs[@]}"
98 }
99
100 src_install() {
101         default
102
103         use doc && dodoc -r doc/*
104
105         if use examples
106         then
107                 docinto examples
108                 dodoc -r example/*
109                 docompress -x /usr/share/doc/${PF}/examples
110         else
111                 # Remove compiled example binaries in case of -examples:
112                 rm -r "${ED}"/usr/bin || die "rm failed"
113         fi
114
115         # Fix wrong installation paths:
116         dodir /usr/share/p4est
117         mv "${ED}"/usr/share/data "${ED}"/usr/share/p4est/data || die "mv failed"
118         mv "${ED}"/etc/* "${ED}"/usr/share/p4est || die "mv failed"
119         rmdir "${ED}"/etc/ || die "rmdir failed"
120 }