# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id$

PortSystem              1.0

name                    mapm3
version                 3.0
revision                3
platforms               darwin
maintainers             ryandesign openmaintainer
categories              science
description             cli tool for calculating Quantitative Trait Loci
long_description        ${name} is a ${description}.
master_sites            http://www.broadinstitute.org/ftp/distribution/software/mapmaker3/
homepage                [lindex ${master_sites} 0]

distname                ${name}-source
extract.suffix          .tar.Z
checksums               md5 8aa7a061d32a49c8704c1a5c4b31aa2d

extract.mkdir           yes
extract.cmd             uncompress
extract.pre_args        -c
extract.post_args       | tar -C ${worksrcpath} -xf -

patchfiles              patch-iolib.h \
                        patch-xmapmaker \
                        patch-Makefile \
                        patch-system.h \
                        patch-xqtl

post-patch {
    reinplace "s|^DIR= /usr/local/bin|DIR= ${prefix}/bin|g" "${worksrcpath}/Makefile"
}

use_configure           no

pre-destroot {
    reinplace "s|^DIR= ${prefix}/bin|DIR= ${destroot}${prefix}/bin|g" "${worksrcpath}/Makefile"
}

post-destroot {
    xinstall -d ${destroot}${prefix}/libexec/${name}
    foreach prog {mapmaker qtl} {
        move ${destroot}${prefix}/bin/${prog} ${destroot}${prefix}/libexec/${name}
        xinstall -m 755 ${filespath}/wrapper.in ${destroot}${prefix}/bin/${prog}
        reinplace "s%@PREFIX@%${prefix}%g" ${destroot}${prefix}/bin/${prog}
    }
}

variant large_datasets {
    post-patch {
        reinplace \
            "s|^SYS= -D_SYS_DARWIN -DUSE_RAND48|SYS= -D_SYS_DARWIN -DUSE_RAND48 -D_BIG_DATASETS|g" \
            "${worksrcpath}/Makefile"
    }
}

livecheck.type          none