app-editors/kakoune: drop old 0_pre20160620
[gentoo.git] / sci-libs / plplot / plplot-5.12.0-r1.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 WX_GTK_VER=3.0-gtk3
7 FORTRAN_NEEDED=fortran
8 FORTRAN_STANDARD=95
9 PYTHON_COMPAT=( python2_7 )
10
11 inherit cmake-utils flag-o-matic fortran-2 java-pkg-opt-2 python-single-r1 toolchain-funcs virtualx wxwidgets
12
13 DESCRIPTION="Multi-language scientific plotting library"
14 HOMEPAGE="http://plplot.sourceforge.net/"
15 SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
16
17 LICENSE="LGPL-2"
18 SLOT="0/14" # SONAME of libplplot.so
19 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
20 IUSE="cairo cxx doc +dynamic examples fortran gd java jpeg latex lua ocaml octave pdf
21         pdl png python qhull qt5 shapefile svg tcl test threads tk truetype wxwidgets X"
22 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} ) qt5? ( dynamic ) test? ( latex ) tk? ( tcl )"
23 RESTRICT="octave? ( test )"
24
25 RDEPEND="
26         cairo? ( x11-libs/cairo:0=[svg?,X] )
27         gd? ( media-libs/gd:2=[jpeg?,png?] )
28         java? ( >=virtual/jre-1.5:* )
29         latex? (
30                 app-text/ghostscript-gpl
31                 virtual/latex-base
32         )
33         lua? ( dev-lang/lua:0= )
34         ocaml? (
35                 dev-lang/ocaml
36                 dev-ml/camlidl
37                 cairo? ( dev-ml/cairo-ocaml[gtk] )
38         )
39         octave? ( sci-mathematics/octave:0= )
40         pdf? ( media-libs/libharu:0= )
41         pdl? (
42                 dev-perl/PDL
43                 dev-perl/XML-DOM
44         )
45         python? (
46                 ${PYTHON_DEPS}
47                 dev-python/numpy[${PYTHON_USEDEP}]
48                 qt5? ( dev-python/PyQt5[${PYTHON_USEDEP}] )
49         )
50         qhull? ( media-libs/qhull:0= )
51         qt5? (
52                 dev-qt/qtgui:5
53                 dev-qt/qtsvg:5
54                 dev-qt/qtprintsupport:5
55         )
56         shapefile? ( sci-libs/shapelib:0= )
57         tcl? (
58                 dev-lang/tcl:0=
59                 dev-tcltk/itcl:0=
60                 tk? (
61                         dev-lang/tk:0=
62                         dev-tcltk/itk
63                 )
64         )
65         truetype? (
66                 media-fonts/freefont
67                 media-libs/lasi:0=
68                 gd? ( media-libs/gd:2=[truetype] )
69         )
70         wxwidgets? (
71                 x11-libs/wxGTK:${WX_GTK_VER}=[X]
72                 x11-libs/agg:0=[truetype?]
73         )
74         X? (
75                 x11-libs/libX11:0=
76                 x11-libs/libXau:0=
77                 x11-libs/libXdmcp:0=
78         )"
79
80 DEPEND="${RDEPEND}
81         virtual/pkgconfig
82         java? (
83                 >=virtual/jdk-1.5
84                 dev-lang/swig
85         )
86         ocaml? ( dev-ml/findlib )
87         octave? ( >=dev-lang/swig-3.0.12 )
88         python? ( dev-lang/swig )
89         test? (
90                 media-fonts/font-misc-misc
91                 media-fonts/font-cursor-misc
92         )"
93
94 PATCHES=(
95         "${FILESDIR}"/${PN}-5.9.6-python.patch
96         "${FILESDIR}"/${PN}-5.11.0-octave.patch
97         "${FILESDIR}"/${PN}-5.12.0-multiarch.patch
98         "${FILESDIR}"/${PN}-5.12.0-java-install-path.patch
99         "${FILESDIR}"/${PN}-5.12.0-ocaml-remove-rpath.patch
100 )
101
102 pkg_setup() {
103         use python && python-single-r1_pkg_setup
104         use java && java-pkg-opt-2_pkg_setup
105         use fortran && fortran-2_pkg_setup
106 }
107
108 src_prepare() {
109         use wxwidgets && need-wxwidgets unicode
110         cmake-utils_src_prepare
111
112         # avoid installing license
113         sed -i -e '/COPYING.LIB/d' CMakeLists.txt || die
114
115         # prexify hard-coded /usr/include in cmake modules
116         sed -i \
117                 -e "s:/usr/include:${EPREFIX}/usr/include:g" \
118                 -e "s:/usr/lib:${EPREFIX}/usr/$(get_libdir):g" \
119                 -e "s:/usr/share:${EPREFIX}/usr/share:g" \
120                 cmake/modules/*.cmake || die
121
122         # change default install directories for doc and examples
123         local f
124         while IFS="" read -d $'\0' -r f; do
125                 sed -i -e 's:${DATA_DIR}/examples:${DOC_DIR}/examples:g' "${f}" || die
126         done < <(find "${S}" -name CMakeLists.txt -print0)
127
128         sed -i \
129                 -e 's:${VERSION}::g' \
130                 -e "s:doc/\${PACKAGE}:doc/${PF}:" \
131                 cmake/modules/instdirs.cmake || die
132
133         java-utils-2_src_prepare
134 }
135
136 src_configure() {
137         # - don't build doc, it pulls in a whole stack of horrible dependencies
138         # - Bindings:
139         #   * Ada is a mess in Gentoo, don't use
140         #   * D has been removed from Gentoo, don't use
141         #   * Qt4 has been disabled, as it is deprecated and unsupported upstream
142         # - DPLD_* drivers need to use ON/OFF instead of the usex defaults yes/no, as
143         #   the testsuite performs a string comparison to determine which tests to run
144
145         # Octave bindings now require C++11 support, #609980
146         append-cxxflags -std=c++11
147
148         local mycmakeargs=(
149                 # The build system does not honour CMAKE_INSTALL_LIBDIR as a
150                 # relative dir, which is against the spirit of GNUInstallDirs, #610066
151                 -DCMAKE_INSTALL_LIBDIR="${EPREFIX}"/usr/$(get_libdir)
152
153                 ## Features
154                 -DBUILD_DOC=OFF
155                 -DBUILD_DOX_DOC=OFF
156                 -DCMAKE_SKIP_RPATH=ON
157                 -DPREBUILT_DOC=$(usex doc)
158                 -DHAVE_SHAPELIB=$(usex shapefile)
159                 -DWITH_FREETYPE=$(usex truetype)
160                 -DPL_HAVE_PTHREAD=$(usex threads)
161                 -DPL_HAVE_QHULL=$(usex qhull)
162                 -DPLPLOT_USE_QT5=$(usex qt5)
163
164                 ## Tests
165                 -DTEST_DYNDRIVERS=OFF
166                 -DBUILD_TEST=$(usex test)
167
168                 ## Bindings
169                 -DENABLE_ada=OFF
170                 -DENABLE_d=OFF
171                 -DENABLE_ocaml=$(usex ocaml)
172                 -DENABLE_pyqt4=OFF
173                 -DENABLE_cxx=$(usex cxx)
174                 -DENABLE_DYNDRIVERS=$(usex dynamic)
175                 -DENABLE_f95=$(usex fortran)
176                 -DENABLE_java=$(usex java)
177                 -DENABLE_lua=$(usex lua)
178                 -DTRY_OCTAVE4=$(usex octave)
179                 -DENABLE_octave=$(usex octave)
180                 -DENABLE_pdl=$(usex pdl)
181                 -DENABLE_python=$(usex python)
182                 -DENABLE_qt=$(usex qt5)
183                 -DENABLE_tcl=$(usex tcl)
184                 -DENABLE_itcl=$(usex tcl)
185                 -DENABLE_tk=$(usex tk)
186                 -DENABLE_itk=$(usex tk)
187                 -DENABLE_wxwidgets=$(usex wxwidgets)
188
189                 ## Drivers
190                 -DPLD_cgm=OFF
191                 -DPLD_gif=OFF
192                 -DPLD_jpeg=OFF
193                 -DPLD_plmeta=OFF
194                 -DPLD_png=OFF
195                 -DPLD_pstex=OFF
196                 -DPLD_wxpng=OFF
197                 -DPLD_mem=ON
198                 -DPLD_null=ON
199                 -DPLD_wingcc=ON
200                 # Cairo
201                 $(usex cairo "" "-DDEFAULT_NO_CAIRO_DEVICES=ON")
202                 -DPLD_epscairo=$(usex cairo ON OFF)
203                 -DPLD_extcairo=$(usex cairo ON OFF)
204                 -DPLD_memcairo=$(usex cairo ON OFF)
205                 -DPLD_pdfcairo=$(usex cairo ON OFF)
206                 -DPLD_pngcairo=$(usex cairo ON OFF)
207                 -DPLD_pscairo=$(usex cairo ON OFF)
208                 -DPLD_svgcairo=$(usex cairo ON OFF)
209                 -DPLD_xcairo=$(usex cairo ON OFF)
210                 # LaTeX
211                 -DPLD_ps=$(usex latex ON OFF)
212                 # PDF
213                 -DPLD_pdf=$(usex pdf ON OFF)
214                 # Qt
215                 -DPLD_aqt=$(usex qt5 ON OFF)
216                 -DPLD_bmpqt=$(usex qt5 ON OFF)
217                 -DPLD_epsqt=$(usex qt5 ON OFF)
218                 -DPLD_extqt=$(usex qt5 ON OFF)
219                 -DPLD_jpgqt=$(usex qt5 ON OFF)
220                 -DPLD_memqt=$(usex qt5 ON OFF)
221                 -DPLD_pdfqt=$(usex qt5 ON OFF)
222                 -DPLD_pngqt=$(usex qt5 ON OFF)
223                 -DPLD_ppmqt=$(usex qt5 ON OFF)
224                 -DPLD_qtwidget=$(usex qt5 ON OFF)
225                 -DPLD_svgqt=$(usex qt5 ON OFF)
226                 -DPLD_tiffqt=$(usex qt5 ON OFF)
227                 # SVG
228                 -DPLD_svg=$(usex svg ON OFF)
229                 # Tk
230                 -DPLD_ntk=$(usex tk ON OFF)
231                 -DPLD_tk=$(usex tk ON OFF)
232                 -DPLD_tkwin=$(usex tk ON OFF)
233                 # Truetype
234                 -DPLD_psttf=$(usex truetype ON OFF)
235                 # Wx
236                 -DPLD_wxwidgets=$(usex wxwidgets ON OFF)
237                 # X
238                 -DPLD_xfig=$(usex X ON OFF)
239                 -DPLD_xwin=$(usex X ON OFF)
240         )
241
242         use truetype && mycmakeargs+=(
243                 -DPL_FREETYPE_FONT_PATH="${EPREFIX}"/usr/share/fonts/freefont
244         )
245         use shapefile && mycmakeargs+=(
246                 -DSHAPELIB_INCLUDE_DIR="${EPREFIX}"/usr/include/libshp
247         )
248         use ocaml && mycmakeargs+=(
249                 -DOCAML_INSTALL_DIR="$(ocamlc -where)"
250         )
251         use python && mycmakeargs+=(
252                 -DENABLE_pyqt5=$(usex qt5)
253         )
254
255         cmake-utils_src_configure
256
257         # clean up bloated pkg-config files (help linking properly on prefix)
258         sed -i \
259                 -e "/Cflags/s:-I\(${EPREFIX}\|\)/usr/include[[:space:]]::g" \
260                 -e "/Libs/s:-L\(${EPREFIX}\|\)/usr/lib\(64\|\)[[:space:]]::g" \
261                 -e "s:${LDFLAGS}::g" \
262                 "${BUILD_DIR}"/pkgcfg/*pc || die
263 }
264
265 src_test() {
266         virtx cmake-utils_src_test
267 }
268
269 src_install() {
270         cmake-utils_src_install
271
272         if use examples; then
273                 docompress -x /usr/share/doc/${PF}/examples
274         else
275                 rm -r "${ED%/}"/usr/share/doc/${PF}/examples || die
276         fi
277
278         if use java; then
279                 java-pkg_dojar "${BUILD_DIR}"/examples/java/${PN}.jar
280                 java-pkg_regso "${EPREFIX}"/usr/$(get_libdir)/jni/plplotjavac_wrap.so
281         fi
282 }