# $Id: Portfile 94870 2012-07-01 21:39:37Z mww@macports.org $

PortSystem	1.0

name		ha
version		0.999
revision    1
categories	archivers sysutils
platforms	darwin
license		GPL-2
description	The \"HA\" archiver, based on arithmetic/Markov coder.
maintainers	crazic.ru:jc
homepage	ftp://ftp.kiarchive.ru/pub/unix/arcers/

long_description ${description}

distfiles	ha0999.tgz
master_sites	ftp://ftp.kiarchive.ru/pub/unix/arcers/

checksums   md5 77f3266a451712bec55d60df67f61486 \
            sha1 8dd106748619772f988ee0bce59937a4de1677ed \
            rmd160 41b52392267551f834b58e0a4b69b89e813c8bd6

extract.dir ${worksrcpath}

pre-extract	{
    file mkdir ${worksrcpath}
}

post-patch {
    reinplace -E "s|(malloc.h)|malloc/\\1|" \
        ${worksrcpath}/c/hsc.c \
        ${worksrcpath}/c/asc.c \
        ${worksrcpath}/c/cpy.c
}

configure {
    reinplace -E "/^CFLAGS/s|\$| [join ${configure.cflags} " "]|" ${worksrcpath}/makefile.nix
    reinplace -E "/^LDFLAGS/s|\$| [join ${configure.ldflags} " "]|" ${worksrcpath}/makefile.nix
}

build.target
build.args	-f makefile.nix

destroot {
    xinstall ${worksrcpath}/ha ${destroot}${prefix}/bin

    set docdir ${prefix}/share/doc/${name}-${version}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} copying readme ${destroot}${docdir}
}

