# -*- 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.38 v
github.tarball_from archive
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  95fd5ac5a8065bc3b41b5920bbe148b8394acdc1 \
                    sha256  6c4337f9b3b3e0be106f74ee4277744988d0a2ac46b7bf66bfef9f044ad7f900 \
                    size    1223067

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
}
