# $Id: Portfile 96489 2012-08-12 08:13:10Z ryandesign@macports.org $

PortSystem        1.0

name              pbzip2
version           1.1.8
set branch        [join [lrange [split ${version} .] 0 1] .]
categories        archivers
platforms         darwin
maintainers       ram openmaintainer
license           Permissive
installs_libs     no

description       parallel bzip2
long_description  PBZIP2 is a parallel implementation of the bzip2 \
  block-sorting file compressor that uses pthreads and achieves \
  near-linear speedup on SMP machines.

homepage          http://compression.ca/pbzip2/
master_sites      https://launchpad.net/pbzip2/${branch}/${version}/+download/

depends_lib       port:bzip2

checksums         rmd160 db138cdab6b2e78c12b16805a486c073a9bd00c7 \
                  sha256 d2da7e65d2a2ba5426d6d9bcd15d86cc5f90038efabd5dbc1ef9bded21371f53

configure {
  reinplace "s|man|share/man|" ${worksrcpath}/Makefile
}

variant universal {}

# yes, the Makefile actually requires $(CC) to compile C++
build.args-append CC=${configure.cxx} \
                  CFLAGS=\"${configure.cxxflags} [get_canonical_archflags cxx]\" \
                  LDFLAGS=\"${configure.ldflags} -lbz2\"

destroot.destdir  PREFIX=${destroot}${prefix}

post-destroot {
  delete ${destroot}${prefix}/bin/pbunzip2
  delete ${destroot}${prefix}/bin/pbzcat
  ln -s pbzip2 ${destroot}${prefix}/bin/pbunzip2
  ln -s pbzip2 ${destroot}${prefix}/bin/pbzcat
  set docdir ${prefix}/share/doc/${name}-${version}
  xinstall -d ${destroot}${docdir}
  xinstall -m 0644 -W ${worksrcpath} AUTHORS COPYING ChangeLog README \
    ${destroot}${docdir}
}

livecheck.type    regex
livecheck.url     https://launchpad.net/pbzip2
livecheck.regex   {pbzip2-(\d+(?:\.\d+)*).tar.gz}
