summaryrefslogtreecommitdiff
blob: 2d39b9c8d9d44f18f9b0ebb93234a9751dbff37a (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
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit autotools elisp-common java-pkg-opt-2

MY_P=ThePEG-${PV}

DESCRIPTION="Toolkit for High Energy Physics Event Generation"
HOMEPAGE="
	http://home.thep.lu.se/ThePEG/
	https://thepeg.hepforge.org/
"

TEST_URI="https://www.hepforge.org/archive/lhapdf/pdfsets/current"
SRC_URI="https://www.hepforge.org/archive/thepeg/${MY_P}.tar.bz2
	test? (
		hepmc3? (
			${TEST_URI}/cteq6ll.LHpdf
			${TEST_URI}/cteq5l.LHgrid
			${TEST_URI}/GRV98nlo.LHgrid
			${TEST_URI}/MRST2001nlo.LHgrid )
	)"

LICENSE="GPL-3"
SLOT="0/30"
KEYWORDS="~amd64"
IUSE="emacs fastjet +hepmc3 lhapdf static-libs test zlib rivet"
RESTRICT="!test? ( test )"

CDEPEND="
	sci-libs/gsl:0=
	emacs? ( >=app-editors/emacs-23.1:* )
	fastjet? ( sci-physics/fastjet:0= )
	rivet? ( sci-physics/rivet:3=[hepmc3] )
	hepmc3? ( sci-physics/hepmc:3= )
	lhapdf? ( >=sci-physics/lhapdf-6.0:0= )
	zlib? ( sys-libs/zlib:0= )"
DEPEND="${CDEPEND}
	sci-libs/gsl:=
	java? ( virtual/jdk:1.8 )
	test? (
		sys-process/time
		dev-libs/boost
	)"
RDEPEND="${CDEPEND}
	java? ( virtual/jre:1.8 )
"

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

PATCHES=(
	"${FILESDIR}"/${PN}-1.8.3-java.patch
	"${FILESDIR}"/${PN}-2.0.4-gcc6.patch
	"${FILESDIR}"/${PN}-2.3.0-rivet.patch # properly support rivet/yoda weights in thepeg, reported to upstream by mail.
)

src_prepare() {
	find -name 'Makefile.am' -exec \
		sed -i -e '1ipkgdatadir=$(datadir)/ThePEG' {} \; || die
	# trick to force c++ linking
	sed -i \
		-e '1inodist_EXTRA_libThePEG_la_SOURCES = dummy.cxx' \
		-e '/dist_pkgdata_DATA = ThePEG.el/d' \
		lib/Makefile.am || die
	default
	java-pkg-opt-2_src_prepare
	eautoreconf
}

src_configure() {
	local -x CONFIG_SHELL=/bin/bash
	econf \
		$(use_enable static-libs static) \
		$(use_with fastjet fastjet "${ESYSROOT}"/usr) \
		$(use_with hepmc3 hepmc "${ESYSROOT}"/usr) \
		$(use_with hepmc3 hepmcversion 3) \
		$(use_with java javagui) \
		$(use_with lhapdf lhapdf "${ESYSROOT}"/usr) \
		$(use_with test boost "${ESYSROOT}"/usr) \
		$(use_with rivet rivet "${ESYSROOT}"/usr) \
		$(use_with zlib zlib "${ESYSROOT}"/usr)
}

src_compile() {
	default
	use emacs && elisp-compile lib/ThePEG.el
}

src_test() {
	emake LHAPATH="${DISTDIR}" check
}

src_install() {
	default
	use emacs && elisp-install ${PN} lib/ThePEG.el{,c}
	use java && java-pkg_newjar java/ThePEG.jar

	cat <<-EOF > "${T}"/50${PN} || die
	LDPATH="${EPREFIX}/usr/$(get_libdir)/ThePEG"
	EOF
	doenvd "${T}"/50${PN}

	find "${ED}" -name '*.la' -delete || die
}

pkg_postinst() {
	use emacs && elisp-site-regen
}

pkg_postrm() {
	use emacs && elisp-site-regen
}