# -*- 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

PortSystem          1.0

name                zip
version             3.00
revision            1

categories          archivers
license             BSD
installs_libs       no
platforms           darwin freebsd
maintainers         nomaintainer

description         compression utility
long_description    Zip is a compression/decompression utility. It is \
                    different from gzip in that it allows packing multiple \
                    files into a single archive (without the assistance of \
                    tar). It is compatible with pkzip, pkunzip, and other \
                    Windows zip utilities.

homepage            http://infozip.sourceforge.net/
master_sites        ftp://ftp.info-zip.org/pub/infozip/src/

distname            ${name}30
extract.suffix      .tgz

checksums           rmd160  1fc99daf3e36494ba392c7514a714fe3d258d232 \
                    sha256  f0e8bb1f9b7eb0b01285495a2699df3a4b766784c1765a8f1aeedf63c0806369 \
                    size    1118845

depends_lib         port:bzip2

patchfiles          configure.patch

set args            "-f unix/Makefile"

configure.cmd       ${build.cmd}
configure.dir       ${worksrcpath}
configure.pre_args  CC=\"\${CC}\" flags \
                    ${args}

# The automake-specific --disable-dependency-tracking is added to all configure arguments
# when +universal is enabled -- we work around this behavior by removing the flag
# explicitly.
configure.universal_args-delete --disable-dependency-tracking

build.target        generic
build.args          ${args}

destroot.args       ${args} \
                    BINDIR=${destroot}${prefix}/bin \
                    MANDIR=${destroot}${prefix}/share/man/man1

post-destroot {
    set docdir ${prefix}/share/doc/${name}-${version}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} BUGS CHANGES LICENSE README TODO WHATSNEW \
        ${destroot}${docdir}
}

variant universal {
    configure.args  "LOCAL_ZIP=\"${configure.universal_cflags}\""

    post-patch {
        reinplace -E "s|(LFLAGS1=')|\\1${configure.universal_ldflags}|" \
            ${worksrcpath}/unix/configure
    }

    post-configure {
        reinplace "s/-DASMV -DASM_CRC//" ${worksrcpath}/flags
        reinplace "s/match.o//g" ${worksrcpath}/flags
        reinplace "s/crc_i386.o//g" ${worksrcpath}/flags
    }
}

livecheck.type  regex
livecheck.url   ${homepage}
livecheck.regex ">Zip.nbsp.(\\d+(?:\\.\\d+)*)<"
