# -*- 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 90888 2012-03-17 07:23:08Z jmr@macports.org $

PortSystem      1.0

name            libzzip
set my_name     zziplib
version         0.13.62
set minor       [lindex [split ${version} .] 1]
categories      archivers devel
platforms       darwin
license         LGPL
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:project/zziplib/zziplib${minor}/${version}
distname        ${my_name}-${version}
use_bzip2       yes

checksums       md5 5fe874946390f939ee8f4abe9624b96c \
                sha1 cf8b642abd9db618324a1b98cc71492a007cd687 \
                rmd160 f616e17d874175b628f3955c7bb9501490dd00aa

depends_build   port:pkgconfig \
                port:xmlto

depends_lib     port:zlib

patchfiles      patch-zzip_Makefile.in.diff

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

configure.python    /usr/bin/python
configure.env       ac_cv_path_PAX=":"

post-configure {
    set builddir [glob -dir ${worksrcpath} "Darwin*.d"]
    reinplace -E {s|-arch [a-z0-9_]+||g} \
        ${builddir}/zzip/zziplib-uninstalled.pc \
        ${builddir}/zzip/zziplib.pc
}

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

variant universal {
    configure.env-append ac_cv_sizeof_long="(LONG_BIT/8)"
}

livecheck.type      regex
livecheck.url       http://sourceforge.net/projects/${my_name}/files/${my_name}13/
livecheck.regex     "${my_name}13\/(\\d+(?:\\.\\d+)*)"
