# -*- 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: Portfile 114431 2013-12-08 09:48:42Z and.damore@macports.org $

PortSystem          1.0

name                ninka
version             1.0-pre2
revision            1
categories          devel
platforms           darwin
license             GPL-3
maintainers         nomaintainer
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  856573164bb105abf43a0c0140550447a3be3db0 \
                    sha256  df6d4c7efe173fca70efe019deb21bf7b32a969a662cf6880c17aaba9a7144ce

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 -m 755 ${worksrcpath}/ninka.pl ${destroot}${prefix}/bin/ninka
    set directoriesToCopy [list comments extComments filter matcher senttok splitter]
    foreach directory ${directoriesToCopy} {
        xinstall -d   -m 755 ${destroot}${datadir}/${directory}
        eval xinstall -m 644 [glob ${worksrcpath}/${directory}/*] ${destroot}${datadir}/${directory}
    }
    
    foreach aFile [glob ${destroot}${datadir}/*/*.pl] {
        file attributes $aFile -permissions 0755
    }

    xinstall -d -m 755 ${destroot}${docdir}
    xinstall    -m 644 ${worksrcpath}/README ${destroot}${docdir}
    
    move ${destroot}${datadir}/comments/README ${destroot}${docdir}/README-comments
    move ${destroot}${datadir}/splitter/README ${destroot}${docdir}/README-splitter
    file attributes ${destroot}${docdir}/README-comments -permissions 644
    file attributes ${destroot}${docdir}/README-splitter -permissions 644
}
