# $Id: Portfile 81015 2011-07-23 05:39:38Z jmr@macports.org $

PortSystem      1.0

name            p7zip
version         9.20.1
revision        1
categories      archivers
# contains unrar code which has a restrictive license
license         LGPL-2.1+ Restrictive/Distributable
maintainers     nomaintainer
platforms       darwin
description     7-Zip implementation

long_description \
    p7zip is a port of 7-Zip, a file archiver with \
    highest compression ratio.

homepage        http://p7zip.sourceforge.net/

master_sites    sourceforge:project/${name}/${name}/${version}
distname        [strsed ${distname} {g/-/_/}]
use_bzip2       yes
distfiles       ${distname}_src_all${extract.suffix}

checksums           md5     bd6caaea567dc0d995c990c5cc883c89 \
                    sha1    1cd567e043ee054bf08244ce15f32cb3258306b7 \
                    rmd160  c3ff2dd12459282b46d9a68ab4af7800ff46039f

patchfiles      patch-install.sh.diff

configure {
    copy -force ${worksrcpath}/makefile.macosx_32bits ${worksrcpath}/makefile.machine
    reinplace "s|CXX=c++ |CXX=${configure.cxx} |g" \
            ${worksrcpath}/makefile.machine
    reinplace "s|CC=cc |CC=${configure.cc} |g" \
            ${worksrcpath}/makefile.machine
    reinplace "s|-m32||g" \
            ${worksrcpath}/makefile.machine
    if {[variant_isset universal]} {
        reinplace "s|\$(LOCAL_FLAGS)|${configure.universal_cflags} \$(LOCAL_FLAGS)|g" \
            ${worksrcpath}/makefile.machine
    }
}

# build 7za, 7z and 7zr
build.target all3

use_parallel_build	yes

destroot.destdir    DEST_HOME=${prefix} \
                    DEST_SHARE_DOC=${prefix}/share/doc/${name}-${version} \
                    DEST_MAN=${prefix}/share/man \
                    DEST_DIR=${destroot}
