sys-kernel/gentoo-sources: Cleanup of 4.14.X series
[gentoo.git] / sci-libs / mathgl / mathgl-2.4.1.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 )
7 WX_GTK_VER=3.0
8
9 inherit cmake-utils eutils python-single-r1 wxwidgets multilib flag-o-matic
10
11 DESCRIPTION="Math Graphics Library"
12 HOMEPAGE="http://mathgl.sourceforge.net/"
13 SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz mirror://sourceforge/${PN}/STIX_font.tgz"
14
15 LICENSE="LGPL-3"
16 SLOT="0/7.5.0"
17 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
18 IUSE="doc fltk gif glut gsl hdf hdf5 jpeg lua mpi octave opengl openmp pdf
19         png python qt5 static-libs threads wxwidgets zlib"
20
21 LANGS="ru"
22 for l in ${LANGS}; do
23         IUSE+=" l10n_${l}"
24 done
25 unset l
26
27 RDEPEND="
28         virtual/opengl
29         fltk? ( x11-libs/fltk:1 )
30         gif? ( media-libs/giflib )
31         glut? ( media-libs/freeglut )
32         gsl? ( >=sci-libs/gsl-2 )
33         hdf? ( sci-libs/hdf )
34         hdf5? ( >=sci-libs/hdf5-1.8[mpi=] )
35         jpeg? ( virtual/jpeg:0 )
36         lua? ( >=dev-lang/lua-5.1:0 )
37         octave? ( >=sci-mathematics/octave-3.4.0 )
38         openmp? ( sys-cluster/openmpi )
39         pdf? ( media-libs/libharu )
40         png? ( media-libs/libpng:0 )
41         python? ( dev-python/numpy[${PYTHON_USEDEP}] ${PYTHON_DEPS} )
42         qt5? (
43                 dev-qt/qtcore:5
44                 dev-qt/qtgui:5
45                 dev-qt/qtprintsupport:5
46                 dev-qt/qtwidgets:5
47         )
48         wxwidgets? ( x11-libs/wxGTK:${WX_GTK_VER}[X] )
49         zlib? ( sys-libs/zlib )"
50
51 DEPEND="${RDEPEND}
52         doc? ( app-text/texi2html virtual/texi2dvi )
53         octave? ( dev-lang/swig )
54         python? ( dev-lang/swig )"
55
56 REQUIRED_USE="
57         mpi? ( hdf5 )
58         openmp? ( !threads )
59         png? ( zlib )
60         pdf? ( png )
61         python? ( ${PYTHON_REQUIRED_USE} )"
62
63 PATCHES=(
64         "${FILESDIR}"/${P}-mutex.patch
65 )
66
67 pkg_setup() {
68         use mpi && export CC=mpicc CXX=mpicxx
69         use python && python-single-r1_pkg_setup
70 }
71
72 src_unpack() {
73         default
74         if ! [[ -d "${S}"/fonts ]]; then
75                 mkdir "${S}"/fonts || die
76         fi
77         cd "${S}"/fonts || die
78         unpack STIX_font.tgz
79 }
80
81 src_prepare() {
82         # fix for location of hdf headers
83         sed -i -e 's:hdf/::g' src/data_io.cpp || die
84         # bored of reporting bad libdir upstream
85         sed -i \
86                 -e '/DESTINATION/s:lib$:lib${LIB_SUFFIX}:g' \
87                 {src,widgets}/CMakeLists.txt || die
88         echo "" > lang/install.m || die
89         # fix desktop file
90         sed -i -e 's/.png//' udav/udav.desktop || die
91         # prevent sandbox violation
92         sed -i -e 's/update-mime-database/true/' udav/CMakeLists.txt || die
93         sed -i -e 's/update-desktop-database/true/' udav/CMakeLists.txt || die
94
95         use python && \
96                 append-cppflags \
97                 -I"$(${EPYTHON} -c 'import numpy; print(numpy.get_include())')"
98         use wxwidgets && need-wxwidgets unicode
99         cmake-utils_src_prepare
100 }
101
102 src_configure() {
103         local mycmakeargs=()
104         if use hdf; then
105                 mycmakeargs+=(
106                         -DHDF4_INCLUDE_DIR="${EPREFIX}/usr/include"
107                 )
108         fi
109         mycmakeargs+=(
110                 # No clue about this option:
111                 # option(enable-mgl2 "Use names 'libmgl2-*' instead of 'libmgl-*'")
112                 -DMathGL_INSTALL_LIB_DIR="${EPREFIX}/usr/$(get_libdir)"
113                 -Denable-all-docs=$(usex doc)
114                 -Denable-fltk=$(usex fltk)
115                 -Denable-gif=$(usex gif)
116                 -Denable-glut=$(usex glut)
117                 -Denable-gsl=$(usex gsl)
118                 -Denable-hdf4=$(usex hdf)
119                 -Denable-hdf5=$(usex hdf5)
120                 -Denable-jpeg=$(usex jpeg)
121                 -Denable-lua=$(usex lua)
122                 -Denable-mpi=$(usex mpi)
123                 -Denable-octave=$(usex octave)
124                 -Denable-opengl=$(usex opengl)
125                 -Denable-openmp=$(usex openmp)
126                 -Denable-pdf=$(usex pdf)
127                 -Denable-png=$(usex png)
128                 -Denable-qt4=OFF
129                 -Denable-qt5=$(usex qt5)
130                 -Denable-qt5asqt=$(usex qt5)
131                 -Denable-pthread=$(usex threads)
132                 -Denable-pthr-widget=$(usex threads)
133                 -Denable-python=$(usex python)
134                 -Denable-wx=$(usex wxwidgets)
135                 -Denable-zlib=$(usex zlib)
136         )
137         cmake-utils_src_configure
138         # to whoever cares: TODO: do for multiple python ABI
139         if use python; then
140                 sed -i \
141                         -e "s:--prefix=\(.*\) :--prefix=\$ENV{DESTDIR}\1 :" \
142                         "${CMAKE_BUILD_DIR}"/lang/cmake_install.cmake || die
143         fi
144 }
145
146 src_install() {
147         cmake-utils_src_install
148         dodoc README* *.txt AUTHORS
149         if ! use static-libs; then
150                 rm "${ED}"/usr/$(get_libdir)/*.a || die
151         fi
152         if use qt5 ; then
153                 local lang
154                 insinto /usr/share/udav
155                 for lang in ${LANGS} ; do
156                         use l10n_${lang} && doins udav/udav_${lang}.qm
157                 done
158         fi
159         if use octave ; then
160                 insinto /usr/share/${PN}/octave
161                 doins "${CMAKE_BUILD_DIR}"/lang/${PN}.tar.gz
162         fi
163         use python && python_optimize
164 }
165
166 pkg_postinst() {
167         if use octave; then
168                 octave <<-EOF
169                 pkg install ${EROOT}/usr/share/${PN}/octave/${PN}.tar.gz
170                 EOF
171         fi
172 }
173
174 pkg_prerm() {
175         if use octave; then
176                 octave <<-EOF
177                 pkg uninstall ${PN}
178                 EOF
179         fi
180 }