summaryrefslogtreecommitdiff
blob: 9a32e2c0b5c5136fdd3e16b2c8145f19a919f848 (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
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

inherit autotools toolchain-funcs multilib

MY_P="${PN^^[gasn]}-${PV}"
DESCRIPTION="Networking middleware for partitioned global address space (PGAS) language"
HOMEPAGE="http://gasnet.lbl.gov/"
SRC_URI="http://gasnet.lbl.gov/${MY_P}.tar.gz"

SOVER="${PV%%.*}"
LICENSE="BSD"
SLOT="0/${PV}"
KEYWORDS="~amd64 ~arm"
IUSE="mpi test threads"

DEPEND="mpi? ( virtual/mpi )"
RDEPEND="${DEPEND}"

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

static_to_shared() {
	local libstatic="${1}"; shift
	local libname="${libstatic%.a}"
	libname="${libname##*/}"
	local soname="${libname}$(get_libname ${SOVER})"
	local libdir="${libstatic%/*}"

	einfo "Making ${soname} from ${libstatic} with libs ${@}"
	if [[ ${CHOST} == *-darwin* ]] ; then
		${LINK:-$(tc-getCXX)} ${LDFLAGS}  \
			-dynamiclib -install_name "${EPREFIX}"/usr/lib/"${soname}" \
			-Wl,-all_load -Wl,${libstatic} \
			"$@" -o ${libdir}/${soname} || die "${soname} failed"
	else
		${LINK:-$(tc-getCXX)} ${LDFLAGS}  \
			-shared -Wl,-soname=${soname} \
			-Wl,-z,defs \
			-Wl,--whole-archive ${libstatic} -Wl,--no-whole-archive \
			"$@" -o ${libdir}/${soname} || die "${soname} failed"
		ln -s ${soname} ${libdir}/${libname}$(get_libname)
	fi
}

src_prepare() {
	find . \
		\( -name Makefile.am -or -name "*.mak" \) \
		-exec sed -i '/^docdir/s/^/#/' {} + || die
	default
	eautoreconf
}

src_configure() {
	econf \
		$(use_enable mpi) \
		$(use_enable threads pthreads) \
		CC="$(tc-getCC) ${CFLAGS} -fPIC" \
		MPI_CC="mpicc ${CFLAGS} -fPIC" \
		CXX="$(tc-getCXX) ${CXXFLAGS} -fPIC"
}

src_compile() {
	emake MANUAL_CFLAGS="${CFLAGS} -fPIC" MANUAL_MPICFLAGS="${CFLAGS} -fPIC" MANUAL_CXXFLAGS="${CXXFLAGS} -fPIC"
}

src_test() {
	emake check MANUAL_CFLAGS="${CFLAGS} -fPIC" MANUAL_MPICFLAGS="${CFLAGS} -fPIC" MANUAL_CXXFLAGS="${CXXFLAGS} -fPIC"
}

src_install() {
	local l libs
	default
	for l in "${ED}/usr/$(get_libdir)"/lib{gasnet_tools-seq,am*,*}.a; do
		[[ -f ${l} ]] || continue
		libs=
		[[ ${l} = */libgasnet-*-par* ]] && libs+=" -lpthread"
		[[ ${l} = */libamudp.a ]] && libs+=" -L${ED}/usr/$(get_libdir) -lgasnet_tools-seq"
		[[ ${l} = */libammpi.a ]] && libs+=" -lmpi"
		[[ ${l} = */libgasnet-udp-* ]] && libs+=" -L${ED}/usr/$(get_libdir) -lamudp"
		[[ ${l} = */libgasnet-mpi-* ]] && libs+=" -L${ED}/usr/$(get_libdir) -lammpi"
		[[ ${l} = */libgasnet-*-* ]] && libs+=" -lrt"
		static_to_shared "${l}" ${libs}
		rm ${l} || die
	done
}