summaryrefslogtreecommitdiff
blob: c5ef043111b3f4ad7d7971393f68c6ef14701564 (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
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

FORTRAN_NEEDED="fortran"

inherit cmake flag-o-matic fortran-2

MY_P="${PN}-${PV/_p/-patch}"
MAJOR_P="${PN}-$(ver_cut 1-2)"

DESCRIPTION="General purpose library and file format for storing scientific data"
HOMEPAGE="https://www.hdfgroup.org/HDF5/"
SRC_URI="https://www.hdfgroup.org/ftp/HDF5/releases/${MAJOR_P}/${MY_P}/src/${MY_P}.tar.bz2"

LICENSE="NCSA-HDF"
SLOT="0/${PV%%_p*}"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~x86-linux"
IUSE="cxx debug doc examples fortran +hl mpi szip test threads unsupported zlib"

REQUIRED_USE="
	!unsupported? (
		mpi? ( !cxx !threads )
		threads? ( !cxx !fortran !hl )
	)"

RESTRICT="!test? ( test )"

RDEPEND="
	mpi? ( virtual/mpi[romio] )
	szip? ( virtual/szip )
	zlib? ( sys-libs/zlib:0= )
"
DEPEND="${RDEPEND}"
BDEPEND="doc? (
	app-doc/doxygen
	virtual/latex-base
)"

PATCHES=(
	"${FILESDIR}"/${PN}-1.12.1-cmake_installdirs.patch
)

S="${WORKDIR}/${MY_P}"

pkg_setup() {
	use fortran && fortran-2_pkg_setup

	if use mpi; then
		if has_version 'sci-libs/hdf5[-mpi]'; then
			ewarn "Installing hdf5 with mpi enabled with a previous hdf5 with mpi disabled may fail."
			ewarn "Try to uninstall the current hdf5 prior to enabling mpi support."
		fi
		export CC="mpicc"
		use fortran && export FC="mpif90"
		append-libs -lmpi
	elif has_version 'sci-libs/hdf5[mpi]'; then
		ewarn "Installing hdf5 with mpi disabled while having hdf5 installed with mpi enabled may fail."
		ewarn "Try to uninstall the current hdf5 prior to disabling mpi support."
	fi
}

src_configure() {
	local mycmakeargs=(
		-DBUILD_STATIC_LIBS=OFF
		-DFETCHCONTENT_FULLY_DISCONNECTED=ON
		-DHDF5_BUILD_EXAMPLES=OFF
		-DALLOW_UNSUPPORTED=$(usex unsupported)
		-DBUILD_TESTING=$(usex test)
		-DHDF5_BUILD_CPP_LIB=$(usex cxx)
		-DHDF5_BUILD_DOC=$(usex doc)
		-DHDF5_BUILD_FORTRAN=$(usex fortran)
		-DHDF5_BUILD_HL_LIB=$(usex hl)
		-DHDF5_ENABLE_CODESTACK=$(usex debug)
		-DHDF5_ENABLE_PARALLEL=$(usex mpi)
		-DHDF5_ENABLE_SZIP_ENCODING=$(usex szip)
		-DHDF5_ENABLE_SZIP_SUPPORT=$(usex szip)
		-DHDF5_ENABLE_THREADSAFE=$(usex threads)
		-DHDF5_ENABLE_Z_LIB_SUPPORT=$(usex zlib)
	)
	cmake_src_configure
}

src_install() {
	cmake_src_install

	# TODO: generate functioning example runners from their respective
	# .in files - as of version 1.12.1 upstream only has it implemented
	# for autoconf.
	if use examples; then
		# These are all useless outside the source tree
		rm -f {examples,c++/examples,fortran/examples}/{Makefile*,CMake*}
		rm -f hl/{examples,c++/examples,fortran/examples}/{Makefile*,CMake*}

		dodoc -r examples
		if use cxx; then
			docinto c++
			dodoc -r c++/examples
		fi
		if use fortran; then
			docinto fortran
			dodoc -r fortran/examples
		fi
		if use hl; then
			docinto hl
			dodoc -r hl/examples
			if use cxx; then
				docinto hl/c++
				dodoc -r hl/c++/examples
			fi
			if use fortran; then
				docinto hl/fortran
				dodoc -r hl/fortran/examples
			fi
		fi
	fi
}