summaryrefslogtreecommitdiff
blob: f6371172f867233c8405863082d71fad17793794 (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
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sci-libs/scotch/scotch-5.1.11.ebuild,v 1.2 2011/03/15 16:58:35 bicatali Exp $

EAPI=4

inherit eutils toolchain-funcs versionator alternatives-2

# use esmumps version to allow linking with mumps
MYP="${PN}_${PV}_esmumps"
# download id on gforge changes every goddamn release
DID=28044

DESCRIPTION="Software for graph, mesh and hypergraph partitioning"
HOMEPAGE="http://www.labri.u-bordeaux.fr/perso/pelegrin/scotch/"
SRC_URI="http://gforge.inria.fr/frs/download.php/${DID}/${MYP}.tgz"

LICENSE="CeCILL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="doc examples mpi static-libs tools"

DEPEND="sys-devel/bison
	sys-libs/zlib
	mpi? ( virtual/mpi )"
RDEPEND="${DEPEND}"

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

make_shared_lib() {
	local libstatic=${1}
	local soname=$(basename "${1%.a}").so.$(get_major_version)
	shift
	einfo "Making ${soname}"
	${LINK:-$(tc-getCC)} ${LDFLAGS}  \
		-shared -Wl,-soname="${soname}" \
		-Wl,--whole-archive "${libstatic}" -Wl,--no-whole-archive \
		"$@" -o $(dirname "${libstatic}")/"${soname}" || die "${soname} failed"
}

src_prepare() {
	epatch "${FILESDIR}"/metis-header.patch
	epatch "${FILESDIR}"/respect-ldflags.patch
	sed -e "s/@CFLAGS@/${CFLAGS}/" \
		-e "s/@CC@/$(tc-getCC)/" \
		-e "s/@AR@/$(tc-getAR)/" \
		-e "s/@RANLIB@/$(tc-getRANLIB)/" \
		"${FILESDIR}"/Makefile.inc.in > src/Makefile.inc || die
}

src_compile() {
	emake -C src PICFLAGS=-fPIC
	make_shared_lib lib/libscotcherr.a
	make_shared_lib lib/libscotcherrexit.a
	make_shared_lib lib/libscotch.a -Llib -lscotcherr -lz -lm -lrt
	make_shared_lib lib/libesmumps.a -Llib -lscotch
	make_shared_lib lib/libscotchmetis.a -Llib -lscotch

	if use mpi; then
		emake -C src PICFLAGS=-fPIC ptscotch
		export LINK=mpicc
		make_shared_lib lib/libptscotcherr.a
		make_shared_lib lib/libptscotcherrexit.a
		make_shared_lib lib/libptscotch.a -Llib -lptscotcherr -lz -lm -lrt
		make_shared_lib lib/libptesmumps.a -Llib -lptscotch
		make_shared_lib lib/libptscotchparmetis.a -Llib -lptscotch
	fi
	if use static-libs; then
		emake -C src clean
		emake -C src
		use mpi && emake -C src ptscotch
	fi
}

src_install() {
	local l
	for l in lib/*.so.*; do
		dolib.so ${l}
		dosym $(basename ${l}) /usr/$(get_libdir)/$(basename ${l%.*})
	done
	use static-libs && dolib.a lib/*.a

	insinto /usr/include/scotch
	doins include/*

	cat <<-EOF > scotchmetis.pc
		prefix=${EPREFIX}/usr
		libdir=\${prefix}/$(get_libdir)
		includedir=\${prefix}/include
		Name: ptscotch
		Description: ${DESCRIPTION}
		Version: ${PV}
		URL: ${HOMEPAGE}
		Libs: -L\${libdir} -lscotchmetis -lscotcherr -lscotch
		Private: -lm -lz -lrt
		Cflags: -I\${includedir}/scotch
	EOF
	insinto /usr/$(get_libdir)/pkgconfig
	doins scotchmetis.pc
	alternatives_for metis scotch 0 \
		"/usr/$(get_libdir)/pkgconfig/metis.pc" "scotchmetis.pc"
	cat <<-EOF > ptscotchmetis.pc
		prefix=${EPREFIX}/usr
		libdir=\${prefix}/$(get_libdir)
		includedir=\${prefix}/include
		Name: ptscotch
		Description: ${DESCRIPTION}
		Version: ${PV}
		URL: ${HOMEPAGE}
		Libs: -L\${libdir} -lptscotchmetis -lptscotcherr -lptscotch
		Private: -lm -lz -lrt
		Cflags: -I\${includedir}/scotch
	EOF
	insinto /usr/$(get_libdir)/pkgconfig
	doins ptscotchmetis.pc
	alternatives_for metis-mpi scotch 0 \
		"/usr/$(get_libdir)/pkgconfig/metis-mpi.pc" "ptscotchmetis.pc"

	dodoc README.txt

	if use tools; then
		local b m
		pushd bin > /dev/null
		for b in *; do
			newbin ${b} scotch_${b}
		done
		popd

		pushd man/man1 > /dev/null
		for m in *; do
			newman ${m} scotch_${m}
		done
		popd > /dev/null
	fi

	use doc && dodoc doc/*.pdf

	if use examples; then
		insinto /usr/share/doc/${PF}/examples
		doins -r examples/* tgt grf
	fi
}