# $Id: Portfile 59075 2009-10-09 11:10:01Z jmr@macports.org $

PortSystem 1.0

name             upx
version          3.04
revision         1
categories       archivers
maintainers      gmail.com:cedric.luthi
description      compress or expand executable files
long_description UPX is a free, portable, extendable, high-performance \
                 executable packer for several different executable formats
homepage         http://upx.sourceforge.net/
platforms        darwin
master_sites     ${homepage}/download/

distname         ${name}-${version}-src
use_bzip2        yes
checksums        [suffix ${distname}] \
                 md5     68d662b1f831335460f9bfdbf632c6ce \
                 sha1    76e509efb52e1b891e929601f7cb8acbe349445e \
                 rmd160  066103c97aa3a624af2903f3e23fb0fe952bffb7

patchfiles       patch-p_mach.cpp

universal_variant no
use_configure    no
build.env        CPPFLAGS="-I${prefix}/include" LDFLAGS="-L${prefix}/lib"

depends_lib      port:ucl port:zlib

# pod2man, pod2text, and pod2html are used to generate documentation
depends_build    bin:pod2man:perl5 \
                 bin:pod2text:perl5 \
                 bin:pod2html:perl5

post-configure {
    # Ensure that the correct compiler is used
    reinplace "s|CXX = .*|CXX = ${configure.cxx}|" ${worksrcpath}/src/Makefile
}

destroot {
    xinstall -m 755 ${worksrcpath}/src/upx.out ${destroot}${prefix}/bin/upx

    xinstall -m 644 ${worksrcpath}/doc/upx.1 ${destroot}${prefix}/share/man/man1

    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath}/doc upx.doc upx.html ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} BUGS COPYING LICENSE NEWS PROJECTS README README.1ST README.SRC THANKS TODO ${destroot}${prefix}/share/doc/${name}
}

variant lzma description {Support LZMA compression} {
    set lzma-distfile [suffix lzma465]
    master_sites-append sourceforge:sevenzip:lzma
    distfiles-append    ${lzma-distfile}:lzma
    checksums-append    ${lzma-distfile} \
                        md5     29d5ffd03a5a3e51aef6a74e9eafb759 \
                        sha1    5ec1c4606fec88c770a9712073e83916f8aed173 \
                        rmd160  70953d4ee8542addf566953e0ed62e9c75a016b5
    build.env-append    UPX_LZMADIR=${workpath}
}

livecheck.type  regex
livecheck.url   ${homepage}
livecheck.regex Version (\\d(\\.\\d+)*)
