SUMMARY="The Hardware Locality library"
DESCRIPTION="The Hardware Locality (hwloc) software project aims at easing the \
process of discovering hardware resources in parallel architectures. It offers \
command-line tools and a C API for consulting these resources, their locality, \
attributes, and interconnection. hwloc primarily aims at helping \
high-performance computing (HPC) applications, but is also applicable to any \
project seeking to exploit code and/or data locality on modern computing \
platforms."
HOMEPAGE="https://www.open-mpi.org/projects/hwloc/"
COPYRIGHT="2004-2006 The Trustees of Indiana University and Indiana \
		University Research and Technology Corporation
	2004-2005 The University of Tennessee and The University of Tennessee \
		Research Foundation
	2004-2005 High Performance Computing Center Stuttgart, University of \
		Stuttgart
	2004-2005 The Regents of the University of California
	2009      CNRS
	2009-2016 Inria
	2009-2015 Université Bordeaux
	2009-2015 Cisco Systems, Inc.
	2009-2012 Oracle and/or its affiliates
	2010      IBM
	2010      Jirka Hladky
	2012      Aleksej Saushev, The NetBSD Foundation
	2012      Blue Brain Project, EPFL
	2013-2014 University of Wisconsin-La Crosse
	2015      Research Organization for Information Science and Technology \
		(RIST)
	2015-2016 Intel, Inc."
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://download.open-mpi.org/release/hwloc/v${portVersion%.*}/hwloc-$portVersion.tar.bz2"
CHECKSUM_SHA256="392421e69f26120c8ab95d151fe989f2b4b69dab3c7735741c4e0a6d7de5de63"
SOURCE_DIR="hwloc-$portVersion"

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

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

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

PROVIDES="
	hwloc2$secondaryArchSuffix = $portVersion
	lib:libhwloc$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libltdl$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	"

PROVIDES_devel="
	hwloc2${secondaryArchSuffix}_devel = $portVersion
	devel:libhwloc$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	hwloc2$secondaryArchSuffix == $portVersion base
	"
CONFLICTS_devel="
	hwloc${secondaryArchSuffix}_devel
	"

PROVIDES_tools="
	hwloc2${secondaryArchSuffix}_tools = $portVersion
	cmd:hwloc_annotate$commandSuffix = $portVersion
	cmd:hwloc_bind$commandSuffix = $portVersion
	cmd:hwloc_calc$commandSuffix = $portVersion
	cmd:hwloc_compress_dir$commandSuffix = $portVersion
	cmd:hwloc_diff$commandSuffix = $portVersion
	cmd:hwloc_distrib$commandSuffix = $portVersion
	cmd:hwloc_gather_cpuid$commandSuffix = $portVersion
	cmd:hwloc_info$commandSuffix = $portVersion
	cmd:hwloc_ls$commandSuffix = $portVersion
	cmd:hwloc_patch$commandSuffix = $portVersion
	cmd:hwloc_ps$commandSuffix = $portVersion
	cmd:lstopo$commandSuffix = $portVersion
	cmd:lstopo_no_graphics$commandSuffix = $portVersion
	"
REQUIRES_tools="
	hwloc2$secondaryArchSuffix == $portVersion base
	$REQUIRES
	"
CONFLICTS_tools="
	hwloc${secondaryArchSuffix}_tools
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libxml2$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage hwloc2$secondaryArchSuffix \
	$libDir/hwloc/hwloc_xml_libxml.so \
	$libDir/libhwloc.so.$libVersion \
	"$(getPackagePrefix tools)"/bin/hwloc-annotate \
	"$(getPackagePrefix tools)"/bin/hwloc-bind \
	"$(getPackagePrefix tools)"/bin/hwloc-calc \
	"$(getPackagePrefix tools)"/bin/hwloc-diff \
	"$(getPackagePrefix tools)"/bin/hwloc-distrib \
	"$(getPackagePrefix tools)"/bin/hwloc-gather-cpuid \
	"$(getPackagePrefix tools)"/bin/hwloc-info \
	"$(getPackagePrefix tools)"/bin/hwloc-patch \
	"$(getPackagePrefix tools)"/bin/hwloc-ps \
	"$(getPackagePrefix tools)"/bin/lstopo-no-graphics

BUILD()
{
	LDFLAGS="-lnetwork" \
	runConfigure --omit-dirs "binDir sbinDir" ./configure \
		--sbindir=$commandBinDir \
		--enable-plugins
	make $jobArgs
}

INSTALL()
{
	install -d $docDir

	make install
	rm -f $libDir/hwloc/*.la
	rm -f $libDir/libhwloc.la

	prepareInstalledDevelLib libhwloc
	fixPkgconfig

	packageEntries devel \
		$developDir \
		$docDir/hwloc-*.pdf \
		$manDir/man3

	packageEntries tools \
		$commandBinDir

	install -t $docDir AUTHORS COPYING README
}

TEST()
{
	export LIBRARY_PATH=$LIBRARY_PATH:$sourceDir/hwloc/.libs
	make check
}
