summaryrefslogtreecommitdiff
blob: a093157e2d71fbac244c3c9277fab66b170764d8 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

# deal.II uses its own FindLAPACK.cmake file that calls into the system
# FindLAPACK.cmake module and does additional internal setup. Do not remove
# any of these modules:
CMAKE_REMOVE_MODULES_LIST=""

inherit cmake flag-o-matic

DESCRIPTION="Solving partial differential equations with the finite element method"
HOMEPAGE="https://www.dealii.org/"

if [[ ${PV} = *9999* ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/dealii/dealii.git"
	SRC_URI=""
else
	SRC_URI="https://github.com/${PN}/${PN}/releases/download/v${PV}/${P}.tar.gz
		doc? (
			https://github.com/${PN}/${PN}/releases/download/v${PV}/${P}-offline_documentation.tar.gz
			)"
	KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
fi

LICENSE="LGPL-2.1+"
SLOT="0"
IUSE="
	adolc assimp arpack cpu_flags_x86_avx cpu_flags_x86_avx512f
	cpu_flags_x86_sse2 cuda +debug doc +examples ginkgo gmsh +gsl hdf5
	+lapack metis mpi muparser opencascade p4est petsc
	scalapack slepc +sparse static-libs sundials symengine trilinos
"

# TODO: add slepc use flag once slepc is packaged for gentoo-science
REQUIRED_USE="
	p4est? ( mpi )
	slepc? ( petsc )
	trilinos? ( mpi )"

RDEPEND="dev-libs/boost:=
	app-arch/bzip2
	sys-libs/zlib
	dev-cpp/tbb:=
	adolc? ( sci-libs/adolc )
	arpack? ( sci-libs/arpack[mpi=] )
	assimp? ( media-libs/assimp:= )
	cuda? ( dev-util/nvidia-cuda-toolkit )
	ginkgo? ( sci-libs/ginkgo )
	gmsh? ( sci-libs/gmsh )
	gsl? ( sci-libs/gsl:= )
	hdf5? ( sci-libs/hdf5[mpi=] )
	lapack? ( virtual/lapack )
	metis? (
		>=sci-libs/metis-5
		mpi? ( >=sci-libs/parmetis-4 )
	)
	mpi? ( virtual/mpi[cxx] )
	muparser? ( dev-cpp/muParser )
	opencascade? ( sci-libs/opencascade:= )
	p4est? ( sci-libs/p4est[mpi] )
	petsc? ( sci-mathematics/petsc[mpi=] )
	scalapack? ( sci-libs/scalapack )
	slepc? ( sci-mathematics/slepc[mpi=] )
	sparse? ( sci-libs/umfpack )
	sundials? ( sci-libs/sundials:= )
	symengine? ( >=sci-libs/symengine-0.4:= )
	trilinos? ( sci-libs/trilinos )"

DEPEND="${RDEPEND}
	virtual/pkgconfig
	doc? ( app-doc/doxygen[dot] dev-lang/perl )"

PATCHES=(
	"${FILESDIR}"/${PN}-9.1.1-no-ld-flags.patch
	"${FILESDIR}"/${P}-fix_p4est_detection.patch
)

src_configure() {
	# deal.II needs a custom build type:
	local CMAKE_BUILD_TYPE=$(usex debug DebugRelease Release)

	local mycmakeargs=(
		-DDEAL_II_PACKAGE_VERSION="${PV}"
		-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=OFF
		-DDEAL_II_ALLOW_AUTODETECTION=OFF
		-DDEAL_II_ALLOW_PLATFORM_INTROSPECTION=OFF
		-DDEAL_II_COMPILE_EXAMPLES=OFF
		-DDEAL_II_DOCHTML_RELDIR="share/doc/${P}/html"
		-DDEAL_II_DOCREADME_RELDIR="share/doc/${P}"
		-DDEAL_II_COMPILE_EXAMPLES=OFF
		-DDEAL_II_EXAMPLES_RELDIR="share/doc/${P}/examples"
		-DDEAL_II_LIBRARY_RELDIR="$(get_libdir)"
		-DDEAL_II_SHARE_RELDIR="share/${PN}"
		-DDEAL_II_WITH_ZLIB=ON
		-DDEAL_II_WITH_ADOLC="$(usex adolc)"
		-DDEAL_II_WITH_ASSIMP="$(usex assimp)"
		-DDEAL_II_WITH_ARPACK="$(usex arpack)"
		-DDEAL_II_WITH_CUDA="$(usex cuda)"
		-DDEAL_II_WITH_GINKGO="$(usex ginkgo)"
		-DDEAL_II_COMPONENT_DOCUMENTATION="$(usex doc)"
		-DDEAL_II_COMPONENT_EXAMPLES="$(usex examples)"
		-DDEAL_II_WITH_GMSH="$(usex gmsh)"
		-DDEAL_II_WITH_GSL="$(usex gsl)"
		-DDEAL_II_WITH_HDF5="$(usex hdf5)"
		-DDEAL_II_WITH_LAPACK="$(usex lapack)"
		-DDEAL_II_WITH_METIS="$(usex metis)"
		-DDEAL_II_WITH_MPI="$(usex mpi)"
		-DDEAL_II_WITH_MUPARSER="$(usex muparser)"
		-DDEAL_II_WITH_OPENCASCADE="$(usex opencascade)"
		-DDEAL_II_WITH_P4EST="$(usex p4est)"
		-DDEAL_II_WITH_PETSC="$(usex petsc)"
		-DDEAL_II_WITH_SCALAPACK="$(usex scalapack)"
		-DDEAL_II_WITH_SLEPC="$(usex slepc)"
		-DDEAL_II_WITH_SUNDIALS="$(usex sundials)"
		-DDEAL_II_WITH_SYMENGINE="$(usex symengine)"
		-DDEAL_II_WITH_UMFPACK="$(usex sparse)"
		-DBUILD_SHARED_LIBS="$(usex !static-libs)"
		-DDEAL_II_PREFER_STATIC_LIBS="$(usex static-libs)"
		-DDEAL_II_WITH_TBB=ON
		-DDEAL_II_WITH_TRILINOS="$(usex trilinos)"
	)

	use opencascade && mycmakeargs+=(
		-DCMAKE_PREFIX_PATH="/usr/$(get_libdir)/opencascade"
	)

	# Do a little dance for purely cosmetic QA reasons. The build system
	# does query for the highest instruction set first and skips the other
	# variables if a "higher" variant is set
	if use cpu_flags_x86_avx512f; then
		mycmakeargs+=( -DDEAL_II_HAVE_AVX512=yes )
		append-cxxflags "-mavx512f"
	elif use cpu_flags_x86_avx; then
		mycmakeargs+=( -DDEAL_II_HAVE_AVX=yes )
		append-cxxflags "-mavx2"
	elif use cpu_flags_x86_avx; then
		mycmakeargs+=( -DDEAL_II_HAVE_SSE2=yes )
		append-cxxflags "-msse2"
	fi

	cmake_src_configure
}

src_install() {
	if use doc && [[ ${PV} != *9999* ]]; then
		# copy missing images to the build directory:
		cp -r "${WORKDIR}"/doc/doxygen/deal.II/images \
			"${BUILD_DIR}"/doc/doxygen/deal.II || die
		# replace links:
		sed -i \
			's#"http://www.dealii.org/images/steps/developer/\(step-.*\)"#"images/\1"#g' \
			"${BUILD_DIR}"/doc/doxygen/deal.II/step_*.html || die "sed failed"
	fi
	cmake_src_install

	# decompress the installed example sources:
	use examples && docompress -x /usr/share/doc/${PF}/examples
}