# -*- 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           perl5 1.0

name                docbook-utils
version             0.6.14
revision            6

# add perl variants
perl5.require_variant   yes
perl5.conflict_variants yes
perl5.branches          5.28 5.30 5.32 5.34
perl5.default_branch    5.34
perl5.create_variants   ${perl5.branches}

categories          textproc
platforms           any
supported_archs     noarch
license             GPL-2+
maintainers         {gmail.com:tlockhart1976 @lockhart} openmaintainer
homepage            https://sourceware.org/docbook-tools/
description         Shell scripts for managing DocBook documents
long_description \
    This package contains scripts for easy conversion from DocBook \
    files to other formats (for example, HTML, RTF, and PostScript), and \
    for comparing SGML files. \
    Transcribed from the Fedora 15 RPM written originally by \
    Tim Waugh <twaugh@redhat.com> based on work by Eric Bischoff \
    and with recent maintenance by Ondrej Vasik <ovasik@redhat.com>.
master_sites        debian:d/${name}
distname            ${name}_${version}.orig
worksrcdir          ${name}-${version}

checksums           rmd160  710fe047ea8a794cc6c0d944521184375a666e6b \
                    sha256  48faab8ee8a7605c9342fb7b906e0815e3cee84a489182af38e8f7c0df2e92e9 \
                    size    124998

conflicts           docbook2X

depends_lib         port:sgml-common \
                    port:p${perl5.major}-sgmlspm \
                    port:openjade \
                    port:docbook-dsssl \
                    port:docbook-sgml-4.2

configure.args-append --mandir=${prefix}/share/man

post-extract {
    copy ${filespath}/docbook2man-spec.pl \
        ${worksrcpath}/bin/
}

patch.pre_args-replace  -p0 -p1
patchfiles          docbook-utils-spaces.patch \
                    docbook-utils-2ndspaces.patch \
                    docbook-utils-w3mtxtconvert.patch \
                    docbook-utils-grepnocolors.patch \
                    docbook-utils-sgmlinclude.patch \
                    docbook-utils-rtfmanpage.patch \
                    docbook-utils-papersize.patch \
                    docbook-utils-nofinalecho.patch \
                    docbook-utils-newgrep.patch

post-patch {
    reinplace -E "s|^docdir=.+$|docdir='${prefix}/share/doc'|" \
        ${worksrcpath}/configure
    reinplace -E "s|^(htmldir = .+)(/html)(.+)$|\\1\\3\\2|" \
        ${worksrcpath}/doc/HTML/Makefile.in

    reinplace "s|/etc/sgml|${prefix}/etc/sgml|" \
        ${worksrcpath}/bin/jw.in \
        ${worksrcpath}/doc/man/Makefile.in \
        ${worksrcpath}/doc/HTML/Makefile.in
    reinplace "s|jade|openjade|" \
        ${worksrcpath}/doc/man/Makefile.in \
        ${worksrcpath}/doc/HTML/Makefile.in
    reinplace "s|nsgmls|onsgmls|g" \
        ${worksrcpath}/backends/man.in \
        ${worksrcpath}/backends/texi.in \
        ${worksrcpath}/helpers/docbook2man-spec.pl \
        ${worksrcpath}/bin/sgmldiff.in \
        ${worksrcpath}/doc/man/Makefile.in \
        ${worksrcpath}/doc/HTML/Makefile.in
    reinplace -W ${worksrcpath} "s|sgmlspl|sgmlspl-${perl5.major}|g" \
        backends/man.in \
        backends/texi.in \
        doc/man/Makefile.in

    # Update content to docbook-4.x since we do not have 3.x available in MacPorts
    reinplace "s|V3.1|V4.2|" ${worksrcpath}/doc/docbook-utils.sgml
    reinplace "s|docinfo|chapterinfo|" \
        ${worksrcpath}/doc/docbook-utils.sgml
    reinplace "s|docinfo|refentryinfo|" \
        ${worksrcpath}/doc/refentry/docbook2man-spec.pl.sgml \
        ${worksrcpath}/doc/refentry/jw.sgml \
        ${worksrcpath}/doc/refentry/frontend-spec.sgml \
        ${worksrcpath}/doc/refentry/backend-spec.sgml \
        ${worksrcpath}/doc/refentry/sgmldiff.sgml
    reinplace "s|<Comment>|<!-- |" \
        ${worksrcpath}/doc/refentry/docbook2man-spec.pl.sgml
    reinplace "s|</Comment>| -->|" \
        ${worksrcpath}/doc/refentry/docbook2man-spec.pl.sgml
}

# per ChangeLog no upstream release since 2004-02-11
livecheck.type     none
