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

EAPI=7

inherit cmake-utils

if [[ ${PV} == *9999* ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/vmc-project/geant4_vmc.git"
else
	DOWN_PV=$(ver_cut 2-)
	SRC_URI="http://root.cern.ch/download/vmc/geant4_vmc.${DOWN_PV}.tar.gz"
	SOURCE_PV=$(ver_rs 1- . ${DOWN_PV})
	S="${WORKDIR}/geant4_vmc.${SOURCE_PV}"
	KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
fi

DESCRIPTION="Virtual Monte Carlo Geant4 implementation"
HOMEPAGE="http://root.cern.ch/root/vmc/VirtualMC.html"

LICENSE="GPL-2"
SLOT="4"
IUSE="doc examples geant3 +g4root +mtroot vgm test"

# sci-physics/root[c++11] required to match sci-physics/geant flags.
RDEPEND="
	>=sci-physics/geant-4.10.03:=[opengl,geant3?]
	sci-physics/root:=[c++11,vmc]
	vgm? ( >=sci-physics/vgm-4.4:= )"
DEPEND="${RDEPEND}
	doc? ( app-doc/doxygen )"
RESTRICT="
	!examples? ( test )
	!geant3? ( test )
	!g4root? ( test )
	!mtroot? ( test )
	!test? ( test )
	!vgm? ( test )"

DOCS=(
	history
	README.md
)
PATCHES=(
	"${FILESDIR}"/"${PN}-${PV}"-fix-cflags.patch
)

src_configure() {
	local mycmakeargs=(
		-DGeant4VMC_USE_VGM="$(usex vgm)"
		-DGeant4VMC_USE_GEANT4_G3TOG4="$(usex geant3)"
		-DGeant4VMC_USE_G4Root="$(usex g4root)"
		-DGeant4VMC_BUILD_MTRoot="$(usex mtroot)"
		-DGeant4VMC_BUILD_EXAMPLES="$(usex test)"
		-DGeant4VMC_INSTALL_EXAMPLES="$(usex examples)"
	)
	cmake-utils_src_configure
}

src_compile() {
	cmake-utils_src_compile
	if use doc ; then
		local dirs=(
			source
			$(usev g4root)
			$(usev mtroot)
			$(usev examples)
		)
		local d
		for d in "${dirs[@]}"; do
			pushd "${d}" > /dev/null || die
			doxygen || die
			popd > /dev/null || die
		done
	fi
}

src_test() {
	# Required by sci-physics/root for pointer validity checking,
	# see e.g. https://sft.its.cern.ch/jira/browse/ROOT-8146 .
	addwrite /dev/random
	cd examples || die
	# Bug: Can not disable Garfield in test suite, fixed upstream.
	sed -i 's/ExGarfield//' test_suite.sh || die
	# Bug: Path for E03 sub-examples wrong, see https://github.com/vmc-project/geant4_vmc/pull/11 .
	sed -i 's#only in E03 test#only in E03 test\nG4EXEDIR=${BUILDDIR}/examples/$EXAMPLE/$OPTION#' test_suite_exe.sh || die
	./test_suite.sh --g3=off --builddir="${BUILD_DIR}" || die
	./test_suite_exe.sh --g3=off --garfield=off --builddir="${BUILD_DIR}" || die
}

src_install() {
	cmake-utils_src_install
	use doc && local HTML_DOCS=(doc/.)
	einstalldocs
}