# -*- 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
PortGroup           makefile 1.0

github.setup        willemdj erlsom 1.5.1 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            0
categories          erlang textproc
license             LGPL-3+
maintainers         nomaintainer
platforms           any
supported_archs     noarch

description         An Erlang libary for XML parsing.
long_description    {*}${description} It supports various modes of operation: as an efficient SAX parser, \
                    as a simple DOM-like parser, or as a 'data mapper'. The data mapper transforms the XML document \
                    to Erlang records, based on an XML Schema.
homepage            https://erlsom.sourceforge.net

checksums           rmd160  eb8067e090f5a83ed9741ab4bbf0f75090cf3b06 \
                    sha256  7c2ae046aa19e95f8717f1ac980fc0f758a2e0ab138ef2ba1f930a2d4ed8a86c \
                    size    331564

depends_build       port:erlang \
                    port:rebar3

# Provided rebar is broken: https://github.com/willemdj/erlsom/issues/91
# Use rebar3 from Macports:
patchfiles-append   patch-use-rebar3.diff

post-patch {
    reinplace "s,@PREFIX@,${prefix}," ${worksrcpath}/Makefile
}

set libdir ${prefix}/lib/erlang/lib/${name}

destroot {
    xinstall -d ${destroot}${libdir}
    copy ${worksrcpath}/_build/default/lib/${name}/ebin ${destroot}${libdir}/ebin
    copy ${worksrcpath}/include ${destroot}${libdir}/include
    copy ${worksrcpath}/priv ${destroot}${libdir}/priv
    copy ${worksrcpath}/src ${destroot}${libdir}/src

    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} CHANGELOG.md COPYING COPYING.LESSER README.md ${destroot}${docdir}
    copy ${worksrcpath}/doc ${destroot}${docdir}/docs
    copy ${worksrcpath}/examples ${destroot}${docdir}
}
