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