d7a73bc88129ea19d7c3029c4e11c57bbde277c6
[gentoo.git] / sci-libs / med / med-4.0.0-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python3_{6,7} )
7
8 inherit autotools flag-o-matic fortran-2 python-single-r1
9
10 #DESCRIPTION="A library to store and exchange meshed data or computation results"
11 DESCRIPTION="Modeling and Exchange of Data library"
12 HOMEPAGE="https://www.salome-platform.org/user-section/about/med"
13 SRC_URI="https://files.salome-platform.org/Salome/other/${P}.tar.gz"
14
15 LICENSE="LGPL-3"
16 SLOT="0"
17 KEYWORDS="~amd64 ~x86"
18 IUSE="doc fortran hdf5-16-api python test"
19
20 # fails to run parallel tests
21 RESTRICT="test"
22
23 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
24 # dev-lang/tk is needed for wish-based xmdump utility
25 RDEPEND="
26         !sci-libs/libmed
27         dev-lang/tk:0=
28         >=sci-libs/hdf5-1.10.2:=[fortran=,mpi(+)]
29         virtual/mpi[fortran=]
30         python? ( ${PYTHON_DEPS} )
31 "
32 DEPEND="${RDEPEND}"
33 BDEPEND="python? ( >=dev-lang/swig-3.0.8 )"
34
35 PATCHES=(
36         "${FILESDIR}/${P}-0001-doc-html.doc-Makefile.am-install-into-htmldir.patch"
37 )
38
39 DOCS=( AUTHORS ChangeLog README )
40
41 pkg_setup() {
42         use python && python-single-r1_pkg_setup
43         use fortran && fortran-2_pkg_setup
44 }
45
46 src_prepare() {
47         if use hdf5-16-api; then
48                 append-cppflags -DH5_USE_16_API
49         fi
50
51         # add flag to produce python 3 code
52         sed -e 's|SWIG_PYTHON_OPT += -c++|SWIG_PYTHON_OPT += -c++ -relativeimport -py3|' \
53                 -i ./python/Makefile.am || die "failed to change swig options"
54
55         # don't use version information when linking python libraries
56         sed -e 's|= -module|= -avoid-version -module|' \
57                 -i ./python/Makefile.am || die "failed to change python link flags"
58
59         default
60         eautoreconf
61 }
62
63 src_configure() {
64         local myconf=(
65                 --disable-api23
66                 --disable-installtest
67                 --disable-static
68                 --htmldir="${EPREFIX}"/usr/share/doc/${PF}/html
69                 --with-hdf5="${EPREFIX}"/usr
70                 --with-hdf5-lib="${EPREFIX}"/usr/$(get_libdir)
71                 $(use_enable fortran)
72                 $(use_enable python)
73         )
74
75         if ! use fortran; then
76                 myconf+=(
77                         --with-f90=no
78                 )
79         fi
80
81         if use python; then
82                 myconf+=(
83                         --with-swig="${EPREFIX}/usr"
84                 )
85         fi
86
87         export MPICC=mpicc
88         export MPICXX=mpicxx
89         export MPIFC=mpif90
90         export MPIF77=mpif77
91         export FC=mpif90
92         export F77=mpif77
93
94         econf "${myconf[@]}"
95 }
96
97 src_install() {
98         use python && python_optimize
99
100         default
101
102         find "${ED}/usr/$(get_libdir)" -type f -name '*.la' -delete || die "failed to delete *.la files"
103
104         # remove unnecessary doc subdirs
105         rm -r "${ED}"/usr/share/doc/${PF}/{gif,jpg,odt,png} || die "failed to remove unneeded doc subdirs"
106         if ! use doc; then
107                 rm -r "${ED}"/usr/share/doc/${PF}/html || die "failed to remove html documentation"
108         fi
109
110         # Prevent test executables being installed
111         if use test; then
112                 rm -r "${ED}"/usr/bin/{testc,testf,testpy} || die "failed to delete test executables"
113         fi
114
115         # we don't need old 2.3.6 include files
116         rm -r "${ED}"/usr/include/2.3.6 || die "failed to delete obsolete include dir"
117
118         rm "${ED}"/usr/$(get_libdir)/libmed3.settings || die "failed to remove libmed3.settings"
119 }