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