summaryrefslogtreecommitdiff
blob: 3c424fdf3c6564c0e94aaaedf8bfcecccc37129b (plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=5

FORTRAN_NEEDED=fortran

inherit eutils fortran-2 java-pkg-opt-2 toolchain-funcs

MY_P=${P/_/}

DESCRIPTION="MPI development tools"
HOMEPAGE="http://www-unix.mcs.anl.gov/perfvis/download/index.htm"
SRC_URI="ftp://ftp.mcs.anl.gov/pub/mpi/${PN%2}/${MY_P}.tar.gz"

LICENSE="mpich2"
SLOT="0"
KEYWORDS="amd64 x86"
IUSE="debug minimal fortran threads"

COMMON_DEPEND="
	!minimal? (
		x11-libs/libXtst
		x11-libs/libXi
	)
	|| (
		sys-cluster/openmpi[fortran?,threads?]
		sys-cluster/mpich2[fortran?,threads?]
	)"

DEPEND="
	!minimal? ( >=virtual/jdk-1.6 )
	${COMMON_DEPEND}"

RDEPEND="
	!minimal? ( >=virtual/jre-1.6 )
	${COMMON_DEPEND}"

S="${WORKDIR}"/${MY_P}
MPE_IMP=""

# README:
# This ebuild is created to handle building with both mpich2 and openmpi.
# However, without empi (in the science overlay), and some further
# conversion to use mpi.eclass, we can only handle one implementation
# at a time.  I still believe it's better to have the ebuild setup
# correctly in preperation.

pkg_setup() {
	fortran-2_pkg_setup
	local i

	if has_version sys-cluster/openmpi; then
		MPE_IMP=openmpi
	elif has_version sys-cluster/mpich2; then
		MPE_IMP=mpich2
	elif has_version sys-cluster/mpich; then
		MPE_IMP=mpich2
	else
		die "Unknown MPI implementation"
	fi

	export JFLAGS="${JFLAGS} $(java-pkg_javac-args)"

	if [[ "${MPE_IMP}" == openmpi ]] && [ -z "${MPE2_FORCE_OPENMPI_TEST}" ]; then
		echo
		elog "Currently src_test fails on collchk with openmpi, hence"
		elog "testing is disabled by default.  If you would like to"
		elog "force testing, please add MPE_FORCE_OPENMPI_TEST=1"
		elog "to your environment."
		echo
	fi

	einfo "Building with support for: sys-cluster/${MPE_IMP}"

	use minimal || java-pkg-opt-2_pkg_setup
}

src_prepare() {
	# Don't assume path contains ./
	sed -i 's,\($MPERUN\) $pgm,\1 ./$pgm,' sbin/mpetestexeclog.in || die
	epatch \
		"${FILESDIR}"/slog2sdk-trace_rlog-makefile-fixes.patch \
		"${FILESDIR}"/slog2sdk-trace_sample-makefile-fixes.patch

	use minimal || java-pkg-opt-2_src_prepare
}

src_configure() {
	local c="--with-mpicc=/usr/bin/mpicc"

	if use fortran; then
		c+=" --with-mpif77=/usr/bin/mpif77"
	else
		c+=" --disable-f77"
	fi

	if use minimal; then
		c+=" --enable-slog2=no --disable-rlog --disable-sample"
	else
		c+=" --with-java2=$(java-config --jdk-home) --enable-slog2=build"
	fi

	[[ "${MPE_IMP}" == openmpi ]] && c+=" --disable-rlog --disable-sample"

	econf ${c} \
		--sysconfdir=/etc/${PN} \
		--datadir=/usr/share/${PN} \
		--with-htmldir=/usr/share/${PN} \
		--with-docdir=/usr/share/${PN} \
		--enable-collchk \
		--enable-wrappers \
		$(use_enable !minimal graphics) \
		$(use_enable threads threadlogging) \
		$(use_enable debug g)
}

src_test() {
	local rc

	cd "${S}" || die
	if [[ "${MPE_IMP}" == mpich2 ]]; then
		echo "MPD_SECRETWORD=junk" > "${T}"/mpd.conf || die
		chmod 600 "${T}"/mpd.conf || die
		export MPD_CONF_FILE="${T}/mpd.conf"
		"${ROOT}"usr/bin/mpd -d --pidfile="${T}"/mpd.pid || die
	elif [[ "${MPE_IMP}" == openmpi* ]] && [ -z "${MPE2_FORCE_OPENMPI_TEST}" ]; then
		echo
		einfo "Skipping tests for openmpi"
		echo
		return 0
	fi

	# No parallel make:
	# http://trac.mcs.anl.gov/projects/mpich2/ticket/1095#comment:1
	emake -j1 \
		CC="${S}"/bin/mpecc \
		FC="${S}"/bin/mpefc \
		MPERUN="${ROOT}/usr/bin/mpiexec -n 4" \
		CLOG2TOSLOG2="${S}/src/slog2sdk/bin/clog2TOslog2" \
		check;
		rc=${?}
	if [[ "${MPE_IMP}" == mpich2 ]]; then
		"${ROOT}"usr/bin/mpdallexit || kill $(<"${T}"/mpd.pid)
	fi

	return ${rc}
}

src_install() {
	# No parallel make:
	# http://trac.mcs.anl.gov/projects/mpich2/ticket/1095#comment:1
	MAKEOPTS+=" -j1"
	default
	rm -f "${ED}"/usr/sbin/mpeuninstall || die
	rm -f "${ED}"/usr/bin/*.in || die
}