# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# $Id: Portfile 44941 2009-01-04 23:51:12Z ryandesign@macports.org $

PortSystem 1.0
PortGroup  python26 1.0

name                    py26-openssl
version                 0.8
categories              python devel security
maintainers             mcalhoun openmaintainer
platforms               darwin freebsd
description             python wrapper around the OpenSSL library
long_description        This python module is a rather thin wrapper around (a \
                                subset of) the OpenSSL library. With thin wrapper a lot of the \
                                object methods do nothing more than calling a corresponding \
                                function in the OpenSSL library.

homepage                http://pyopenssl.sourceforge.net/
master_sites            sourceforge:pyopenssl
distname                pyOpenSSL-${version}

checksums \
    md5     00377690f224d9e59c833fb0459603f4 \
    sha1    50f4214dc18d8b90b9c6a7f50d6c004edad997eb \
    rmd160  daacaab96c45aadca25f8aa39238a12d1907ddaa

depends_lib-append port:openssl

post-patch {
    reinplace "s|/sw/|${prefix}/|g" ${worksrcpath}/setup.py
    reinplace "s|#!/usr/bin/env python|#!${prefix}/bin/python2.6|g" ${worksrcpath}/examples/proxy.py
}

post-destroot {
    xinstall -m 644 -W ${worksrcpath} \
        COPYING ChangeLog INSTALL README TODO \
        ${destroot}${prefix}/share/doc/${name}
    
    file delete ${destroot}${prefix}/share/doc/${name}/examples
    file copy ${worksrcpath}/examples ${destroot}${prefix}/share/doc/${name}
}

variant doc description {build html documentation} {
    depends_build-append port:latex2html
    
    post-patch {
        # Ensure that the correct binaries are used.
        # Some are not actually invoked because only the html documentation is created.
        foreach bin {bibtex dvips latex latex2html lynx makeindex pdflatex perl python} {
            reinplace "s| = \"${bin}\"| = \"${prefix}/bin/${bin}\"|g" ${worksrcpath}/doc/tools/mkhowto
        }
        
        # Ensure that the correct python is used.
        reinplace "s|${prefix}/bin/python|${prefix}/bin/python2.6|g" ${worksrcpath}/doc/tools/mkhowto
        reinplace "s| python | ${prefix}/bin/python2.6 |g" ${worksrcpath}/doc/Makefile
    }
    
    post-build {
        system "cd ${worksrcpath}/doc && /usr/bin/make html"
    }
    
    post-destroot {
        file copy ${worksrcpath}/doc/html ${destroot}${prefix}/share/doc/${name}
    }
}
