# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0

github.setup        maranget hevea 2.36 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
categories          textproc www tex
maintainers         {pmetzger @pmetzger} openmaintainer
license             {QPL LGPL}
description         HEVEA is a quite complete and fast LATEX to HTML translator.
long_description    HEVEA is a LaTeX to HTML translator.\
                    The input language is a fairly complete subset\
                    of LaTeX2e (old LaTeX style is also accepted) and\
                    the output language is HTML that is (hopefully)\
                    correct with respect to version 4.0 (transitional)

homepage            https://hevea.inria.fr/

checksums           rmd160  86a6c3556521312afc3e8eb8e12261e6bfa7c768 \
                    sha256  e46e53b80da79309e61014ec43dd6cd3572230f979fa8dc539d311d94ff34fdf \
                    size    1218008

patchfiles          patch-Makefile.diff

depends_build       port:ocaml \
                    port:ocaml-ocamlbuild

universal_variant   no
installs_libs       no

configure {
    reinplace "s|^PREFIX?=.*|PREFIX=${prefix}|" ${worksrcpath}/Makefile
    reinplace "s|^LIBDIR=.*|LIBDIR=${prefix}/share/${name}|" ${worksrcpath}/Makefile
    reinplace "s|^LATEXLIBDIR=.*|LATEXLIBDIR=${prefix}/share/${name}|" ${worksrcpath}/Makefile
    reinplace "s|^DESTDIR=.*|DESTDIR=${destroot}|" ${worksrcpath}/Makefile
}

# When OCaml is updated to 5.x, this should be modified, since 32-bit support is removed in it for all OSs.
# I.e. i386 and ppc will only have bytecode compiler, regardless of a platform.
# Only ppc64 then should be left conditional on Darwin, until the native compiler is fixed for it.
if {${os.platform} eq "darwin" && (${configure.build_arch} in [list ppc ppc64])} {
    build.target    byte
    destroot.cmd    ./install.sh byte
}
