dev-vcs/hg-git-0.9.0_rc1: version bump with mercurial 5.4 support
[gentoo.git] / sci-physics / root / root-9999.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 # ninja does not work due to fortran
7 CMAKE_MAKEFILE_GENERATOR=emake
8 FORTRAN_NEEDED="fortran"
9 PYTHON_COMPAT=( python2_7 python3_{6,7,8} )
10
11 inherit cmake-utils cuda eapi7-ver elisp-common eutils fortran-2 \
12         prefix python-single-r1 toolchain-funcs
13
14 DESCRIPTION="C++ data analysis framework and interpreter from CERN"
15 HOMEPAGE="https://root.cern"
16
17 IUSE="+X aqua +asimage +c++11 c++14 c++17 cuda cudnn +davix debug emacs
18         +examples fits fftw fortran +gdml graphviz +gsl http libcxx +minuit
19         mpi mysql odbc +opengl oracle postgres prefix pythia6 pythia8 +python
20         qt5 R +roofit root7 shadow sqlite +ssl +tbb test +tmva +unuran vc
21         vmc +xml xrootd"
22 RESTRICT="!test? ( test )"
23
24 if [[ ${PV} =~ "9999" ]] ; then
25         inherit git-r3
26         KEYWORDS=""
27         EGIT_REPO_URI="http://root.cern/git/root.git"
28         if [[ ${PV} == "9999" ]]; then
29                 SLOT="0"
30         else
31                 SLOT="$(ver_cut 1-2)/$(ver_cut 3)"
32                 EGIT_BRANCH="v$(ver_cut 1)-$(ver_cut 2)-00-patches"
33         fi
34 else
35         KEYWORDS="~amd64 ~x86"
36         SRC_URI="https://root.cern/download/${PN}_v${PV}.source.tar.gz"
37 fi
38
39 LICENSE="LGPL-2.1 freedist MSttfEULA LGPL-3 libpng UoI-NCSA"
40
41 REQUIRED_USE="
42         ^^ ( c++11 c++14 c++17 )
43         cuda? ( tmva !c++17 )
44         cudnn? ( cuda )
45         !X? ( !asimage !opengl !qt5 )
46         davix? ( ssl xml )
47         python? ( ${PYTHON_REQUIRED_USE} )
48         qt5? ( root7 )
49         root7? ( || ( c++14 c++17 ) )
50         tmva? ( gsl )
51 "
52
53 CDEPEND="
54         app-arch/lz4
55         app-arch/zstd
56         app-arch/xz-utils
57         fortran? ( dev-lang/cfortran )
58         dev-libs/libpcre:3
59         dev-libs/xxhash
60         media-fonts/dejavu
61         media-libs/freetype:2
62         media-libs/libpng:0=
63         sys-libs/ncurses:=
64         sys-libs/zlib
65         X? (
66                 x11-libs/libX11:0
67                 x11-libs/libXext:0
68                 x11-libs/libXft:0
69                 x11-libs/libXpm:0
70                 opengl? (
71                         media-libs/ftgl:0=
72                         media-libs/glew:0=
73                         virtual/opengl
74                         virtual/glu
75                         x11-libs/gl2ps:0=
76                 )
77                 qt5? (
78                         dev-qt/qtcore:5
79                         dev-qt/qtgui:5
80                         dev-qt/qtwebengine:5[widgets]
81                 )
82         )
83         asimage? ( media-libs/libafterimage[gif,jpeg,png,tiff] )
84         cuda? ( >=dev-util/nvidia-cuda-toolkit-9.0 )
85         cudnn? ( dev-libs/cudnn )
86         davix? ( net-libs/davix )
87         emacs? ( >=app-editors/emacs-23.1:* )
88         fftw? ( sci-libs/fftw:3.0= )
89         fits? ( sci-libs/cfitsio:0= )
90         graphviz? ( media-gfx/graphviz )
91         gsl? ( sci-libs/gsl:= )
92         http? ( dev-libs/fcgi:0= )
93         libcxx? ( sys-libs/libcxx )
94         unuran? ( sci-mathematics/unuran:0= )
95         minuit? ( !sci-libs/minuit )
96         mpi? ( virtual/mpi )
97         mysql? ( dev-db/mysql-connector-c )
98         odbc? ( || ( dev-db/libiodbc dev-db/unixODBC ) )
99         oracle? ( dev-db/oracle-instantclient-basic )
100         postgres? ( dev-db/postgresql:= )
101         pythia6? ( sci-physics/pythia:6 )
102         pythia8? ( sci-physics/pythia:8 )
103         python? ( ${PYTHON_DEPS} )
104         R? ( dev-lang/R )
105         shadow? ( sys-apps/shadow )
106         sqlite? ( dev-db/sqlite:3 )
107         ssl? ( dev-libs/openssl:0= )
108         tbb? ( >=dev-cpp/tbb-2018 )
109         tmva? (
110                 $(python_gen_cond_dep '
111                         dev-python/numpy[${PYTHON_MULTI_USEDEP}]
112                 ')
113         )
114         vc? ( dev-libs/vc:= )
115         xml? ( dev-libs/libxml2:2= )
116         xrootd? ( net-libs/xrootd:0= )
117 "
118
119 DEPEND="${CDEPEND}
120         virtual/pkgconfig"
121
122 RDEPEND="${CDEPEND}"
123
124 PATCHES=(
125         "${FILESDIR}"/${PN}-6.12.06_cling-runtime-sysroot.patch
126 )
127
128 pkg_setup() {
129         use fortran && fortran-2_pkg_setup
130         use python && python-single-r1_pkg_setup
131
132         elog "There are extra options on packages not available in Gentoo."
133         elog "You can use the environment variable EXTRA_ECONF to enable"
134         elog "these packages. For example, for Vdt you would set:"
135         elog "EXTRA_ECONF=\"-Dbuiltin_vdt=ON -Dvdt=ON\""
136 }
137
138 src_prepare() {
139         use cuda && cuda_src_prepare
140
141         cmake-utils_src_prepare
142
143         sed -i "/CLING_BUILD_PLUGINS/d" interpreter/CMakeLists.txt || die
144
145         # CSS should use local images
146         sed -i -e 's,http://.*/,,' etc/html/ROOT.css || die "html sed failed"
147 }
148
149 # Note: ROOT uses bundled clang because it is patched and API-incompatible
150 #       with vanilla clang. The patches enable the C++ interpreter to work.
151 #       Since ROOT installs many files into /etc (>100MB in total) that don't
152 #       really belong there, we install it into another directory to avoid
153 #       making /etc too big.
154
155 src_configure() {
156         local mycmakeargs=(
157                 -DCMAKE_C_COMPILER=$(tc-getCC)
158                 -DCMAKE_CXX_COMPILER=$(tc-getCXX)
159                 -DCMAKE_CUDA_HOST_COMPILER=$(tc-getCXX)
160                 -DCMAKE_C_FLAGS="${CFLAGS}"
161                 -DCMAKE_CXX_FLAGS="${CXXFLAGS}"
162                 -DCMAKE_CXX_STANDARD=$((usev c++11 || usev c++14 || usev c++17) | cut -c4-)
163                 -DPYTHON_EXECUTABLE="${EPREFIX}/usr/bin/${EPYTHON}"
164                 -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/${PN}/$(ver_cut 1-2)"
165                 -DCMAKE_INSTALL_MANDIR="${EPREFIX}/usr/lib/${PN}/$(ver_cut 1-2)/share/man"
166                 -DCMAKE_INSTALL_LIBDIR="lib"
167                 -DDEFAULT_SYSROOT="${EPREFIX}"
168                 -DCLING_BUILD_PLUGINS=OFF
169                 -Dexplicitlink=ON
170                 -Dexceptions=ON
171                 -Dfail-on-missing=ON
172                 -Dgnuinstall=OFF
173                 -Dshared=ON
174                 -Dsoversion=ON
175                 -Dbuiltin_llvm=ON
176                 -Dbuiltin_clang=ON
177                 -Dbuiltin_afterimage=OFF
178                 -Dbuiltin_cfitsio=OFF
179                 -Dbuiltin_davix=OFF
180                 -Dbuiltin_fftw3=OFF
181                 -Dbuiltin_freetype=OFF
182                 -Dbuiltin_ftgl=OFF
183                 -Dbuiltin_gl2ps=OFF
184                 -Dbuiltin_glew=OFF
185                 -Dbuiltin_gsl=OFF
186                 -Dbuiltin_lz4=OFF
187                 -Dbuiltin_lzma=OFF
188                 -Dbuiltin_openssl=OFF
189                 -Dbuiltin_pcre=OFF
190                 -Dbuiltin_tbb=OFF
191                 -Dbuiltin_unuran=OFF
192                 -Dbuiltin_vc=OFF
193                 -Dbuiltin_vdt=OFF
194                 -Dbuiltin_veccore=OFF
195                 -Dbuiltin_xrootd=OFF
196                 -Dbuiltin_xxhash=OFF
197                 -Dbuiltin_zlib=OFF
198                 -Dbuiltin_zstd=OFF
199                 -Dx11=$(usex X)
200                 -Dalien=OFF
201                 -Darrow=OFF
202                 -Dasimage=$(usex asimage)
203                 -Dlibcxx=$(usex libcxx)
204                 -Dccache=OFF # use ccache via portage
205                 -Dcefweb=OFF
206                 -Dclad=OFF
207                 -Dcocoa=$(usex aqua)
208                 -Dcuda=$(usex cuda)
209                 -Dcudnn=$(usex cudnn)
210                 -Dcxxmodules=OFF # requires clang, unstable
211                 -Ddavix=$(usex davix)
212                 -Ddataframe=ON
213                 -Ddcache=OFF
214                 -Dfcgi=$(usex http)
215                 -Dfftw3=$(usex fftw)
216                 -Dfitsio=$(usex fits)
217                 -Dfortran=$(usex fortran)
218                 -Dftgl=$(usex opengl)
219                 -Dgdml=$(usex gdml)
220                 -Dgfal=OFF
221                 -Dgl2ps=$(usex opengl)
222                 -Dgminimal=OFF
223                 -Dgsl_shared=$(usex gsl)
224                 -Dgviz=$(usex graphviz)
225                 -Dhttp=$(usex http)
226                 -Dimt=$(usex tbb)
227                 -Dmathmore=$(usex gsl)
228                 -Dmemstat=OFF # deprecated
229                 -Dminimal=OFF
230                 -Dminuit2=$(usex minuit)
231                 -Dminuit=$(usex minuit)
232                 -Dmlp=$(usex tmva)
233                 -Dmonalisa=OFF
234                 -Dmpi=$(usex mpi)
235                 -Dmysql=$(usex mysql)
236                 -Dodbc=$(usex odbc)
237                 -Dopengl=$(usex opengl)
238                 -Doracle=$(usex oracle)
239                 -Dpgsql=$(usex postgres)
240                 -Dpythia6=$(usex pythia6)
241                 -Dpythia8=$(usex pythia8)
242                 -Dpyroot=$(usex python) # python was renamed to pyroot
243                 -Dpython=$(usex python) # kept for backward compatibility
244                 -Dpyroot_experimental=OFF # use standard PyROOT for now
245                 -Dqt5web=$(usex qt5)
246                 -Droofit=$(usex roofit)
247                 -Droot7=$(usex root7)
248                 -Drootbench=OFF
249                 -Droottest=OFF
250                 -Drpath=OFF
251                 -Druntime_cxxmodules=OFF # does not work yet
252                 -Dr=$(usex R)
253                 -Dshadowpw=$(usex shadow)
254                 -Dsqlite=$(usex sqlite)
255                 -Dssl=$(usex ssl)
256                 -Dtcmalloc=OFF
257                 -Dtesting=$(usex test)
258                 -Dtmva=$(usex tmva)
259                 -Dtmva-cpu=$(usex tmva)
260                 -Dtmva-gpu=$(usex cuda)
261                 -Dunuran=$(usex unuran)
262                 -Dvc=$(usex vc)
263                 -Dvmc=$(usex vmc)
264                 -Dvdt=OFF
265                 -Dveccore=OFF
266                 -Dxml=$(usex xml)
267                 -Dxrootd=$(usex xrootd)
268                 ${EXTRA_ECONF}
269         )
270
271         CMAKE_BUILD_TYPE=$(usex debug Debug Release) \
272         cmake-utils_src_configure
273 }
274
275 src_compile() {
276         # needed for hsimple.root
277         addwrite /dev/random
278         cmake-utils_src_compile
279 }
280
281 src_install() {
282         cmake-utils_src_install
283
284         ROOTSYS=${EPREFIX}/usr/lib/${PN}/$(ver_cut 1-2)
285
286         if [[ ${PV} == "9999" ]]; then
287                 ROOTENV="9900${PN}-git"
288         else
289                 ROOTENV="$((9999 - $(ver_cut 2)))${PN}-$(ver_cut 1-2)-git"
290         fi
291
292         cat > ${ROOTENV} <<- EOF || die
293         MANPATH="${ROOTSYS}/share/man"
294         PATH="${ROOTSYS}/bin"
295         ROOTPATH="${ROOTSYS}/bin"
296         LDPATH="${ROOTSYS}/lib"
297         EOF
298
299         if use python; then
300                 echo "PYTHONPATH=\"${ROOTSYS}/lib\"" >> ${ROOTENV} || die
301         fi
302
303         doenvd ${ROOTENV}
304
305         if use emacs; then
306                 elisp-install ${PN}-$(ver_cut 1-2) "${BUILD_DIR}"/root-help.el
307         fi
308
309         pushd "${D}/${ROOTSYS}" > /dev/null
310
311         rm -r emacs bin/*.{csh,sh,fish} || die
312
313         if ! use examples; then
314                 rm -r tutorials || die
315         fi
316
317         # create versioned symlinks for binaries
318         if [[ ! ${PV} == "9999" ]]; then
319                 cd bin;
320                 for exe in *; do
321                         dosym "${exe}" "/usr/lib/${PN}/$(ver_cut 1-2)/bin/${exe}-$(ver_cut 1-2)"
322                 done
323         fi
324 }