sci-physics/clhep: x86 stable wrt bug #556782
[gentoo.git] / sci-physics / pythia / pythia-8.1.86-r1.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 inherit eutils versionator toolchain-funcs multilib
8
9 MV=$(get_major_version)
10 MY_P=${PN}$(replace_all_version_separators "" ${PV})
11
12 DESCRIPTION="Lund Monte Carlo high-energy physics event generator"
13 HOMEPAGE="http://pythia8.hepforge.org/"
14 SRC_URI="http://home.thep.lu.se/~torbjorn/${PN}${MV}/${MY_P}.tgz"
15
16 SLOT="8"
17 LICENSE="GPL-2"
18 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
19 IUSE="doc examples gzip +hepmc static-libs"
20
21 DEPEND="
22         gzip? ( dev-libs/boost sys-libs/zlib )
23         hepmc? ( sci-physics/hepmc:0= )"
24 RDEPEND="${DEPEND}"
25
26 S="${WORKDIR}/${MY_P}"
27
28 src_prepare() {
29         PYTHIADIR="${EPREFIX}/usr/share/pythia8"
30         # set datadir for xmldor in include file
31         sed -i \
32                 -e "s:../xmldoc:${PYTHIADIR}/xmldoc:" \
33                 include/Pythia8/Pythia.h || die
34         # respect libdir, prefix, flags
35         sed -i \
36                 -e "s:/lib:/$(get_libdir):g" \
37                 -e "s:/usr:${EPREFIX}/usr:g" \
38                 -e "s:-O2::g" \
39                 configure || die
40         sed -i \
41                 -e "s:LIBDIR=.*:LIBDIR=$(get_libdir):" \
42                 -e "s:LIBDIRARCH=.*:LIBDIRARCH=$(get_libdir):" \
43                 -e "s:cp -r lib:cp -r $(get_libdir):" \
44                 -e '/ln -fs/d' \
45                 Makefile examples/Makefile || die
46 }
47
48 src_configure() {
49         export USRCXXFLAGS="${CXXFLAGS}"
50         export USRLDFLAGSSHARED="${LDFLAGS}"
51         tc-export CC CXX
52         # homemade configure script
53         ./configure \
54                 --installdir="${EPREFIX}/usr" \
55                 --datadir="${PYTHIADIR}" \
56                 --enable-shared \
57                 $(usex gzip "--enable-gzip=yes" "") \
58                 $(usex hepmc "--with-hepmcversion=2 --with-hepmc=${EPREFIX}/usr" "") \
59                 || die
60         if ! use static-libs; then
61                 sed -i \
62                         -e '/targets.*=$(LIBDIR.*\.a$/d' \
63                         -e 's/+=\(.*libpythia8\.\)/=\1/' \
64                         Makefile || die
65                 sed -i \
66                         -e 's:\.a:\.so:g' \
67                         -e 's:$(LIBDIRARCH):$(LIBDIR):g' \
68                         examples/Makefile || die
69         fi
70 }
71
72 src_test() {
73         cd examples || die
74         # use emake for parallel instead of long runmains
75         local tests="$(echo main0{1..8})" t
76         use hepmc && tests="${tests} main31"
77         emake ${tests}
78         for t in ${tests}; do
79                 LD_LIBRARY_PATH="${S}/$(get_libdir):${LD_LIBRARY_PATH}" \
80                         bin/${t}.exe > ${t}.out || die "test ${t} failed"
81         done
82         emake clean && rm main*out
83 }
84
85 src_install() {
86         emake INSTALLDIR="${ED}/usr" DATADIR="${D}/${PYTHIADIR}" install
87         rm -r "${D}"/${PYTHIADIR}/{html,php}doc || die
88         echo "PYTHIA8DATA=${PYTHIADIR}/xmldoc" >> 99pythia8
89         doenvd 99pythia8
90
91         dodoc GUIDELINES AUTHORS README
92         if use doc; then
93                 dodoc worksheet.pdf htmldoc/pythia8100.pdf
94                 dohtml -r htmldoc/*
95         fi
96         if use examples; then
97                 insinto /usr/share/doc/${PF}
98                 doins -r examples rootexamples
99                 docompress -x /usr/share/doc/${PF}/{root,}examples
100         fi
101 }