# -*- 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 75669 2011-02-03 22:03:45Z ryandesign@macports.org $

PortSystem          1.0

name                xhtml1
version             2.0
categories          textproc
platforms           darwin
maintainers         redhat.com:jclift
supported_archs     noarch

description         A reformulation of HTML 4 in XML 1.0

long_description    The Second Edition of XHTML 1.0, a reformulation \
                    of HTML 4 as an XML 1.0 application, and three DTDs \
                    corresponding to the ones defined by HTML 4. \
                    These DTDs are useful for validating or processing \
                    world wide web pages with XML tools.

homepage            http://www.w3.org/TR/xhtml1/
master_sites        http://www.w3.org/TR/xhtml1/

dist_subdir         ${name}/${version}
distfiles           ${name}.tgz
worksrcdir          ${name}-20020801

checksums           sha1    6fb14e70047f4b56681cd64032ca5ec5eb9396cd \
                    rmd160  923b346b4cd7e2fac147692c95abca93cacfc828

depends_run         port:xmlcatmgr

use_configure       no
build               {}

set instdir         share/xml/html/4

destroot {
    xinstall -m 755 -d ${destroot}${prefix}/${instdir}
    xinstall -m 644 -W ${worksrcpath}/DTD/ xhtml.soc xhtml-lat1.ent xhtml-special.ent xhtml-symbol.ent xhtml1-frameset.dtd xhtml1-strict.dtd xhtml1-transitional.dtd xhtml1.dcl ${destroot}${prefix}/${instdir}
}

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 entries to the catalog
    system "xmlcatmgr add public '-//W3C//DTD XHTML 1.0 Strict//EN' '${prefix}/${instdir}/xhtml1-strict.dtd'"
    system "xmlcatmgr add public '-//W3C//DTD XHTML 1.0 Transitional//EN' '${prefix}/${instdir}/xhtml1-transitional.dtd'"
    system "xmlcatmgr add public '-//W3C//DTD XHTML 1.0 Frameset//EN' '${prefix}/${instdir}/xhtml1-frameset.dtd'"
    system "xmlcatmgr add public '-//W3C//ENTITIES Latin 1 for XHTML//EN' '${prefix}/${instdir}/xhtml-lat1.ent'"
    system "xmlcatmgr add public '-//W3C//ENTITIES Special for XHTML//EN' '${prefix}/${instdir}/xhtml-special.ent'"
    system "xmlcatmgr add public '-//W3C//ENTITIES Symbols for XHTML//EN' '${prefix}/${instdir}/xhtml-symbol.ent'"
    system "xmlcatmgr add rewriteSystem 'http://www.w3.org/TR/xhtml1/DTD/' '${prefix}/${instdir}/'"
    system "xmlcatmgr add rewriteSystem 'http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/' '${prefix}/${instdir}/'"
    system "xmlcatmgr add rewriteURI 'http://www.w3.org/TR/xhtml1/DTD/' '${prefix}/${instdir}/'"
    system "xmlcatmgr add rewriteURI 'http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/' '${prefix}/${instdir}/'"
}

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
# entres for this port when you uninstall it.  To do so, run
# \"xmlcatmgr remove public '-//W3C//DTD XHTML 1.0 Strict//EN'\"
# \"xmlcatmgr remove public '-//W3C//DTD XHTML 1.0 Transitional//EN'\"
# \"xmlcatmgr remove public '-//W3C//DTD XHTML 1.0 Frameset//EN'\"
# \"xmlcatmgr remove public '-//W3C//ENTITIES Latin 1 for XHTML//EN'\"
# \"xmlcatmgr remove public '-//W3C//ENTITIES Special for XHTML//EN'\"
# \"xmlcatmgr remove public '-//W3C//ENTITIES Symbols for XHTML//EN'\"
# \"xmlcatmgr remove rewriteSystem 'http://www.w3.org/TR/xhtml1/DTD/'\"
# \"xmlcatmgr remove rewriteSystem 'http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/'\"
# \"xmlcatmgr remove rewriteURI 'http://www.w3.org/TR/xhtml1/DTD/'\"
# \"xmlcatmgr remove rewriteURI 'http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/'\"
######################################################################"
}

# This will remove the catalog entries for this port.
post-deactivate {
    system "xmlcatmgr remove public '-//W3C//DTD XHTML 1.0 Strict//EN'"
    system "xmlcatmgr remove public '-//W3C//DTD XHTML 1.0 Transitional//EN'"
    system "xmlcatmgr remove public '-//W3C//DTD XHTML 1.0 Frameset//EN'"
    system "xmlcatmgr remove public '-//W3C//ENTITIES Latin 1 for XHTML//EN'"
    system "xmlcatmgr remove public '-//W3C//ENTITIES Special for XHTML//EN'"
    system "xmlcatmgr remove public '-//W3C//ENTITIES Symbols for XHTML//EN'"
    system "xmlcatmgr remove rewriteSystem 'http://www.w3.org/TR/xhtml1/DTD/'"
    system "xmlcatmgr remove rewriteSystem 'http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/'"
    system "xmlcatmgr remove rewriteURI 'http://www.w3.org/TR/xhtml1/DTD/'"
    system "xmlcatmgr remove rewriteURI 'http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/'"
}

livecheck.type      none
