# $Id: Portfile 57375 2009-09-10 08:16:41Z ryandesign@macports.org $

PortSystem      1.0

name            dact
version         0.8.41
categories      archivers
platforms       darwin
maintainers     nomaintainer
description     dynamic adaptive compression tool

long_description \
    DACT attempts to create very efficient compressed files by \
    attempting to use many different algorithms on each block until it \
    finds the best for every block in the file.

homepage        http://www.rkeene.org/oss/dact/
master_sites    http://www.rkeene.org/files/oss/dact/release/

checksums       md5 f6b33e18e9680c08835e93f8673dea8d \
                sha1 a87db20ae7bf4ffd1b5d37c7e3be70c84661e379 \
                rmd160 015544501df128da869f837b64579de53028a163

post-patch {
	# checking how to create shared objects... cant
	# configure: error: We are unable to make shared objects.

	reinplace "s/ -bind_at_load//" ${worksrcpath}/configure

	# Loadable objects are bundles on OS X

	reinplace "s/=\\.so/=\\.bundle/g" ${worksrcpath}/Makefile.in
	reinplace -E "s/\[\[:<:\]\]so\[\[:>:\]\]/bundle/g" \
        ${worksrcpath}/Makefile.in \
        ${worksrcpath}/Makefile.dep
	reinplace -E "/AS_MODULE/s/(SHOBJLDFLAGS)/\\1:dynamiclib=bundle/" \
        ${worksrcpath}/Makefile.in
	reinplace -E "/for/s/\\(MODS\\)/(ALGO:.c=.bundle)/" ${worksrcpath}/Makefile.in

	# ld: common symbols not allowed with MH_DYLIB output format with the -multi_module option
	# module_shr.o definition of common _modules (size 1024)
	# net_shr.o definition of common _dact_urls (size 3072)
	# ui_shr.o definition of common _dact_ui_statusvar (size 128)

	reinplace -E "s/^(void)/static \\1/" ${worksrcpath}/module.c
	reinplace -E "/^extern void/d" ${worksrcpath}/module.h
	reinplace -E "s/^(struct.*;)\$/static \\1/" ${worksrcpath}/net.c
	reinplace -E "s/^(char.*;)\$/static \\1/" ${worksrcpath}/ui.c
}

depends_lib     port:libmcrypt \
                port:zlib \
                port:bzip2 \
                port:lzo

configure.args  --mandir=${prefix}/share/man \
                --disable-chkvers

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

post-destroot {
    system "install_name_tool -id ${prefix}/lib/lib${name}.dylib \
        ${destroot}${prefix}/lib/lib${name}.dylib"

    set docdir ${prefix}/share/doc/${name}-${version}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} AUTHORS ChangeLog LICENSE README TODO TODO.ideas \
        ${destroot}${docdir}
}

# gcc: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags
universal_variant   no

livecheck.type  regex
livecheck.url   ${homepage}
livecheck.regex ${name}-(\\d+(?:\\.\\d+)*)
