summaryrefslogtreecommitdiff
blob: 517e32342ded5f5abe93434ab74cd0f452036ca6 (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
110
111
112
113
114
115
116
117
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CMAKE_MAKEFILE_GENERATOR="emake"
FORTRAN_NEEDED=fortran
FORTRAN_STANDARD="77 90 2003"
# if FFLAGS and FCFLAGS are set then should be equal

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

DESCRIPTION="Suite of nonlinear solvers"
HOMEPAGE="https://computing.llnl.gov/projects/sundials"
SRC_URI="https://github.com/LLNL/${PN}/releases/download/v${PV}/${P}.tar.gz"

LICENSE="BSD"
SLOT="0/$(ver_cut 1)"
KEYWORDS="amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~x86 ~amd64-linux ~x86-linux"
IUSE="doc examples fortran hypre +int64 lapack mpi openmp sparse +static-libs superlumt threads"
REQUIRED_USE="
	fortran? ( static-libs )
	hypre? ( mpi )
"

BDEPEND="virtual/pkgconfig"
RDEPEND="
	lapack? ( virtual/lapack )
	mpi? (
		sci-libs/hypre:=[fortran?,mpi?]
		virtual/mpi[fortran?]
	)
	sparse? ( sci-libs/klu )
	superlumt? ( sci-libs/superlu_mt:=[int64=] )
"
DEPEND="${RDEPEND}"

PATCHES=(
		"${FILESDIR}"/${P}-fix-license-install-path.patch
)

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() {
	# bug #707240
	append-cflags -fcommon
	use threads && append-ldflags -pthread

	cmake_src_prepare
}

src_configure() {
	mycmakeargs+=(
		-DBUILD_FORTRAN77_INTERFACE=$(usex fortran)
		-DBUILD_FORTRAN_MODULE_INTERFACE=$(usex fortran)
		-DBUILD_SHARED_LIBS=ON
		-DBUILD_STATIC_LIBS=$(usex static-libs)
		-DENABLE_HYPRE=$(usex hypre)
		-DENABLE_KLU=$(usex sparse)
		-DENABLE_LAPACK=$(usex lapack)
		-DENABLE_MPI=$(usex mpi)
		-DENABLE_OPENMP=$(usex openmp)
		-DENABLE_PTHREAD=$(usex threads)
		-DENABLE_SUPERLUMT=$(usex superlumt)
		-DEXAMPLES_INSTALL=ON
		-DEXAMPLES_INSTALL_PATH="/usr/share/doc/${PF}/examples"
		-DSUNDIALS_INDEX_SIZE="$(usex int64 64 32)"
		-DSUPERLUMT_INCLUDE_DIR="${EPREFIX}/usr/include/superlu_mt"
		-DSUPERLUMT_LIBRARY="-lsuperlu_mt"
		-DUSE_GENERIC_MATH=ON
	)
	if use examples; then
		mycmakeargs+=(
			-DEXAMPLES_ENABLE_C=ON
			-DEXAMPLES_ENABLE_CXX=ON
		)
		if use fortran; then
			mycmakeargs+=(
				-DEXAMPLES_ENABLE_F77=ON
				-DEXAMPLES_ENABLE_F90=ON
				-DEXAMPLES_ENABLE_F2003=ON
			)
		fi
	fi

	if use fortran; then
		mycmakeargs+=(
			-DFortran_INSTALL_MODDIR="${EPREFIX}/usr/$(get_libdir)/fortran"
		)
	fi

	if use hypre; then
		mycmakeargs+=(
			-DHYPRE_INCLUDE_DIR="${EPREFIX}/usr/include/hypre"
			-DHYPRE_LIBRARY="${EPREFIX}/usr/$(get_libdir)/libHYPRE.so"
		)
	fi

	if use sparse; then
		mycmakeargs+=(
		-DKLU_LIBRARY="${EPREFIX}/usr/$(get_libdir)/libklu.so"
		)
	fi
	cmake_src_configure
}

src_install() {
	cmake_src_install
	use doc && dodoc doc/*/*.pdf
}