# -*- 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                ninka
version             1.3
categories          devel
platforms           darwin
maintainers         ryandesign openmaintainer
license             GPL-2+

description         license identification tool
long_description    \
    Ninka is a lightweight license identification tool for source code. It is \
    sentence-based, and provides a simple way to identify open source licenses in a \
    source code file. It is capable of identifying several dozen different licenses \
    (and their variations)
homepage            http://ninka.turingmachine.org
master_sites        http://ninka.turingmachine.org/download
depends_lib         bin:perl:perl5
use_bzip2           yes
supported_archs     noarch

checksums           rmd160  84925c82173d54e036b76a6639d018055a033b5c \
                    sha256  fb9c17bcea2c1c2f77ae0adfe1a95adc7778c55041249fba89f2ad5fb75374fb

post-extract {
    # Fix incorrect permissions in distfile, and remove backup files that
    # were left in the distfile.
    fs-traverse item ${workpath} {
        if {[string index ${item} end] eq "~"} {
            delete ${item}
        } else {
            file attributes ${item} -permissions a+r
        }
    }
}

set datadir         ${prefix}/share/${name}
set docdir          ${prefix}/share/doc/${name}

patchfiles          patch-ninka.pl.diff
post-patch {
    reinplace "s|%%DATADIR%%|${datadir}|" ${worksrcpath}/ninka.pl
}

use_configure       no
build {}
destroot {
    xinstall ${worksrcpath}/ninka.pl ${destroot}${prefix}/bin/ninka

    xinstall -d ${destroot}${datadir}
    set directoriesToCopy [list comments extComments filter matcher senttok splitter]
    foreach directory ${directoriesToCopy} {
        copy ${worksrcpath}/${directory} ${destroot}${datadir}
    }

    xinstall -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} ChangeLog README.txt ${destroot}${docdir}
}