Diff pythia-6.4.28-r2 with a pythia-8.2.45-r2

/usr/portage/sci-physics/pythia/pythia-8.2.45-r2.ebuild 2023-10-09 14:52:35.260368496 +0300
1 1
# Copyright 1999-2023 Gentoo Authors
2 2
# Distributed under the terms of the GNU General Public License v2
3 3

  
4
EAPI=7
4
EAPI=8
5 5

  
6
inherit autotools fortran-2
6
inherit toolchain-funcs
7 7

  
8
MV=$(ver_cut 1)
9
MY_PN=${PN}${MV}
10
DOC_PV=0613
11
EX_PV=6.4.18
12
MY_PV=${PV//./}
13
PYR_P=pythia6-20160413
8
MV=$(ver_cut 1)$(ver_cut 2)
9
MY_P="${PN}${PV//./}"
10
LHA_VER="6.1"
14 11

  
15 12
DESCRIPTION="Lund Monte Carlo high-energy physics event generator"
16
HOMEPAGE="http://pythia6.hepforge.org/"
17

  
18
# pythia6 from root is needed for some files to interface pythia6 with root.
19
# To produce a split version, replace the 6.4.x by the current version:
20
# svn export http://svn.hepforge.org/pythia6/tags/v_6_4_x/ pythia-6.4.x
21
# tar cJf pythia-6.4.x.tar.xz
22

  
23
SRC_URI="
24
	https://pythia.org/download/pythia6/pythia${MY_PV}-split.tgz
25
	https://root.cern.ch/download/pythia6.tar.gz -> ${PYR_P}.tar.gz
26
	doc? ( https://pythia.org/download/pythia6/lutp${DOC_PV}man2.pdf )
27
	examples? ( mirror://gentoo/${PN}-${EX_PV}-examples.tar.bz2 )"
28

  
29
SLOT="6"
30
LICENSE="public-domain"
31
KEYWORDS="amd64 ~x86 ~amd64-linux ~x86-linux"
32
IUSE="doc examples"
33

  
34
PATCHES=( "${FILESDIR}"/${P}-fno-common.patch )
35

  
36
# workaround to official pythia-split not having a pythia subdir
37
src_unpack() {
38
	mkdir -p "${S}" || die
39
	cd "${S}" || die
40
	unpack pythia${MY_PV}-split.tgz
41
	cd "${WORKDIR}" || die
42
	default
13
HOMEPAGE="https://pythia.org/"
14
SRC_URI="https://pythia.org/download/${PN}${MV}/${MY_P}.tgz
15
	test? ( lhapdf? (
16
		https://www.hepforge.org/archive/lhapdf/pdfsets/${LHA_VER}/CT10.tar.gz
17
		https://www.hepforge.org/archive/lhapdf/pdfsets/${LHA_VER}/MRST2007lomod.tar.gz
18
		https://www.hepforge.org/archive/lhapdf/pdfsets/${LHA_VER}/NNPDF23_nlo_as_0119_qed_mc.tar.gz
19
		https://www.hepforge.org/archive/lhapdf/pdfsets/${LHA_VER}/NNPDF23_nnlo_as_0119_qed_mc.tar.gz
20
		https://www.hepforge.org/archive/lhapdf/pdfsets/${LHA_VER}/cteq66.tar.gz
21
		https://www.hepforge.org/archive/lhapdf/pdfsets/${LHA_VER}/cteq6l1.tar.gz
22
		https://www.hepforge.org/archive/lhapdf/pdfsets/${LHA_VER}/unvalidated/MRST2004qed.tar.gz
23
	) )"
24

  
25
SLOT="8"
26
LICENSE="GPL-2"
27
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
28
IUSE="doc examples fastjet +hepmc lhapdf root test zlib"
29
RESTRICT="!test? ( test )"
30

  
31
RDEPEND="
32
	fastjet? ( sci-physics/fastjet )
33
	hepmc? ( sci-physics/hepmc:2= )
34
	lhapdf? ( sci-physics/lhapdf:= )
35
	zlib? ( sys-libs/zlib )"
36
# ROOT is used only when building related tests
37
DEPEND="${RDEPEND}
38
	test? (
39
		root? ( sci-physics/root:= )
40
	)"
41

  
42
PATCHES=(
43
	"${FILESDIR}"/${PN}8209-root-noninteractive.patch
44
)
45

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

  
48
pkg_pretend() {
49
	if use root && ! use test; then
50
		ewarn "ROOT support will only affect examples code build during test stage."
51
		ewarn "Since you have tests disabled, this is a no-op."
52
	fi
43 53
}
44 54

  
45 55
src_prepare() {
46
	cp ../pythia6/tpythia6_called_from_cc.F .
47
	cp ../pythia6/pythia6_common_address.c .
48
	default
49

  
50
	cat > configure.ac <<-EOF || die
51
		AC_INIT(${PN},${PV})
52
		AM_INIT_AUTOMAKE
53
		AC_PROG_F77
54
		LT_INIT
55
		AC_CHECK_LIB(m,sqrt)
56
		AC_CONFIG_FILES(Makefile)
57
		AC_OUTPUT
58
	EOF
59
	echo >> Makefile.am "lib_LTLIBRARIES = libpythia6.la" || die
60
	echo >> Makefile.am "libpythia6_la_SOURCES = \ " || die
61
	# replace wildcard from makefile to ls in shell
62
	local f
63
	for f in py*.f struct*.f up*.f fh*.f; do
64
		echo  >> Makefile.am "  ${f} \\" || die
65
	done
66
	echo  >> Makefile.am "  ssmssm.f sugra.f visaje.f pdfset.f \\" || die
67
	echo  >> Makefile.am "  tpythia6_called_from_cc.F pythia6_common_address.c" || die
56
	PYTHIADIR="/usr/share/pythia8"
57
	EPYTHIADIR="${EPREFIX}${PYTHIADIR}"
68 58

  
69
	eautoreconf
59
	default
60
	# set datadir for xmldor in include file
61
	sed -i \
62
		-e "s|../share/Pythia8/xmldoc|${EPYTHIADIR}/xmldoc|" \
63
		include/Pythia8/Pythia.h || die
64
	# respect libdir, prefix, flags
65
	sed -i \
66
		-e "s|/lib|/$(get_libdir)|g" \
67
		-e "s|/usr|${EPREFIX}/usr|g" \
68
		-e "s|-O2|${CXXFLAGS}|g" \
69
		-e "s|Cint|Core|g" \
70
		configure || die
71
	sed -i 's|$(CXX) $^ -o $@ $(CXX_COMMON) $(CXX_SHARED)|$(CXX) $(LDFLAGS) $^ -o $@ $(CXX_COMMON) $(CXX_SHARED)|g' \
72
		Makefile || die
73
	sed -i 's|$(CXX)|$(CXX) $(LDFLAGS)|' examples/Makefile || die
74
	# we use lhapdf6 instead of lhapdf5
75
	# some PDFs changed, use something similar
76
	sed -i \
77
		-e "s|LHAPDF5|LHAPDF6|g" \
78
		-e "s|\.LHgrid||g" \
79
		-e "s|\.LHpdf||g" \
80
		-e "s|MRST2001lo|MRST2007lomod|g" \
81
		-e "s|cteq6ll|cteq6l1|g" \
82
		-e "s|cteq6m|cteq66|g" \
83
		examples/*.{cc,cmnd} || die
84
	# After lhapdf5->6 migration PDFs are identical within ~1/1000
85
	# https|//www.hepforge.org/archive/lhapdf/pdfsets/6.1/README
86
	sed -i \
87
		-e "s|1e-8|3e-1|g" \
88
		-e "s|nlo_as_0119_qed|nlo_as_0119_qed_mc|g" \
89
		-e "s|xmldoc|share/Pythia8/xmldoc|g" \
90
		examples/main54.cc || die
91
	# ask cflags from root
92
	sed -i "s|root-config|root-config --cflags|g" examples/Makefile || die
93

  
94
	sed -i \
95
		-e '/TARGETS=$(LOCAL_LIB)\/libpythia8\.a/d' \
96
		-e 's|libpythia8\.a$|libpythia8$(LIB_SUFFIX)|g' \
97
		Makefile || die
98
	sed -i 's|libpythia8\.a|libpythia8$(LIB_SUFFIX)|g' \
99
		examples/Makefile || die
70 100
}
71 101

  
102
# TODO: the following optional packages are out of Gentoo tree:
103
# - EvtGen http://atlas-computing.web.cern.ch/atlas-computing/links/externalDirectory/EvtGen/
104
# - PowHEG http://powhegbox.mib.infn.it/
105
# - ProMC  https://github.com/Argonne-National-Laboratory/ProMC/
72 106
src_configure() {
73
	econf --disable-static
107
	# homemade configure script
108
	./configure \
109
		--arch=Linux \
110
		--cxx="$(tc-getCXX)" \
111
		--enable-shared \
112
		--prefix="${EPREFIX}/usr" \
113
		--prefix-lib="$(get_libdir)" \
114
		--prefix-share="${EPYTHIADIR}" \
115
		$(usex fastjet "--with-fastjet3" "") \
116
		$(usex zlib "--with-gzip" "") \
117
		$(usex hepmc "--with-hepmc2" "") \
118
		$(usex lhapdf "--with-lhapdf6
119
			--with-lhapdf6-plugin=LHAPDF6.h
120
			--with-lhapdf6-lib=${EPREFIX}/usr/$(get_libdir)" "") \
121
		$(usex root "--with-root
122
			--with-root-include=${EPREFIX}/usr/include/root
123
			--with-root-lib=${EPREFIX}/usr/$(get_libdir)/root" "") \
124
		|| die
125

  
126
	# fix pythia config script
127
	sed -i \
128
		-e 's|pythia8/examples/Makefile.inc|pythia8/Makefile.inc|' \
129
		-e 's|LINE%=|LINE%%=|' \
130
		bin/pythia8-config || die
131
}
132

  
133
src_test() {
134
	cd examples || die
135

  
136
	local tests="$(echo main{{01..32},37,38,61,62,73,80}.out)"
137
	use hepmc && tests+=" $(echo main{41,42,85,86}.out)"
138
	use hepmc && use lhapdf && tests+=" $(echo main{43,{87..89}}.out)"
139
	use lhapdf && tests+=" $(echo main{51..54}.out)"
140
	use fastjet && tests+=" $(echo main{71,72}.out)"
141
	use fastjet && use hepmc && use lhapdf && tests+=" $(echo main{81..84}).out"
142
	use root && tests+=" main91.out"
143
	# Disabled tests:
144
	# 33	needs PowHEG
145
	# 46	needs ProMC
146
	# 48	needs EvtGen
147
	# 92	generated ROOT dictionary is badly broken
148

  
149
	# use emake for parallel instead of long runmains
150
	LD_LIBRARY_PATH="${S}/$(get_libdir):${LD_LIBRARY_PATH}" \
151
	PYTHIA8DATA="../share/Pythia8/xmldoc/" \
152
	LHAPDF_DATA_PATH="${WORKDIR}" \
153
	emake ${tests}
154
	emake clean
74 155
}
75 156

  
76 157
src_install() {
77
	default
78
	dodoc update_notes.txt
79
	use doc && dodoc "${DISTDIR}"/lutp${DOC_PV}man2.pdf
158
	# make install is too broken, much easier to install manually
159
	dobin bin/pythia8-config
160
	doheader -r include/*
161
	dolib.so lib/libpythia8.so
162
	use lhapdf && dolib.so lib/libpythia8lhapdf6.so
163
	insinto "${PYTHIADIR}"
164
	doins -r share/Pythia8/xmldoc examples/Makefile.inc
165

  
166
	newenvd - 99pythia8 <<- _EOF_
167
		PYTHIA8DATA=${EPYTHIADIR}/xmldoc
168
	_EOF_
169

  
170
	dodoc AUTHORS GUIDELINES README
171
	if use doc; then
172
		dodoc -r share/Pythia8/pdfdoc/.
173
		dodoc -r share/Pythia8/htmldoc/.
174
	fi
80 175
	if use examples; then
81
		dodoc -r "${WORKDIR}"/examples
176
		# reuse system Makefile.inc
177
		rm examples/Makefile.inc || die
178
		sed -i "s|include Makefile.inc|include ${EPYTHIADIR}|" \
179
			examples/Makefile || die
180

  
181
		insinto /usr/share/${PN}
182
		doins -r examples
82 183
		docompress -x /usr/share/doc/${PF}/examples
83 184
	fi
84 185

  
85
	find "${ED}" -name '*.la' -delete || die
186
	# cleanup
187
	unset PYTHIADIR EPYTHIADIR
86 188
}
Thank you!