# -*- 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
# $Id: Portfile 93159 2012-05-16 18:10:00Z ryandesign@macports.org $

PortSystem          1.0

name                xmlroff
version             0.6.2
categories          textproc
platforms           darwin
maintainers         nomaintainer
license             BSD

description         An XSL formatter producing PDF and PostScript.

long_description    Creates formatted output -- pages containing text in a \
                    variety of type styles and sizes -- from an input XML \
                    document and an XSL stylesheet.

homepage            http://xmlroff.org/
master_sites        ${homepage}download/

checksums           rmd160  a20e052ba7adae1e704f5f2620d14456872245c7 \
                    sha256  305be62e51406baaa74870cb95f813f436a756170d2cd14eb48ffd13c7b20f74

depends_build       port:pkgconfig

depends_lib         port:libxml2 \
                    port:atk \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:gtk2 \
                    port:libart_lgpl \
                    port:libbonobo \
                    port:libgnomeprint \
                    port:libidl \
                    port:libxslt \
                    port:orbit2 \
                    path:lib/pkgconfig/pango.pc:pango \
                    port:pangoxsl \
                    port:xmlcatmgr

patchfiles          patch-glib-2.32.diff

configure.ldflags-append    "-framework CoreFoundation"

# Specify catalog to add (catalog for xmlroff's libfo library)
set libfocatalog ${prefix}/share/xml/libfo-${version}/catalog.xml

post-activate {
    # xmlcatmgr as installed by MacPorts defaults to using
    # ${prefix}/etc/xml/docbook (for XML) and ${prefix}/etc/xml/docbook (for
    # SGML) if no catalog is specified, but we'll specify the path just in case
    # users have another installation of xmlcatmgr and happen to have it before
    # ${prefix}/bin in their PATH.
    set catalog.xml ${prefix}/etc/xml/catalog

    # Make the directory if it doesn't exist
    if {![file exists ${prefix}/etc/xml]} {
        xinstall -m 755 -d ${prefix}/etc/xml
    }

    # Create the catalog file if it doesn't exist
    if {![file exists ${catalog.xml}]} {
        system "xmlcatmgr create -c ${catalog.xml}"
    }

    # Add the nextCatalog entry to the catalog if it doesn't exist
    if {[catch {exec xmlcatmgr lookup ${libfocatalog}}]} {
        system "xmlcatmgr add nextCatalog ${libfocatalog}"
    }
}

# This will remove the catalog entry for this port.
post-deactivate {
    system "xmlcatmgr remove nextCatalog ${libfocatalog}"
}
