Ticket #51818: Portfile

File Portfile, 5.3 KB (added by brucemiller (bruce miller), 8 years ago)
Line 
1# -*- coding: utf-8; mode: tcl; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; truncate-lines: t -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
2# $Id$
3#======================================================================
4# Portfile for LaTeXML
5#======================================================================
6PortSystem          1.0
7PortGroup           texlive 1.0
8
9name                LaTeXML
10version             0.8.2
11license             public-domain
12maintainers         nist.gov:bruce.miller
13description         LaTeXML converts TeX to XML/HTML/MathML
14long_description \
15   LaTeXML converts TeX to XML, including HTML, XHTML, ePub with MathML.
16
17# Written in Perl, but it is an application, not just modules
18PortGroup           perl5 1.0
19perl5.branches      5.24
20perl5.setup         ${name} ${version}
21perl5.link_binaries_suffix
22
23categories          tex
24homepage            http://dlmf.nist.gov/LaTeXML/
25
26platforms           darwin
27supported_archs     noarch
28
29master_sites        ${homepage}/releases/
30checksums           rmd160 6dbf960277cdcf30605ce93335e3383673c1ff66 \
31                    sha256 3d41a3012760d31d721b569d8c1b430cde1df2b68fcc3c66f41ec640965caabf
32# Use:
33# openssl rmd160 LaTeXML-0.8.2.tar.gz
34# openssl sha256 LaTeXML-0.8.2.tar.gz
35
36#============================================================
37# Dependencies
38depends_lib-append \
39        port:p${perl5.major}-archive-zip \
40        port:p${perl5.major}-file-which \
41        port:p${perl5.major}-getopt-long \
42        port:p${perl5.major}-image-size \
43        port:p${perl5.major}-io-string \
44        port:p${perl5.major}-json-xs \
45        port:p${perl5.major}-libwww-perl \
46        port:p${perl5.major}-parse-recdescent \
47        port:p${perl5.major}-text-unidecode \
48        port:p${perl5.major}-time-hires \
49        port:p${perl5.major}-uri \
50        port:p${perl5.major}-xml-libxml \
51        port:p${perl5.major}-xml-libxslt \
52        port:p${perl5.major}-perlmagick
53
54# Also requires: DB_File, Pod::Parser, Test::More & version
55# but those should be in any non-obsolete Perl's core modules.
56
57#============================================================
58# LaTeXML works MUCH better if there is a TeX installed.
59# - it uses some latex style files from texlive within bindings
60# - it can install its own style files for use within tex/latex
61# We could simply depend on texlive, but some folks prefer MacTeX
62# and object to 2nd multi-GB download!  So we define variants.
63options latexml.found_tex
64default latexml.found_tex no
65
66# No texmf install via Makefile.
67pre-configure {
68   configure.args-append   TEXMF=
69  }
70# We don't want dependencies on texlive, but want to cooperate.
71# We'll install style files where texlive expects or will expect.
72post-destroot {
73    xinstall -d ${texlive_texmfdist}/tex/latex/latexml
74    foreach sty [glob ${worksrcpath}/lib/LaTeXML/texmf/*.sty] {
75        file copy -force ${sty} ${texlive_texmfdist}/tex/latex/latexml/
76    }
77}
78# invoke mktexlsr IFF texlive already installed;
79# otherwise texlive will do it if it's ever installed.
80post-activate {
81    if [file executable ${prefix}/bin/mktexlsr] {
82        latexml.found_tex yes
83        ${texlive.mktexlsr}
84    }
85}
86# Remove style files
87post-uninstall {
88    foreach sty [glob -nocomplain ${texlive_texmfdist}/tex/latex/latexml/*.sty] {
89        delete ${sty}
90    }
91    if [file executable ${prefix}/bin/mktexlsr] {
92        ${texlive.mktexlsr}
93    }
94}
95
96# The mactex variant expects MacTeX to be installed
97# and installs latexml's stylefiles to MacTeX's texmf (local)
98options latexml.mactex_bin
99options latexml.mactex_texmf
100default latexml.mactex_bin ""
101default latexml.mactex_texmf ""
102set latexml.mactex_candidates { \
103   "/Library/TeX/texbin" \
104   "/usr/texbin" \
105}
106variant mactex description {Build with MacTeX support} {
107    # First, check if MacTeX actually seems to be there...
108    foreach dir ${latexml.mactex_candidates} {
109        if [file executable "${dir}/kpsewhich"] {
110            latexml.mactex_bin ${dir}
111            break
112        }
113    }
114    if { ${latexml.mactex_bin} != "" } {
115        latexml.mactex_texmf \
116            [exec ${latexml.mactex_bin}/kpsewhich --expand-var='\$TEXMFLOCAL']
117        regsub -all {'} ${latexml.mactex_texmf} "" latexml.mactex_texmf
118        latexml.found_tex yes
119    } else {
120        return -code error "Cannot find MacTeX installation; aborting"
121    }
122
123    post-destroot {
124        xinstall -d ${latexml.mactex_texmf}/tex/latex/latexml
125        foreach sty [glob ${worksrcpath}/lib/LaTeXML/texmf/*.sty] {
126            file copy -force ${sty} ${latexml.mactex_texmf}/tex/latex/latexml/
127        }
128    }
129    post-activate {
130        system "${latexml.mactex_bin}/mktexlsr"
131    }
132    # Remove style files
133    post-uninstall {
134        foreach sty [glob -nocomplain ${latexml.mactex_texmf}/tex/latex/latexml/*.sty] {
135            delete ${sty}
136        }
137        system "${latexml.mactex_bin}/mktexlsr"
138    }
139    notes "Using MacTeX for TeX: will install styles to MacTeX's texmf-local \
140        ${latexml.mactex_texmf} \
141        (which is outside macport's common directory structure)"
142    # AND, since we're installing files outside macports' normal directories
143    destroot.violate_mtree  yes
144}
145
146post-activate {
147    if {! ${latexml.found_tex}} {
148        ui_msg "${name} works best with some version of TeX installed. \
149    Please consider installing texlive, or PRE-install MacTeX and use +mactex variant."
150    }
151}
152
153#============================================================