# $Id: Portfile 65648 2010-03-29 21:20:44Z ryandesign@macports.org $

PortSystem      1.0

name            libzzip
set my_name     zziplib
version         0.13.59
categories      archivers devel
platforms       darwin
maintainers     nomaintainer
description     library providing read access on ZIP-archives

long_description \
    The ZZIPlib provides read access on ZIP-archives. The \
    library uses only the patent-free compression-algorithms \
    supported by Zlib. It provides functions that transparently \
    access files being either real files or zipped files, \
    both with the same filepath.

homepage        http://zziplib.sourceforge.net/
master_sites    sourceforge:${my_name}
distname        ${my_name}-${version}
use_bzip2       yes

checksums       md5     14b5a6fc229afe9916d48358479568d3 \
                sha1    ddbce25cb36c3b4c2b892e2c8a88fa4a0be29a71 \
                rmd160  b96f547039ac005f6e9ca2cf92c388a077b9b21e

depends_build   port:pkgconfig \
                port:xmlto

depends_lib     port:zlib

patchfiles      patch-zzip_Makefile.in.diff

set docdir ${prefix}/share/doc/${name}

if {[variant_isset universal]} {
    patchfiles-append patch-configure.ac.diff
    use_autoconf yes
}

post-destroot {
    xinstall -d ${destroot}${docdir}/html

    xinstall -m 0644 -W ${worksrcpath} COPYING.LIB ChangeLog README TODO \
        ${destroot}${docdir}

    eval xinstall -m 0644 [glob -directory ${worksrcpath}/docs "*.{css,htm}"] \
        ${destroot}${docdir}/html

    # We replace every soelim stub with a soft link, as ".so" groff directives
    # don't work with gzip'd manpages.

    foreach {f} [glob -directory ${destroot}${prefix}/share/man/man3 *.3] {
        set channel [open ${f}]

        if {[regexp {^\.so (.+)$} [read -nonewline ${channel}] _ target]} {
            # This manpage is a soelim stub.
            ln -sf [file tail ${target}] ${f}
        }

        close ${channel}
    }
}

variant sdl description {Enable SDL support} {
    depends_lib-append      path:lib/pkgconfig/sdl.pc:libsdl

    configure.args-append   --enable-sdl

    post-destroot {
        xinstall -m 0644 ${worksrcpath}/docs/README.SDL ${destroot}${docdir}
    }
}

livecheck.name      ${my_name}
livecheck.distname  ${my_name}-preview
