# -*- 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
PortGroup                   cxx11 1.0

name                        cppcheck
version                     1.72
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  62444a704fc0f6a7301aad3c763c297a3d727788 \
                            sha256  459108c81ea607c8bd3da842d83990d6555e0351d0fe4bb21c2c72110274f393

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}

notes                       "If you've updated cppcheck from a previous version," \
                            "you may want to replace the included config files:" \
                            "sudo find ${prefix}/share/cppcheck -type f -name \"*.dist\" -exec bash -c 'f=\"\{\}\"; cp \"\$f\" \"\$\{f%.dist\}\"' \\;"

post-destroot {
    xinstall -m 444 ${worksrcpath}/cppcheck.1 ${destroot}${prefix}/share/man/man1
    xinstall -d ${destroot}${prefix}/share/cppcheck
    copy ${worksrcpath}/cfg/avr.cfg ${destroot}${prefix}/share/cppcheck/avr.cfg.dist
    copy ${worksrcpath}/cfg/cppcheck-cfg.rng ${destroot}${prefix}/share/cppcheck/cppcheck-cfg.rng.dist
    copy ${worksrcpath}/cfg/gnu.cfg ${destroot}${prefix}/share/cppcheck/gnu.cfg.dist
    copy ${worksrcpath}/cfg/gtk.cfg ${destroot}${prefix}/share/cppcheck/gtk.cfg.dist
    copy ${worksrcpath}/cfg/microsoft_sal.cfg ${destroot}${prefix}/share/cppcheck/microsoft_sal.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/sdl.cfg ${destroot}${prefix}/share/cppcheck/sdl.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/avr.cfg]} {
        copy ${prefix}/share/cppcheck/avr.cfg.dist ${prefix}/share/cppcheck/avr.cfg
    }

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

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

    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/microsoft_sal.cfg]} {
        copy ${prefix}/share/cppcheck/microsoft_sal.cfg.dist ${prefix}/share/cppcheck/microsoft_sal.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/sdl.cfg]} {
        copy ${prefix}/share/cppcheck/sdl.cfg.dist ${prefix}/share/cppcheck/sdl.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
    }
}