SUMMARY="A file format and library for storing scientific data"
DESCRIPTION="HDF5 was designed and implemented to address the deficiencies \
of HDF4.x. It has a more powerful and flexible data model, supports files \
larger than 2 GB, and supports parallel I/O."
HOMEPAGE="https://www.hdfgroup.org/HDF5/"
COPYRIGHT="2011-2019 The HDF Group,
	The Board of Trustees of the University of Illinois."
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-$portVersion/src/hdf5-$portVersion.tar.gz"
CHECKSUM_SHA256="a62dcb276658cb78e6795dd29bf926ed7a9bc4edf6e77025cd2c689a8f97c17a"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

libhdf5Version="200.0.0"
libhdf5VersionCompat="$libhdf5Version compat >= ${libhdf5Version%%.*}"
libhdf5_cppVersion="200.0.0"
libhdf5_cppVersionCompat="$libhdf5_cppVersion compat >= ${libhdf5_cppVersion%%.*}"
libhdf5_fortranVersion="200.0.0"
libhdf5_fortranVersionCompat="$libhdf5_fortranVersion compat >= ${libhdf5_fortranVersion%%.*}"
libhdf5_hlVersion="200.0.0"
libhdf5_hlVersionCompat="$libhdf5_hlVersion compat >= ${libhdf5_hlVersion%%.*}"
libhdf5_hl_cppVersion="200.0.0"
libhdf5_hl_cppVersionCompat="$libhdf5_hl_cppVersion compat >= ${libhdf5_hl_cppVersion%%.*}"
libhdf5hl_fortranVersion="200.0.0"
libhdf5hl_fortranVersionCompat="$libhdf5hl_fortranVersion compat >= ${libhdf5hl_fortranVersion%%.*}"

PROVIDES="
	hdf5$secondaryArchSuffix = $portVersion
	cmd:gif2h5$secondaryArchSuffix
	cmd:h52gif$secondaryArchSuffix
	cmd:h5c++$secondaryArchSuffix
	cmd:h5cc$secondaryArchSuffix
	cmd:h5clear$secondaryArchSuffix
	cmd:h5copy$secondaryArchSuffix
	cmd:h5debug$secondaryArchSuffix
	cmd:h5diff$secondaryArchSuffix
	cmd:h5dump$secondaryArchSuffix
	cmd:h5fc$secondaryArchSuffix
	cmd:h5format_convert$secondaryArchSuffix
	cmd:h5import$secondaryArchSuffix
	cmd:h5jam$secondaryArchSuffix
	cmd:h5ls$secondaryArchSuffix
	cmd:h5mkgrp$secondaryArchSuffix
	cmd:h5perf_serial$secondaryArchSuffix
	cmd:h5redeploy$secondaryArchSuffix
	cmd:h5repack$secondaryArchSuffix
	cmd:h5repart$secondaryArchSuffix
	cmd:h5stat$secondaryArchSuffix
	cmd:h5unjam$secondaryArchSuffix
	cmd:h5watch$secondaryArchSuffix
	lib:libhdf5$secondaryArchSuffix = $libhdf5VersionCompat
	lib:libhdf5_cpp$secondaryArchSuffix = $libhdf5_cppVersionCompat
	lib:libhdf5_fortran$secondaryArchSuffix = $libhdf5_fortranVersionCompat
	lib:libhdf5_hl$secondaryArchSuffix = $libhdf5_hlVersionCompat
	lib:libhdf5_hl_cpp$secondaryArchSuffix = $libhdf5_hl_cppVersionCompat
	lib:libhdf5hl_fortran$secondaryArchSuffix = $libhdf5hl_fortranVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libgettextpo$secondaryArchSuffix
	lib:libgfortran$secondaryArchSuffix
	lib:libgomp$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	hdf5${secondaryArchSuffix}_devel = $portVersion
	devel:libhdf5$secondaryArchSuffix = $libhdf5VersionCompat
	devel:libhdf5_cpp$secondaryArchSuffix = $libhdf5_cppVersionCompat
	devel:libhdf5_fortran$secondaryArchSuffix = $libhdf5_fortranVersionCompat
	devel:libhdf5_hl$secondaryArchSuffix = $libhdf5_hlVersionCompat
	devel:libhdf5_hl_cpp$secondaryArchSuffix = $libhdf5_hl_cppVersionCompat
	devel:libhdf5hl_fortran$secondaryArchSuffix = $libhdf5hl_fortranVersionCompat
	devel:libhdf5_hl_fortran$secondaryArchSuffix = $libhdf5hl_fortranVersionCompat
	"
REQUIRES_devel="
	hdf5$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libgettextlib$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoreconf
	cmd:awk
	cmd:g++$secondaryArchSuffix
	cmd:gettext$secondaryArchSuffix
	cmd:gfortran$secondaryArchSuffix
	cmd:grep
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:perl
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	autoreconf -fi
	runConfigure ./configure \
		--enable-hl \
		--enable-build-mode=production \
		--enable-fortran \
		--enable-fortran2003 \
		--enable-cxx \
		--disable-sharedlib-rpath \
		--disable-threadsafe
	make $jobArgs
}

INSTALL()
{
	make install $jobArgs

	rm $libDir/lib*.la || true

	prepareInstalledDevelLibs \
		libhdf5 \
		libhdf5_cpp \
		libhdf5_fortran \
		libhdf5_hl \
		libhdf5_hl_cpp \
		libhdf5hl_fortran \
		libhdf5_hl_fortran

	fixPkgconfig

	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
