sys-cluster/glusterfs: version bump, fix #560750 #582732 #592174 #589058
[gentoo.git] / sys-cluster / charm / charm-6.5.1-r2.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 PYTHON_COMPAT=( python2_7 )
8
9 inherit eutils flag-o-matic fortran-2 multilib toolchain-funcs python-single-r1
10
11 DESCRIPTION="Message-passing parallel language and runtime system"
12 HOMEPAGE="http://charm.cs.uiuc.edu/"
13 SRC_URI="http://charm.cs.uiuc.edu/distrib/${P}.tar.gz"
14
15 LICENSE="charm"
16 SLOT="0"
17 KEYWORDS="~amd64 ~x86"
18 IUSE="charmdebug charmtracing charmproduction cmkopt doc examples mlogft mpi numa smp static-libs syncft tcp"
19
20 RDEPEND="mpi? ( virtual/mpi )"
21 DEPEND="
22         ${RDEPEND}
23         doc? (
24                 >=app-text/poppler-0.12.3-r3[utils]
25                 dev-tex/latex2html
26                 virtual/tex-base
27                 >=dev-python/beautifulsoup-4[${PYTHON_USEDEP}]
28                 dev-python/lxml[${PYTHON_USEDEP}]
29                 media-libs/netpbm
30                 ${PYTHON_DEPS}
31         )"
32
33 REQUIRED_USE="
34         doc? ( ${PYTHON_REQUIRED_USE} )
35         cmkopt? ( !charmdebug !charmtracing )
36         charmproduction? ( !charmdebug !charmtracing )"
37
38 FORTRAN_STANDARD="90"
39
40 get_opts() {
41         local CHARM_OPTS
42
43         # TCP instead of default UDP for socket comunication
44         # protocol
45         CHARM_OPTS+="$(usex tcp ' tcp' '')"
46
47         # enable direct SMP support using shared memory
48         CHARM_OPTS+="$(usex smp ' smp' '')"
49
50         CHARM_OPTS+="$(usex mlogft ' mlogft' '')"
51         CHARM_OPTS+="$(usex syncft ' syncft' '')"
52
53         # Build shared libraries by default.
54         CHARM_OPTS+=" --build-shared"
55
56         if use charmproduction; then
57                 CHARM_OPTS+=" --with-production"
58         else
59                 if use charmdebug; then
60                         CHARM_OPTS+=" --enable-charmdebug"
61                 fi
62
63                 if use charmtracing; then
64                         CHARM_OPTS+=" --enable-tracing --enable-tracing-commthread"
65                 fi
66         fi
67
68         CHARM_OPTS+="$(usex numa ' --with-numa' '')"
69         echo $CHARM_OPTS
70 }
71
72 src_prepare() {
73         sed \
74                 -e "/CMK_CF90/s:f90:$(usex mpi "mpif90" "$(tc-getFC)"):g" \
75                 -e "/CMK_CXX/s:g++:$(usex mpi "mpic++" "$(tc-getCXX)"):g" \
76                 -e "/CMK_CC/s:gcc:$(usex mpi "mpicc" "$(tc-getCC)"):g" \
77                 -e '/CMK_F90_MODINC/s:-p:-I:g' \
78                 -e "/CMK_LD/s:\"$: ${LDFLAGS} \":g" \
79                 -i src/arch/$(usex mpi "mpi" "net")-linux*/*sh || die
80
81         sed \
82                 -e "s:-o conv-cpm:${LDFLAGS} &:g" \
83                 -e "s:-o charmxi:${LDFLAGS} &:g" \
84                 -e "s:-o charmrun-silent:${LDFLAGS} &:g" \
85                 -e "s:-o charmrun-notify:${LDFLAGS} &:g" \
86                 -e "s:-o charmrun:${LDFLAGS} &:g" \
87                 -e "s:-o charmd_faceless:${LDFLAGS} &:g" \
88                 -e "s:-o charmd:${LDFLAGS} &:g" \
89                 -i \
90                 src/scripts/Makefile \
91                 src/arch/net/charmrun/Makefile || die
92
93         # CMK optimization
94         use cmkopt && append-cppflags -DCMK_OPTIMIZE=1
95
96         # Fix QA notice. Filed report with upstream.
97         append-cflags -DALLOCA_H
98
99         epatch "${FILESDIR}/charm-6.5.1-cleanup-config.patch"
100         epatch "${FILESDIR}/charm-6.5.1-CkReductionMgr.patch"
101         epatch "${FILESDIR}/charm-6.5.1-fix-string-parsing.patch"
102         epatch "${FILESDIR}/charm-6.5.1-fix-navmenuGenerator.patch"
103         epatch "${FILESDIR}/charm-6.5.1-static-library-fix.patch"
104 }
105
106 src_compile() {
107         local mybuildoptions="$(usex mpi "mpi" "net")-linux$(usex amd64 "-amd64" '') $(get_opts) ${MAKEOPTS} -j1 ${CFLAGS}"
108
109         # Build charmm++ first.
110         einfo "running ./build charm++ ${mybuildoptions}"
111         ./build charm++ ${mybuildoptions} || die "Failed to build charm++"
112
113         # make pdf/html docs
114         if use doc; then
115                 python-single-r1_pkg_setup
116                 python_fix_shebang "${S}/doc"
117                 einfo "forcing ${EPYTHON}"
118                 emake -j1 -C doc/charm++
119         fi
120 }
121
122 src_test() {
123         make -C tests/charm++ test TESTOPTS="++local" || die
124 }
125
126 src_install() {
127         # Make charmc play well with gentoo before we move it into /usr/bin. This
128         # patch cannot be applied during src_prepare() because the charmc wrapper
129         # is used during building.
130         epatch "${FILESDIR}/charm-6.5.1-charmc-gentoo.patch"
131
132         sed -e "s|gentoo-include|${P}|" \
133                 -e "s|gentoo-libdir|$(get_libdir)|g" \
134                 -e "s|VERSION|${P}/VERSION|" \
135                 -i ./src/scripts/charmc || die "failed patching charmc script"
136
137         # In the following, some of the files are symlinks to ../tmp which we need
138         # to dereference first (see bug 432834).
139
140         local i
141
142         # Install binaries.
143         for i in bin/*; do
144                 if [[ -L ${i} ]]; then
145                         i=$(readlink -e "${i}") || die
146                 fi
147                 dobin "${i}"
148         done
149
150         # Install headers.
151         insinto /usr/include/${P}
152         for i in include/*; do
153                 if [[ -L ${i} ]]; then
154                         i=$(readlink -e "${i}") || die
155                 fi
156                 doins "${i}"
157         done
158
159         # Install static libs. Charm has a lot of .o "libs" that it requires at
160         # runtime.
161         if use static-libs; then
162                 for i in lib/*.{a,o}; do
163                         if [[ -L ${i} ]]; then
164                                 i=$(readlink -e "${i}") || die
165                         fi
166                         dolib "${i}"
167                 done
168         fi
169
170         # Install shared libs.
171         for i in lib_so/*; do
172                 if [[ -L ${i} ]]; then
173                         i=$(readlink -e "${i}") || die
174                 fi
175                 dolib.so "${i}"
176         done
177
178         # Basic docs.
179         dodoc CHANGES README
180
181         # Install examples.
182         if use examples; then
183                 find examples/ -name 'Makefile' | xargs sed \
184                         -r "s:(../)+bin/charmc:/usr/bin/charmc:" -i || \
185                         die "Failed to fix examples"
186                 find examples/ -name 'Makefile' | xargs sed \
187                         -r "s:./charmrun:./charmrun ++local:" -i || \
188                         die "Failed to fix examples"
189                 insinto /usr/share/doc/${PF}/examples
190                 doins -r examples/charm++/*
191         fi
192
193         # Install pdf/html docs
194         if use doc; then
195                 cd "${S}/doc/charm++"
196                 # Install pdfs.
197                 insinto /usr/share/doc/${PF}/pdf
198                 doins  *.pdf
199                 # Install html.
200                 docinto html
201                 dohtml -r manual/*
202         fi
203 }
204
205 pkg_postinst() {
206         einfo "Please test your charm installation by copying the"
207         einfo "content of /usr/share/doc/${PF}/examples to a"
208         einfo "temporary location and run 'make test'."
209 }