# $Id: Portfile 41808 2008-11-10 23:41:44Z ryandesign@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"
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

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

    # 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}"
    }
    # Once MacPorts does get a post-deactivate hook, this should change to
    # auto-detect whether or not the user's installed version has the hook, and
    # only print the message if it doesn't.
    ui_msg \
    "######################################################################"
    ui_msg "# As MacPorts does not currently have a post-deactivate hook,\
        \n# you will need to ensure that you manually remove the catalog\
        \n# entry for this port when you uninstall it.  To do so, run\
        \n# \"xmlcatmgr remove nextCatalog ${libfocatalog}\"."
    ui_msg \
    "######################################################################"
}

# This will remove the catalog entry for this port once a post-deactivate hook
# has been implemented.
#post-deactivate {
#    system "xmlcatmgr remove nextCatalog ${libfocatalog}"
#}

