SUMMARY="A high-performance message passing library (MPI)"
DESCRIPTION="The Open MPI Project is an open source Message Passing \
Interface implementation that is developed and maintained by a consortium \
of academic, research, and industry partners. Open MPI is therefore able \
to combine the expertise, technologies, and resources from all across the \
High Performance Computing community in order to build the best MPI library \
available. Open MPI offers advantages for system and software vendors, \
application developers and computer science researchers."
HOMEPAGE="https://www.open-mpi.org/"
COPYRIGHT="2004-2010 The Trustees of Indiana University and Indiana \
		University Research and Technology Corporation
	2004-2017 The University of Tennessee and The University of Tennessee \
		Research Foundation
	2004-2010 High Performance Computing Center Stuttgart,University of \
		Stuttgart
	2004-2008 The Regents of the University of California
	2006-2017 Los Alamos National Security, LLC.
	2006-2017 Cisco Systems, Inc.
	2006-2010 Voltaire, Inc.
	2006-2017 Sandia National Laboratories
	2006-2010 Sun Microsystems, Inc.
	2006-2017 The University of Houston
	2006-2009 Myricom, Inc.
	2007-2017 UT-Battelle, LLC.
	2007-2017 IBM Corporation
	1998-2005 Forschungszentrum Juelich, Juelich Supercomputing Centre
	2005-2008 ZIH, TU Dresden, Federal Republic of Germany
	2007 Evergrid, Inc.
	2008 Chelsio, Inc.
	2008-2009 Institut National de Recherche en Informatique
	2007 Lawrence Livermore National Security, LLC.
	2007-2017 Mellanox Technologies
	2006-2010 QLogic Corporation
	2008-2017 Oak Ridge National Labs
	2006-2012 Oracle and/or its affiliates
	2009-2015 Bull SAS.
	2010 ARM ltd.
	2016 ARM, Inc.
	2010-2011 Alex Brick
	2012 The University of Wisconsin-La Crosse
	2013-2016 Intel, Inc.
	2011-2017 NVIDIA Corporation
	2016 Broadcom Limited
	2011-2017 Fujitsu Limited
	2014-2015 Hewlett-Packard Development Company, LP.
	2013-2017 Research Organization for Information Science (RIST)
	2017 Amazon.com, Inc. or its affiliates"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://download.open-mpi.org/release/open-mpi/v${portVersion%.*}/openmpi-$portVersion.tar.bz2"
CHECKSUM_SHA256="73866fb77090819b6a8c85cb8539638d37d6877455825b74e289d647a39fd5b5"
PATCHES="openmpi-$portVersion.patchset"

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

openmpiLibs="
	libmca_common_dstore
	libmca_common_monitoring
	libmca_common_ompio
	libmca_common_sm
	libmpi_mpifh
	libmpi_usempi_ignore_tkr
	libmpi_usempif08
	libmpi
	libompitrace
	libopen_pal
	libopen_rte
	"
libmca_common_dstoreVersion=1.0.2
libmca_common_monitoringVersion=50.20.0
libmca_common_ompioVersion=41.29.0
libmca_common_smVersion=40.30.0
libmpi_mpifhVersion=40.30.0
libmpi_usempi_ignore_tkrVersion=40.30.0
libmpi_usempif08Version=40.30.0
libmpiVersion=40.30.0
libompitraceVersion=40.30.0
libopen_palVersion=40.30.0
libopen_rteVersion=40.30.0
for i in $openmpiLibs; do
	eval "${i}VersionCompat=\"\$${i}Version compat >= \${${i}Version%%.*}\""
done

GLOBAL_WRITABLE_FILES="
	settings/openmpi-default-hostfile keep-old
	settings/openmpi-mca-params.conf keep-old
	settings/openmpi-totalview.tcl keep-old
	settings/pmix-mca-params.conf keep-old
	"

PROVIDES="
	openmpi$secondaryArchSuffix = $portVersion
	cmd:aggregate_profile.pl = $portVersion
	cmd:mpicc = $portVersion
	cmd:mpic++ = $portVersion
	cmd:mpicc = $portVersion
	cmd:mpicxx = $portVersion
	cmd:mpiexec = $portVersion
	cmd:mpif77 = $portVersion
	cmd:mpif90 = $portVersion
	cmd:mpifort = $portVersion
	cmd:mpirun = $portVersion
	cmd:ompi_clean = $portVersion
	cmd:ompi_dvm = $portVersion
	cmd:ompi_ps = $portVersion
	cmd:ompi_server = $portVersion
	cmd:ompi_top = $portVersion
	cmd:ompi_info = $portVersion
	cmd:opal_wrapper = $portVersion
	cmd:orte_clean = $portVersion
	cmd:orte_dvm = $portVersion
	cmd:orte_info = $portVersion
	cmd:orte_ps = $portVersion
	cmd:orte_server = $portVersion
	cmd:orte_top = $portVersion
	cmd:ortecc = $portVersion
	cmd:orted = $portVersion
	cmd:orterun = $portVersion
	cmd:profile2mat.pl = $portVersion
	cmd:prun = $portVersion
	lib:libmca_common_dstore$secondaryArchSuffix = $libmca_common_dstoreVersionCompat
	lib:libmca_common_monitoring$secondaryArchSuffix = $libmca_common_monitoringVersionCompat
	lib:libmca_common_ompio$secondaryArchSuffix = $libmca_common_ompioVersionCompat
	lib:libmca_common_sm$secondaryArchSuffix = $libmca_common_smVersionCompat
	lib:libmpi$secondaryArchSuffix = $libmpiVersionCompat
	lib:libmpi_mpifh$secondaryArchSuffix = $libmpi_mpifhVersionCompat
	lib:libmpi_usempi_ignore_tkr$secondaryArchSuffix = $libmpi_usempi_ignore_tkrVersionCompat
	lib:libmpi_usempif08$secondaryArchSuffix = $libmpi_usempif08VersionCompat
	lib:libompitrace$secondaryArchSuffix = $libompitraceVersionCompat
	lib:libopen_pal$secondaryArchSuffix = $libopen_palVersionCompat
	lib:libopen_rte$secondaryArchSuffix = $libopen_rteVersionCompat
	lib:ompi_monitoring_prof$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libexecinfo$secondaryArchSuffix
	lib:libevent_2.1$secondaryArchSuffix
	lib:libevent_pthreads_2.1$secondaryArchSuffix
	lib:libgfortran$secondaryArchSuffix
	lib:libgomp$secondaryArchSuffix
	lib:libhwloc$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	openmpi${secondaryArchSuffix}_devel = $portVersion
	devel:libmca_common_monitoring$secondaryArchSuffix = $libmca_common_monitoringVersionCompat
	devel:libmca_common_ompio$secondaryArchSuffix = $libmca_common_ompioVersionCompat
	devel:libmca_common_sm$secondaryArchSuffix = $libmca_common_smVersionCompat
	devel:libmpi$secondaryArchSuffix = $libmpiVersionCompat
	devel:libmpi_mpifh$secondaryArchSuffix = $libmpi_mpifhVersionCompat
	devel:libmpi_usempi_ignore_tkr$secondaryArchSuffix = $libmpi_usempi_ignore_tkrVersionCompat
	devel:libmpi_usempif08$secondaryArchSuffix = $libmpi_usempif08VersionCompat
	devel:libompitrace$secondaryArchSuffix = $libompitraceVersionCompat
	devel:libopen_pal$secondaryArchSuffix = $libopen_palVersionCompat
	devel:libopen_rte$secondaryArchSuffix = $libopen_rteVersionCompat
	devel:ompi_monitoring_prof$secondaryArchSuffix
	"
REQUIRES_devel="
	openmpi$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libevent_2.1$secondaryArchSuffix
	devel:libevent_pthreads_2.1$secondaryArchSuffix
	devel:libexecinfo$secondaryArchSuffix
	devel:libhwloc$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:bison
	cmd:flex
	cmd:gfortran$secondaryArchSuffix
	cmd:g++$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:perl
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage openmpi$secondaryArchSuffix \
	"$libDir"/libmca_common_dstore.so.$libmca_common_dstoreVersion \
	"$libDir"/libmca_common_monitoring.so.$libmca_common_monitoringVersion \
	"$libDir"/libmca_common_ompio.so.$libmca_common_ompioVersion \
	"$libDir"/libmca_common_sm.so.$libmca_common_smVersion \
	"$libDir"/libmpi.so.$libmpiVersion \
	"$libDir"/libmpi_mpifh.so.$libmpi_mpifhVersion \
	"$libDir"/libmpi_usempi_ignore_tkr.so.$libmpi_usempi_ignore_tkrVersion \
	"$libDir"/libmpi_usempif08.so.$libmpi_usempif08Version \
	"$libDir"/libompitrace.so.$libompitraceVersion \
	"$libDir"/libopen-pal.so.$libopen_palVersion \
	"$libDir"/libopen-rte.so.$libopen_rteVersion \
	"$libDir"/ompi_monitoring_prof.so

BUILD()
{
	LDFLAGS="-lnetwork -lbsd" \
	CFLAGS="-D_BSD_SOURCE" \
	runConfigure --omit-dirs "libExecDir" ./configure \
		--libexecdir="$libExecDir/openmpi" \
		--with-libevent \
		--with-hwloc=external \
		--with-zlib

	make $jobArgs
}

INSTALL()
{
	make install $jobArgs

	rm $libDir/*.la
	rm $libDir/pmix/*.la
	rm $libDir/openmpi/*.la

	prepareInstalledDevelLibs \
		libmpi \
		libopen-pal \
		libopen-rte

	fixPkgconfig

	packageEntries devel \
		$developDir
}

TEST()
{
	LIBRARY_PATH=$LIBRARY_PATH:$sourceDir/ompi/.libs:$sourceDir/opal/.libs:$sourceDir/orte/.libs make check
}
