# -*- 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

PortSystem          1.0
PortGroup           haskell_cabal 1.0

name                hlint
version             3.8
revision            1
categories          devel haskell
maintainers         nomaintainer
license             GPL-3
platforms           macosx
homepage            https://github.com/ndmitchell/hlint

description         A tool for suggesting possible improvements to \
                    Haskell code.

long_description    HLint is a tool for suggesting possible \
                    improvements to Haskell code.  These suggestions \
                    include ideas such as using alternative functions, \
                    simplifying code and spotting redundancies.

checksums           rmd160  fbd7716d72f07e6666ac7455269c8e0b0398dc18 \
                    sha256  a8f236b62be7f28ff2900745a227a29c50b68c9f33c849c678b5c564519bbd74 \
                    size    183849

post-extract {
    # Fix for cabal data-files hardcoded path in binary
    # See:
    # https://github.com/commercialhaskell/stack/issues/848
    # https://github.com/commercialhaskell/stack/issues/4857
    # https://github.com/haskell/cabal/issues/462
    # https://github.com/haskell/cabal/issues/3586
    xinstall -m 0644 -W ${worksrcpath} \
        ${filespath}/Paths_NAME.hs ./src/Paths_${name}.hs

    reinplace "s|@PREFIX@|${prefix}|g" \
        ${worksrcpath}/src/Paths_${name}.hs
    reinplace "s|@NAME@|${name}|g" \
        ${worksrcpath}/src/Paths_${name}.hs
    reinplace -E "s|(Version\[\[:space:\]\]+)\\\[\[\[:digit:\]\]+(,\[\[:digit:\]\]+){1,4}\\\]|\\1\[[join [split ${version} .] ,]\]|" \
        ${worksrcpath}/src/Paths_${name}.hs
}

build.target        exe:hlint

post-destroot {
    # install the manpage and data-files
    foreach f [glob ${worksrcpath}/data/*] {
        if {[file tail ${f}] eq "${name}.1"} {
            xinstall -m 0644 ${f} \
                    ${destroot}${prefix}/share/man/man1
        } else {
            xinstall -m 0644 ${f} \
                ${destroot}${prefix}/${haskell_cabal.datadir}
        }
    }
}
