Ticket #51818: Portfile.3

File Portfile.3, 5.0 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.
63set latexml.found_tex no
64
65# We don't want dependencies on texlive, but want to cooperate.
66# We'll install style files where texlive expects or will expect.
67configure.args-append   TEXMF=${texlive_texmfdist}
68
69# But the .packlist will need cleanup
70post-destroot {
71    fs-traverse file ${destroot}${prefix}/share {
72        if {[file isfile ${file}] && [file tail ${file}] eq ".packlist"} {
73            ui_info "Fixing paths in [string map "${destroot}${prefix}/ {}" ${file}]"
74            reinplace -n "s|${destroot}||p" ${file}
75        }
76    }
77}
78
79# Note whether we've found a TeX
80post-activate {
81    if [file executable ${prefix}/bin/mktexlsr] {
82        latexml.found_tex yes
83    }
84}
85
86# The mactex variant expects MacTeX to be installed
87# and installs latexml's stylefiles to MacTeX's texmf (local)
88set latexml.mactex_bin ""
89set latexml.mactex_texmf ""
90set latexml.mactex_candidates { \
91   "/Library/TeX/texbin" \
92   "/usr/texbin" \
93}
94variant mactex description {Build with MacTeX support} {
95    # First, check if MacTeX actually seems to be there...
96    foreach dir ${latexml.mactex_candidates} {
97        if [file executable "${dir}/kpsewhich"] {
98            set latexml.mactex_bin ${dir}
99            break
100        }
101    }
102    if { ${latexml.mactex_bin} != "" } {
103        set latexml.mactex_texmf \
104            [exec ${latexml.mactex_bin}/kpsewhich --expand-var='\$TEXMFLOCAL']
105        regsub -all {'} ${latexml.mactex_texmf} "" latexml.mactex_texmf
106        set latexml.found_tex yes
107    } else {
108        return -code error "Cannot find MacTeX installation; aborting"
109    }
110
111    post-destroot {
112        xinstall -d ${latexml.mactex_texmf}/tex/latex/latexml
113        foreach sty [glob ${worksrcpath}/lib/LaTeXML/texmf/*.sty] {
114            file copy -force ${sty} ${latexml.mactex_texmf}/tex/latex/latexml/
115        }
116    }
117    post-activate {
118        system "${latexml.mactex_bin}/mktexlsr"
119    }
120    # Remove style files
121    post-uninstall {
122        foreach sty [glob -nocomplain ${latexml.mactex_texmf}/tex/latex/latexml/*.sty] {
123            delete ${sty}
124        }
125        system "${latexml.mactex_bin}/mktexlsr"
126    }
127    notes "Using MacTeX for TeX: will install styles to MacTeX's texmf-local \
128        ${latexml.mactex_texmf} \
129        (which is outside macport's common directory structure)"
130    # AND, since we're installing files outside macports' normal directories
131    destroot.violate_mtree  yes
132}
133
134if {! ${latexml.found_tex}} {
135  notes "${name} works best with some version of TeX installed. \
136    Please consider installing texlive, or PRE-install MacTeX and use +mactex variant."
137}
138
139#============================================================