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