*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / media-gfx / graphviz / graphviz-2.42.3.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python2_7 python3_{6,7,8} )
7 inherit autotools flag-o-matic java-pkg-opt-2 python-single-r1 qmake-utils
8
9 DESCRIPTION="Open Source Graph Visualization Software"
10 HOMEPAGE="https://www.graphviz.org/ https://gitlab.com/graphviz/graphviz/"
11 SRC_URI="https://www2.graphviz.org/Packages/stable/portable_source/${P}.tar.gz"
12
13 LICENSE="CPL-1.0"
14 SLOT="0"
15 KEYWORDS="alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 s390 ~sh sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~x64-solaris"
16 IUSE="+cairo devil doc examples gdk-pixbuf gtk gts guile java lasi nls pdf perl postscript python qt5 ruby static-libs svg tcl X elibc_FreeBSD"
17
18 REQUIRED_USE="
19         !cairo? ( !X !gtk !postscript !lasi )
20         python? ( ${PYTHON_REQUIRED_USE} )"
21
22 # Requires ksh, tests against installed package, missing files and directory
23 RESTRICT="test"
24
25 BDEPEND="
26         sys-devel/flex
27         sys-devel/libtool
28         virtual/pkgconfig
29         nls? ( >=sys-devel/gettext-0.14.5 )
30         perl? ( dev-lang/swig )
31         python? ( dev-lang/swig )
32         ruby? ( dev-lang/swig )
33         tcl? ( dev-lang/swig )
34 "
35 RDEPEND="
36         >=dev-libs/expat-2
37         >=dev-libs/glib-2.11.1:2
38         dev-libs/libltdl:0
39         >=media-libs/fontconfig-2.3.95
40         >=media-libs/freetype-2.1.10
41         >=media-libs/gd-2.0.34:=[fontconfig,jpeg,png,truetype,zlib]
42         >=media-libs/libpng-1.2:0=
43         sys-libs/zlib
44         virtual/jpeg:0
45         virtual/libiconv
46         cairo? (
47                 >=x11-libs/cairo-1.1.10[svg]
48                 >=x11-libs/pango-1.12
49         )
50         devil? ( media-libs/devil[png,jpeg] )
51         gtk? ( x11-libs/gtk+:2 )
52         gts? ( sci-libs/gts )
53         lasi? ( media-libs/lasi )
54         pdf? ( app-text/poppler )
55         perl? ( dev-lang/perl:= )
56         postscript? ( app-text/ghostscript-gpl )
57         python? ( ${PYTHON_DEPS} )
58         qt5? (
59                 dev-qt/qtcore:5
60                 dev-qt/qtgui:5
61                 dev-qt/qtprintsupport:5
62                 dev-qt/qtwidgets:5
63         )
64         ruby? ( dev-lang/ruby:* )
65         svg? ( gnome-base/librsvg )
66         tcl? ( >=dev-lang/tcl-8.3:0= )
67         X? (
68                 x11-libs/libX11
69                 x11-libs/libXaw
70                 x11-libs/libXmu
71                 x11-libs/libXpm
72                 x11-libs/libXt
73         )
74 "
75 DEPEND="${RDEPEND}
76         guile? (
77                 dev-lang/swig
78                 dev-scheme/guile
79         )
80         java? (
81                 dev-lang/swig
82                 >=virtual/jdk-1.5
83         )
84 "
85
86 # Dependency description / Maintainer-Info:
87
88 # Rendering is done via the following plugins (/plugins):
89 # - core, dot_layout, neato_layout, gd , dot
90 #   the ones which are always compiled in, depend on zlib, gd
91 # - gtk
92 #   Directly depends on gtk-2.
93 #   needs 'pangocairo' enabled in graphviz configuration
94 #   gtk-2 depends on pango, cairo and libX11 directly.
95 # - gdk-pixbuf
96 #   Disabled, GTK-1 junk.
97 # - glitz
98 #   Disabled, no particular reason
99 #   needs 'pangocairo' enabled in graphviz configuration
100 # - ming
101 #   flash plugin via -Tswf requires media-libs/ming-0.4. Disabled as it's
102 #   incomplete.
103 # - cairo/pango:
104 #   Needs pango for text layout, uses cairo methods to draw stuff
105 # - xlib:
106 #   needs cairo+pango,
107 #   can make use of gnomeui and inotify support (??? unsure),
108 #   needs libXaw for UI
109 #   UI also links directly against libX11, libXmu, and libXt
110 #   and uses libXpm if available so we make sure it always is
111
112 # There can be swig-generated bindings for the following languages (/tclpkg/gv):
113 # - c-sharp (disabled)
114 # - scheme (enabled via guile) ... no longer broken on ~x86
115 # - go (disabled)
116 # - io (disabled)
117 # - java (enabled via java) *2
118 # - lua (enabled via lua)
119 # - ocaml (enabled via ocaml)
120 # - perl (enabled via perl) *1
121 # - php (enabled via php) *2
122 # - python (enabled via python) *1
123 # - ruby (enabled via ruby) *1
124 # - tcl (enabled via tcl)
125 # *1 = The ${P}-bindings.patch takes care that those bindings are installed to the right location
126 # *2 = Those bindings don't build because the paths for the headers/libs aren't
127 #      detected correctly and/or the options passed to swig are wrong (-php instead of -php4/5)
128
129 # There are several other tools in /tclpkg:
130 # gdtclft, tcldot, tclhandle, tclpathplan, tclstubs ; enabled with: --with-tcl
131 # tkspline, tkstubs ; enabled with: --with-tk
132
133 # And the commands (/cmd):
134 # - dot, dotty, gvedit, gvpr, lefty, lneato, smyrna, tools/* :)
135 #   sci-libs/gts can be used for some of these
136 # - lefty:
137 #   needs Xaw and X to build
138 # - gvedit (via 'qt5'):
139 #   based on ./configure it needs qt-core and qt-gui only
140 # - smyrna : experimental opengl front-end (via 'smyrna')
141 #   currently disabled -- it segfaults a lot
142 #   needs x11-libs/gtkglext, gnome-base/libglade, media-libs/freeglut
143 #   sci-libs/gts, x11-libs/gtk.  Also needs 'gtk','glade','glut','gts' and 'png'
144 #   with flags enabled at configure time
145
146 PATCHES=( "${FILESDIR}"/${PN}-2.34.0-Xaw-configure.patch )
147
148 pkg_setup() {
149         use python && python-single-r1_pkg_setup
150
151         java-pkg-opt-2_pkg_setup
152 }
153
154 src_prepare() {
155         default
156
157         # ToDo: Do the same thing for examples and/or
158         #       write a patch for a configuration-option
159         #       and send it to upstream
160         # note - the longer sed expression removes multi-line assignments that are extended via '\'
161         if ! use doc ; then
162                 find . -iname Makefile.am \
163                         | xargs sed -i -e '/^\(html\|pdf\)_DATA.*\\[[:space:]]*$/{:m;N;s/\\\n//;tm;d}' \
164                                 -e '/^\(html\|pdf\)_DATA/d' || die
165         fi
166
167         # This is an old version of libtool
168         # use the ./configure option to exclude its use, and
169         # delete the dir since we don't need to eautoreconf it
170         rm -r libltdl || die
171
172         # Nuke the dead symlinks for the bindings
173         sed -i -e '/$(pkgluadir)/d' tclpkg/gv/Makefile.am || die
174
175         # replace the whitespace with tabs
176         sed -i -e 's:  :\t:g' doc/info/Makefile.am || die
177
178         # use correct version of qmake. bug #567236
179         sed -i -e "/AC_CHECK_PROGS(QMAKE/a AC_SUBST(QMAKE,$(qt5_get_bindir)/qmake)" configure.ac || die
180
181         # workaround for http://www.graphviz.org/mantisbt/view.php?id=1895
182         use elibc_FreeBSD && append-flags $(test-flags -fno-builtin-sincos)
183
184         use java && append-cppflags $(java-pkg_get-jni-cflags)
185
186         eautoreconf
187 }
188
189 src_configure() {
190         local myconf=(
191                 --enable-ltdl
192                 $(use_with cairo pangocairo)
193                 $(use_with devil)
194                 $(use_enable gdk-pixbuf)
195                 $(use_with gtk)
196                 $(use_with gts)
197                 $(use_with qt5 qt)
198                 $(use_with lasi)
199                 $(use_with pdf poppler)
200                 $(use_with postscript ghostscript)
201                 $(use_enable static-libs static)
202                 $(use_with svg rsvg)
203                 $(use_with X x)
204                 $(use_with X xaw)
205                 $(use_with X lefty)
206                 --with-digcola
207                 --with-fontconfig
208                 --with-freetype2
209                 --with-ipsepcola
210                 --with-libgd
211                 --with-sfdp
212                 --without-ming
213                 # new/experimental features, to be tested, disable for now
214                 --with-cgraph
215                 --without-glitz
216                 --without-ipsepcola
217                 --without-smyrna
218                 --without-visio
219                 # Bindings:
220                 $(use_enable guile)
221                 $(use_enable java)
222                 $(use_enable perl)
223                 $(use_enable python python2)
224                 $(use_enable python python3)
225                 $(use_enable ruby)
226                 $(use_enable tcl)
227                 --disable-go
228                 --disable-io
229                 --disable-lua
230                 --disable-ocaml
231                 --disable-php
232                 --disable-python
233                 --disable-r
234                 --disable-sharp
235                 # libtool file collision, bug #276609
236                 --without-included-ltdl
237                 --disable-ltdl-install
238         )
239         econf "${myconf[@]}"
240 }
241
242 src_install() {
243         sed -i -e "s:htmldir:htmlinfodir:g" doc/info/Makefile || die
244
245         emake DESTDIR="${D}" \
246                 txtdir="${EPREFIX}"/usr/share/doc/${PF} \
247                 htmldir="${EPREFIX}"/usr/share/doc/${PF}/html \
248                 htmlinfodir="${EPREFIX}"/usr/share/doc/${PF}/html/info \
249                 pdfdir="${EPREFIX}"/usr/share/doc/${PF}/pdf \
250                 pkgconfigdir="${EPREFIX}"/usr/$(get_libdir)/pkgconfig \
251                 install
252
253         if ! use examples; then
254                 rm -rf "${ED}"/usr/share/graphviz/demo || die
255         fi
256
257         if ! use static-libs; then
258                 find "${ED}" -name '*.la' -delete || die
259         fi
260
261         einstalldocs
262
263         use python && python_optimize \
264                 "${D}$(python_get_sitedir)" \
265                 "${D}/usr/$(get_libdir)/graphviz/python2" \
266                 "${D}/usr/$(get_libdir)/graphviz/python3"
267 }
268
269 pkg_postinst() {
270         # This actually works if --enable-ltdl is passed
271         # to configure
272         dot -c || die
273 }
274
275 pkg_postrm() {
276         # Remove cruft, bug #547344
277         rm -rf "${EROOT}"/usr/$(get_libdir)/graphviz/config{,6} || die
278 }