# $Id: Portfile 68945 2010-06-18 15:20:23Z 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.sourceforge.net
master_sites			sourceforge:xmlroff

platforms			darwin
checksums			md5 83cc19e284efb140008d11863fe74ff2

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

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

if {${registry.format} == "receipt_flat"} {
    notes \
"######################################################################
# As the flat registry format does not support post-deactivate hooks,
# you will need to ensure that you manually remove the catalog
# entry for this port when you uninstall it.  To do so, run
# \"xmlcatmgr remove nextCatalog ${libfocatalog}\".
######################################################################"
}

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