dev-tex/mathtex: Add imagemagick/dvips alternative
[portage-overlay.git] / dev-tex / mathtex / mathtex-1.05.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 EAPI=5
6 inherit toolchain-funcs
7
8 DESCRIPTION="Tool to easily embed LaTeX math in html pages"
9 HOMEPAGE="http://www.forkosh.com/mathtex.html"
10
11 LICENSE="GPL-3"
12 SLOT="0"
13 IUSE="png imagemagick"
14 SRC_URI="https://download.sumptuouscapital.com/gentoo/releases/${CATEGORY}/${PN}/${P}.zip"
15
16 KEYWORDS="~amd64 ~x86"
17
18 CDEPEND="virtual/latex-base
19         !imagemagick ( app-text/dvipng )
20         imagemagick ( app-text/dvipsk media-gfx/imagemagick )"
21
22 DEPEND="${CDEPEND}"
23 RDEPEND="${CDEPEND}"
24
25 S=${WORKDIR}
26
27 src_compile()
28 {
29         local -a myconf = ( );
30
31         if use png then;
32             myconf+=( "-DPNG" )
33         fi;
34
35         if use imagemagick; then
36             myconf+=( 
37                -DDVIPS=\"$(/usr/bin/which dvips)\"
38                -DCONVERT=\"$(/usr/bin/which convert)\"
39             )
40         else
41             myconf+=(
42                  -DDVIPNG=\"$(/usr/bin/which dvipng)\"
43             )
44         fi
45
46         #This package ships as a single .c file, manual compile process needed
47         $(tc-getCC) mathtex.c \
48             -DLATEX=\"$(/usr/bin/which latex)\" \
49             -DCACHE=\"../${PN}_cache\" \
50             ${myconf[@]}
51             -o mathtex.cgi || die
52 }
53
54 src_install()
55 {
56         dodoc README
57         exeinto /usr/libexec/${PN}
58         doexe ${PN}.cgi
59 }
60
61 pkg_postinst()
62 {
63         elog "${PN}.cgi has been installed in /usr/libexec/${PN},"
64         elog "if you want to enable this for a webserver please create a symlink"\
65              " to your cgi-bin"
66 }