aboutsummaryrefslogtreecommitdiff
path: root/Mk/Uses/mpi.mk
blob: cf14ec675118cf74a6f66a1ba7f453ad75294032 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Handle dependencies on MPICH / OpenMPI
#
# Feature:	mpi
# Usage:	USES=mpi or USES=mpi:ARGS
# Valid ARGS:	mpich (default) openmpi
# Note: mpich2 and openmpi3 are not handled
#
# Provides:	MPI_LIBS MPI_CFLAGS MPICC MPICXX MPIF90 MPIFC MPI_HOME	\
#		MPIEXEC MPIRUN
# Sets:		LIB_DEPENDS
#		+ CMAKE_ARGS if cmake is enabled to drive FindMPI.cmake
#
# Maintainer:	thierry@FreeBSD.org

.if !defined(_INCLUDE_USES_MPI_MK)
_INCLUDE_USES_MPI_MK=	yes

_valid_ARGS=	mpich openmpi

_DEFAULT_MPI=	mpich

.  if empty(mpi_ARGS)
mpi_ARGS=	${_DEFAULT_MPI}
.  endif

.  if ! ${USES:Mpkgconfig}
USES+=	pkgconfig
.  endif

.  if ${mpi_ARGS} == mpich
LIB_DEPENDS+=	libmpich.so:net/mpich
MPI_HOME=	${LOCALBASE}
MPI_LIBS+=	`pkgconf --libs mpich`
MPI4PY=		${PYTHON_PKGNAMEPREFIX}mpi4py-mpich>0:net/py-mpi4py-mpich@${PY_FLAVOR}
.    if ${USES:Mfortran}
MPI_LIBS+=	-lmpifort
MPIFC=		${MPI_HOME}/bin/mpif90
MPIF90=		${MPIFC}
.    endif
MPI_CFLAGS+=	`pkgconf --cflags mpich`
.  elif ${mpi_ARGS} == openmpi
.    if ${ARCH} == armv6 || ${ARCH} == armv7 || ${ARCH} == i386 || ${ARCH} == powerpc
LIB_DEPENDS+=	libmpi_cxx.so:net/openmpi4
.    else
LIB_DEPENDS+=	libmpi_mpifh.so:net/openmpi
.    endif
MPI_HOME=	${LOCALBASE}/mpi/openmpi
MPI4PY=		${PYTHON_PKGNAMEPREFIX}mpi4py>0:net/py-mpi4py@${PY_FLAVOR}
.    if ${USES:Mfortran}
MPI_LIBS+=	`pkgconf --libs ompi-fort`
MPIFC=		${MPI_HOME}/bin/mpif90
MPIF90=		${MPIFC}
.    else
MPI_LIBS+=	`pkgconf --libs ompi`
.    endif
MPI_CFLAGS+=	`pkgconf --cflags ompi`
.  else
IGNORE=		USES=mpi: invalid arguments: ${mpi_ARGS}
.  endif

MPICC=		${MPI_HOME}/bin/mpicc
MPICXX=		${MPI_HOME}/bin/mpicxx
MPIEXEC=	${MPI_HOME}/bin/mpiexec
MPIRUN=		${MPI_HOME}/bin/mpirun

.  if ${USES:Mcmake} || ${USES:Mcmake\:*}
CMAKE_ARGS+=	-DMPIEXEC_EXECUTABLE:FILEPATH="${MPIEXEC}"	\
		-DMPI_HOME:PATH="${MPI_HOME}"
.  endif

.endif