# -*- 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        camlp5 camlp5 8.05.01
github.tarball_from archive
revision            1
categories          lang ocaml
license             BSD
maintainers         {pmetzger @pmetzger} openmaintainer

description         Camlp5 is a preprocessor-pretty-printer of OCaml.
long_description    Camlp5 is a preprocessor and pretty-printer for \
        OCaml programs. It also provides parsing and printing tools. \
        As a preprocessor, it allows to: extend the syntax of OCaml, \
        redefine the whole syntax of the language. As a pretty printer, \
        it allows to: display OCaml programs in an elegant way, convert \
        from one syntax to another, check the results of syntax \
        extensions. Camlp5 also provides some parsing and pretty \
        printing tools: extensible grammars, extensible printers, \
        stream parsers and lexers pretty print module.  It works as a \
        shell command and can also be used in the OCaml toplevel.

homepage            https://camlp5.github.io/

checksums           rmd160  69c8ee14343af0c0d2f381a88b28d29462dcf82c \
                    sha256  7aa71c393cf4f24860051a5aa78da8925d73cb79ba045df442dff2343b1283d7 \
                    size    1506086

depends_build       bin:perl:perl5
depends_lib         port:ocaml \
    port:ocaml-bos \
    port:ocaml-camlp-streams \
    port:ocaml-camlp5-buildscripts \
    port:ocaml-findlib \
    port:ocaml-fmt \
    port:ocaml-pcre2 \
    port:ocaml-re \
    port:ocaml-rresult

configure.pre_args  --prefix "${prefix}"
configure.args      --mandir "${prefix}/share/man"

if {${build_arch} in [list i386 ppc ppc64]} {
    build.target    world
    } else {
    build.target    world.opt
}

use_parallel_build  no

# ocaml is not universal
universal_variant   no

post-destroot {
    # Install META file not installed by the Makefile, with directory field
    # so ocamlfind can locate the compiled modules in ${prefix}/lib/${name}
    xinstall -m 755 -d ${destroot}${prefix}/lib/ocaml/site-lib/${name}
    set meta_fd [open ${worksrcpath}/etc/META r]
    set meta_content [read $meta_fd]
    close $meta_fd
    set out_fd [open ${destroot}${prefix}/lib/ocaml/site-lib/${name}/META w]
    puts $out_fd "directory = \"${prefix}/lib/${name}\""
    puts -nonewline $out_fd $meta_content
    close $out_fd
}
