SUMMARY="C++ library for netCDF"
DESCRIPTION="NetCDF (network Common Data Form) is an interface for \
scientific data access and a freely-distributed software library that \
provides an implementation of the interface. The netCDF library also \
defines a machine-independent format for representing scientific data. \
Together, the interface, library, and format support the creation, access, \
and sharing of scientific data. This is the C++ library which links to the \
C library."
HOMEPAGE="https://www.unidata.ucar.edu/software/netcdf/"
COPYRIGHT="1993-2011 University Corporation for Atmospheric Research/Unidata"
LICENSE="UCAR_Unidata"
REVISION="1"
SOURCE_URI="https://github.com/Unidata/netcdf-cxx4/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="e3fe3d2ec06c1c2772555bf1208d220aab5fee186d04bd265219b0bc7a978edc"
SOURCE_DIR="netcdf-cxx4-$portVersion"

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

libVersion="1.1.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	netcdf_cxx$secondaryArchSuffix = $portVersion
	lib:libh5bzip2$secondaryArchSuffix
	lib:libnetcdf_c++4$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libnetcdf$secondaryArchSuffix
	"

PROVIDES_devel="
	netcdf_cxx${secondaryArchSuffix}_devel = $portVersion
	cmd:ncxx4_config$secondaryArchSuffix = $portVersion
	devel:libnetcdf_c++4$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	netcdf_cxx$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libhdf5$secondaryArchSuffix
	devel:libnetcdf$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:dd
	cmd:g++$secondaryArchSuffix
	cmd:grep
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:sed
	"

defineDebugInfoPackage netcdf_cxx$secondaryArchSuffix \
	"$libDir"/libnetcdf_c++4.so.$libVersion

BUILD()
{
	mkdir -p haiku_build && cd haiku_build
	runConfigure ../configure
	make $jobArgs
}

INSTALL()
{
	cd haiku_build
	make install $jobArgs

	rm -f $libDir/lib*.la $libDir/libnetcdf_c++4.a

	prepareInstalledDevelLib \
		libnetcdf_c++4

	fixPkgconfig

	packageEntries devel \
		$binDir \
		$developDir
}

TEST()
{
	cd haiku_build
	make check
}
