# Template file for 'papi'
pkgname=papi
version=7.0.1
revision=1
build_wrksrc="src"
build_style=gnu-configure
configure_args="--with-pfm-root=$XBPS_CROSS_BASE/usr --with-tls=__thread
 --with-ffsll --with-virtualtimer=cloc_thread_cputime_id
 --with-walltimer=clock_realtime --with-arch=${XBPS_TARGET_MACHINE%-musl}"
hostmakedepends="gcc-fortran openmpi"
makedepends="libpfm4-devel libgomp-devel openmpi-devel"
short_desc="Provides interface for use of performance counter hardware"
maintainer="Orphaned <orphan@voidlinux.org>"
license="BSD-3-Clause"
homepage="https://icl.utk.edu/papi/"
distfiles="http://icl.utk.edu/projects/papi/downloads/papi-${version}.tar.gz"
checksum=c105da5d8fea7b113b0741a943d467a06c98db959ce71bdd9a50b9f03eecc43e
python_version=3

case "$XBPS_TARGET_MACHINE" in
	i686*|x86_64*) configure_args+=" --with-CPU=x86" ;;
	arm*|aarch*) configure_args+=" --with-CPU=arm" ;;
	ppc*-musl) broken="requires non-standard __ppc_get_timebase_freq";;
	ppc64le*) configure_args+=" --with-CPU=POWER8" ;;
	ppc64*) configure_args+=" --with-CPU=PPC970" ;;
	ppc*) configure_args+=" --with-CPU=ppc" ;;
	mips*) configure_args+=" --with-CPU=mips" ;;
esac

pre_build() {
	export OMPI_CC="$CC"
	export OMPI_FC="$FC"
}

post_extract() {
	rm -rf src/libpfm*
}

post_install() {
	vlicense ../LICENSE.txt
}

papi-devel_package() {
	short_desc+=" - development files"
	depends="${sourcepkg}>=${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/*.a
		vmove usr/lib/*.so
		vmove usr/lib/pkgconfig
		vmove usr/share/man/man3
	}
}
