# $Id: Portfile 84028 2011-09-15 03:41:26Z jmr@macports.org $

PortSystem			1.0

name				xmlroff
version				0.5.1
categories			textproc
maintainers			nomaintainer
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/

platforms			darwin
checksums			md5 83cc19e284efb140008d11863fe74ff2

depends_build			port:pkgconfig
depends_lib			lib:libxml2.2:libxml2 \
				lib:libatk-1.0:atk \
				path:lib/pkgconfig/glib-2.0.pc:glib2 \
				lib:libgtk.2:gtk2 \
				lib:libart_lgpl_2:libart_lgpl \
				lib:libbonobo-2:libbonobo \
				lib:libgnomeprint-2.2:libgnomeprint \
				lib:libIDL-2:libidl \
				lib:libxslt:libxslt \
				lib:libORBit-2.0:orbit2 \
				path:lib/pkgconfig/pango.pc:pango \
				lib:libpangoxsl-1:pangoxsl \
				port:xmlcatmgr

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}"
}
