# $Id: Portfile 86426 2011-10-25 16:16:48Z jmr@macports.org $

PortSystem      1.0

name            lzma
version         4.63
categories      archivers
license         public-domain
platforms       darwin
maintainers     nomaintainer
description     high compression ratio archiver

long_description \
    LZMA is default and general compression method of 7z \
    format in 7-Zip program. LZMA provides high compression \
    ratio and very fast decompression.

homepage        http://www.7-zip.org/sdk.html
master_sites    sourceforge:sevenzip
distname        lzma[strsed ${version} {/\.//}]
use_bzip2       yes

checksums       md5 ad7d7eb5120b500271dcf83af00e2fc1 \
                sha1 36b5fe39014c9f1f114ab4dfbe5768cb20529d3e \
                rmd160 d3506df1996d72be7d4e914c56b5b2e43c5a0b8a

extract.mkdir   yes
post-extract {
    # Convert DOS to UNIX line endings so we can patch
    reinplace "s|\r||g" ${worksrcpath}/CPP/7zip/Compress/LZMA_Alone/makefile.gcc
}

patchfiles      patch-lzma.1 \
                patch-makefile.gcc
post-patch {
    reinplace "s|@CC@|${configure.cc}|g" ${worksrcpath}/CPP/7zip/Compress/LZMA_Alone/makefile.gcc
    reinplace "s|@CXX@|${configure.cxx}|g" ${worksrcpath}/CPP/7zip/Compress/LZMA_Alone/makefile.gcc
}

use_configure   no

build.dir       ${worksrcpath}/CPP/7zip/Compress/LZMA_Alone
build.type      gnu
build.args      -f makefile.gcc

post-install {
    ui_msg "The LZMA SDK program is installed as \"lzma_alone\", to avoid conflict with LZMA Utils"
}

destroot {
    xinstall -s ${worksrcpath}/CPP/7zip/Compress/LZMA_Alone/lzma ${destroot}${prefix}/bin/lzma_alone
    xinstall ${worksrcpath}/lzma.1 ${destroot}${prefix}/share/man/man1/lzma_alone.1

    set docdir ${prefix}/share/doc/${name}-${version}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} history.txt lzma.txt \
        ${destroot}${docdir}
}

livecheck.type  regex
livecheck.regex {(\d+(?:\.\d+)*):}

