summaryrefslogtreecommitdiff
blob: 8c9d5ab220f1d684a58a5adec8516af38f52482f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

FORTRAN_NEEDED=fortran

inherit fortran-2 toolchain-funcs flag-o-matic

DESCRIPTION="Parallel matrix preconditioners library"
HOMEPAGE="https://computation.llnl.gov/projects/hypre-scalable-linear-solvers-multigrid-methods"
SRC_URI="https://github.com/hypre-space/hypre/archive/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="LGPL-2.1"
SLOT="0/${PV}"
KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~x86 ~amd64-linux ~x86-linux"
IUSE="debug examples fortran int64 openmp mpi"

BDEPEND="virtual/pkgconfig"
RDEPEND="
	sci-libs/superlu:=
	virtual/blas
	virtual/lapack
	mpi? ( virtual/mpi )
"
DEPEND="${RDEPEND}"

DOCS=( CHANGELOG COPYRIGHT README )

pkg_pretend() {
	[[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
}

pkg_setup() {
	[[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
	use fortran && fortran-2_pkg_setup
}

src_prepare() {
	default

	# link with system superlu and propagate LDFLAGS
	sed -e "s:@LIBS@:@LIBS@ $($(tc-getPKG_CONFIG) --libs superlu):" \
		-e 's:_SHARED@:_SHARED@ $(LDFLAGS):g' \
		-i src/config/Makefile.config.in || die

	sed -e '/HYPRE_ARCH/s: = :=:g' \
		-i src/configure || die

	# link with system blas and lapack
	sed -e '/^BLASFILES/d' \
		-e '/^LAPACKFILES/d' \
		-i src/lib/Makefile || die
}

src_configure() {
	tc-export CC CXX
	append-flags -Dhypre_dgesvd=dgesvd_

	if use openmp ; then
		append-flags -fopenmp
		append-ldflags -fopenmp
	fi

	if use mpi ; then
		CC=mpicc
		FC=mpif77
		CXX=mpicxx
	fi

	cd src || die

	# without-superlu: means do not use bundled one
	econf \
		--enable-shared \
		--with-blas-libs="$($(tc-getPKG_CONFIG) --libs-only-l blas | sed -e 's/-l//g')" \
		--with-blas-lib-dirs="$($(tc-getPKG_CONFIG) --libs-only-L blas | sed -e 's/-L//g')" \
		--with-lapack-libs="$($(tc-getPKG_CONFIG) --libs-only-l lapack | sed -e 's/-l//g')" \
		--with-lapack-lib-dirs="$($(tc-getPKG_CONFIG) --libs-only-L lapack | sed -e 's/-L//g')" \
		--with-timing \
		--without-superlu \
		$(use_enable debug) \
		$(use_enable openmp hopscotch) \
		$(use_enable int64 bigint) \
		$(use_enable fortran) \
		$(use_with openmp) \
		$(use_with mpi MPI)
}

src_compile() {
	emake -C src
}

src_test() {
	LD_LIBRARY_PATH="${S}/src/lib:${LD_LIBRARY_PATH}" \
		PATH="${S}/src/test:${PATH}" \
		emake -C src check
}

src_install() {
	emake -C src install \
		HYPRE_INSTALL_DIR="${ED}" \
		HYPRE_LIB_INSTALL="${ED}/usr/$(get_libdir)" \
		HYPRE_INC_INSTALL="${ED}/usr/include/hypre"

	if use examples; then
		dodoc -r src/examples
	fi
}