# -*- 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.10
revision            0
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  397c3a4052912bb52e06b2801c02a114bc4e4787 \
                    sha256  d99672337c06b455884ac14418d562701143141d0d7e46af476817c2ae3efe37 \
                    size    184556

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
    xinstall -d ${destroot}${prefix}/${haskell_cabal.datadir}
    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}
        }
    }
}
