dev-db/postgresql: Merge "use /bin/sh (...) for postgres user"
[gentoo.git] / media-gfx / asymptote / asymptote-2.21.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=4
6
7 SUPPORT_PYTHON_ABIS=1
8 PYTHON_DEPEND="python? 2"
9 RESTRICT_PYTHON_ABIS="3.*"
10
11 inherit eutils autotools elisp-common latex-package multilib python
12
13 DESCRIPTION="A vector graphics language that provides a framework for technical drawing"
14 HOMEPAGE="http://asymptote.sourceforge.net/"
15 SRC_URI="mirror://sourceforge/asymptote/${P}.src.tgz"
16
17 LICENSE="GPL-3"
18 SLOT="0"
19 KEYWORDS="amd64 x86 ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos"
20 IUSE="+boehm-gc doc emacs examples fftw gsl +imagemagick latex offscreen +opengl python sigsegv svg vim-syntax X"
21
22 REQUIRED_USE="offscreen? ( opengl )"
23
24 RDEPEND="
25         >=sys-libs/readline-4.3-r5:0
26         >=sys-libs/ncurses-5.4-r5
27         imagemagick? ( media-gfx/imagemagick[png] )
28         opengl? ( >=media-libs/mesa-8 )
29         offscreen? ( media-libs/mesa[osmesa] )
30         svg? ( app-text/dvisvgm )
31         sigsegv? ( dev-libs/libsigsegv )
32         boehm-gc? ( >=dev-libs/boehm-gc-7.0[cxx,threads] )
33         fftw? ( >=sci-libs/fftw-3.0.1 )
34         gsl? ( sci-libs/gsl )
35         X? ( x11-misc/xdg-utils dev-lang/python dev-python/imaging[tk] )
36         latex? ( virtual/latex-base dev-texlive/texlive-latexextra )
37         emacs? ( virtual/emacs )
38         vim-syntax? ( || ( app-editors/vim app-editors/gvim ) )"
39 DEPEND="${RDEPEND}
40         doc? ( dev-lang/perl virtual/texi2dvi virtual/latex-base media-gfx/imagemagick[png] )"
41
42 TEXMF=/usr/share/texmf-site
43
44 src_prepare() {
45         # Fixing sigsegv enabling
46         epatch "${FILESDIR}/${P}-configure-ac.patch"
47         einfo "Patching configure.ac"
48         sed -e "s:Datadir/doc/asymptote:Datadir/doc/${PF}:" \
49                 -i configure.ac \
50                 || die "sed configure.ac failed"
51
52         # Changing pdf, ps, image viewers to xdg-open
53         epatch "${FILESDIR}/${P}-xdg-utils.patch"
54
55         # Bug #322473
56         epatch "${FILESDIR}/${P}-info.patch"
57
58         eautoreconf
59 }
60
61 src_configure() {
62         # for the CPPFLAGS see
63         # http://sourceforge.net/forum/forum.php?thread_id=1683277&forum_id=409349
64         econf \
65                 CPPFLAGS=-DHAVE_SYS_TYPES_H \
66                 CFLAGS="${CXXFLAGS}" \
67                 --disable-gc-debug \
68                 $(use_enable boehm-gc gc system) \
69                 $(use_enable fftw) \
70                 $(use_enable gsl) \
71                 $(use_enable opengl gl) \
72                 $(use_enable offscreen) \
73                 $(use_with sigsegv)
74 }
75
76 src_compile() {
77         emake
78
79         cd doc || die
80         emake asy.1
81         if use doc; then
82                 # info
83                 einfo "Making info"
84                 emake ${PN}.info
85                 cd FAQ || die
86                 emake
87                 cd .. || die
88                 # pdf
89                 einfo "Making pdf docs"
90                 export VARTEXFONTS="${T}"/fonts
91                 # see bug #260606
92                 emake -j1 asymptote.pdf
93                 emake CAD.pdf
94         fi
95         cd .. || die
96
97         if use emacs; then
98                 einfo "Compiling emacs lisp files"
99                 elisp-compile base/*.el
100         fi
101 }
102
103 src_install() {
104         # the program
105         dobin asy
106
107         # .asy files
108         insinto /usr/share/${PN}
109         doins base/*.asy
110
111         # documentation
112         dodoc BUGS ChangeLog README ReleaseNotes TODO
113         doman doc/asy.1
114
115         # X GUI
116         if use X; then
117                 exeinto /usr/share/${PN}/GUI
118                 doexe GUI/xasy.py
119                 rm GUI/xasy.py || die
120                 insinto /usr/share/${PN}/GUI
121                 doins GUI/*.py
122                 dosym /usr/share/${PN}/GUI/xasy.py /usr/bin/xasy
123                 doman doc/xasy.1x
124         fi
125
126         # examples
127         if use examples; then
128                 insinto /usr/share/${PN}/examples
129                 doins \
130                         examples/*.asy \
131                         examples/*.eps \
132                         doc/*.asy \
133                         doc/*.csv \
134                         doc/*.dat \
135                         doc/extra/*.asy
136                 use X && doins GUI/*.asy
137
138                 insinto /usr/share/${PN}/examples/animations
139                 doins examples/animations/*.asy
140         fi
141
142         # LaTeX style
143         if use latex; then
144                 cd doc || die
145                 insinto "${TEXMF}"/tex/latex/${PN}
146                 doins ${PN}.sty asycolors.sty
147                 if use examples; then
148                         insinto /usr/share/${PN}/examples
149                         doins latexusage.tex
150                 fi
151                 cd .. || die
152         fi
153
154         # asymptote.py
155         if use python; then
156                 python_install() {
157                         insinto "$(python_get_sitedir)"
158                         doins base/${PN}.py
159                 }
160                 python_execute_function python_install
161         fi
162
163         # emacs mode
164         if use emacs; then
165                 elisp-install ${PN} base/*.el base/*.elc
166                 elisp-site-file-install "${FILESDIR}"/64${PN}-gentoo.el
167         fi
168
169         # vim syntax
170         if use vim-syntax; then
171                 insinto /usr/share/vim/vimfiles/syntax
172                 doins base/asy.vim
173                 insinto /usr/share/vim/vimfiles/ftdetect
174                 doins "${FILESDIR}"/asy-ftd.vim
175         fi
176
177         # extra documentation
178         if use doc; then
179                 cd doc || die
180                 doinfo ${PN}.info*
181                 cd FAQ || die
182                 dodoc asy-faq.ascii
183                 doinfo asy-faq.info
184                 insinto /usr/share/doc/${PF}/html/FAQ
185                 doins asy-faq.html/*
186                 cd .. || die
187                 insinto /usr/share/doc/${PF}
188                 doins ${PN}.pdf CAD.pdf
189         fi
190 }
191
192 pkg_postinst() {
193         use python && python_mod_optimize ${PN}.py
194         use latex && latex-package_rehash
195         use emacs && elisp-site-regen
196
197         elog 'Use the variable ASYMPTOTE_PSVIEWER to set the postscript viewer'
198         elog 'Use the variable ASYMPTOTE_PDFVIEWER to set the PDF viewer'
199 }
200
201 pkg_postrm() {
202         use python && python_mod_cleanup ${PN}.py
203         use latex && latex-package_rehash
204         use emacs && elisp-site-regen
205 }