# -*- 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 120151 2014-05-17 01:03:05Z ryandesign@macports.org $

PortSystem          1.0

name                cppcheck
version             1.65
categories          devel
license             GPL-3
platforms           darwin
maintainers         xythobuz.de:xythobuz

description         Static analysis of C and C++ code.

long_description    Cppcheck is an analysis tool for C and C++ code. Unlike \
                    compilers and many other analysis tools, we do not detect \
                    syntax errors. Cppcheck only detects the types of bugs that \
                    the compilers normally fail to detect. The goal is no false \
                    positives.

homepage            http://cppcheck.sourceforge.net/
master_sites        sourceforge:project/cppcheck/cppcheck/${version}

checksums           rmd160  17a7d54a61faea7a3783a94b18301bce18b1b7ec \
                    sha256  f684ae47c4556eea87d04f54e3eb9782fca2ba9ff43adaa29a9271177ee6d7ea

depends_build       port:libxslt \
                    port:docbook-xsl

depends_lib         port:pcre

use_configure       no

variant universal {}

build.args          CXX="${configure.cxx} [get_canonical_archflags cxx]" \
                    HAVE_RULES=yes CFGDIR=${prefix}/share/cppcheck \
                    DB2MAN=${prefix}/share/xsl/docbook-xsl/manpages/docbook.xsl
build.target        all man

test.run            yes
test.target         test

destroot.args       PREFIX=${prefix}

post-destroot {
    xinstall -m 444 ${worksrcpath}/cppcheck.1 ${destroot}${prefix}/share/man/man1
    xinstall -d ${destroot}${prefix}/share/cppcheck
    copy ${worksrcpath}/cfg/gtk.cfg ${destroot}${prefix}/share/cppcheck/gtk.cfg.dist
    copy ${worksrcpath}/cfg/posix.cfg ${destroot}${prefix}/share/cppcheck/posix.cfg.dist
    copy ${worksrcpath}/cfg/qt.cfg ${destroot}${prefix}/share/cppcheck/qt.cfg.dist
    copy ${worksrcpath}/cfg/std.cfg ${destroot}${prefix}/share/cppcheck/std.cfg.dist
    copy ${worksrcpath}/cfg/windows.cfg ${destroot}${prefix}/share/cppcheck/windows.cfg.dist
}

post-activate {
    if {![file exists ${prefix}/share/cppcheck/gtk.cfg]} {
        copy ${prefix}/share/cppcheck/gtk.cfg.dist ${prefix}/share/cppcheck/gtk.cfg
    }

    if {![file exists ${prefix}/share/cppcheck/posix.cfg]} {
        copy ${prefix}/share/cppcheck/posix.cfg.dist ${prefix}/share/cppcheck/posix.cfg
    }

    if {![file exists ${prefix}/share/cppcheck/qt.cfg]} {
        copy ${prefix}/share/cppcheck/qt.cfg.dist ${prefix}/share/cppcheck/qt.cfg
    }

    if {![file exists ${prefix}/share/cppcheck/std.cfg]} {
        copy ${prefix}/share/cppcheck/std.cfg.dist ${prefix}/share/cppcheck/std.cfg
    }

    if {![file exists ${prefix}/share/cppcheck/windows.cfg]} {
        copy ${prefix}/share/cppcheck/windows.cfg.dist ${prefix}/share/cppcheck/windows.cfg
    }
}
