# -*- 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

name                flawfinder
version             2.0.19
revision            2
categories          devel
license             GPL-2+
maintainers         {khindenburg @kurthindenburg} openmaintainer

description         Examines C/C++ source code for security flaw
long_description \
    Program that examines source code and reports possible  \
    security weaknesses (``flaws'') sorted by risk level.   \
    It's very useful for quickly finding and removing at    \
    least some potential security problems before a program \
    is widely released to the public.

homepage            https://dwheeler.com/flawfinder/
platforms           any
supported_archs     noarch
master_sites        ${homepage}

checksums           rmd160  df7d640994ae690eed26d68cfd001e95f8016be9 \
                    sha256  fe550981d370abfa0a29671346cc0b038229a9bd90b239eab0f01f12212df618 \
                    size    260817

set python_branch   3.12
set python_version  [string map {. ""} ${python_branch}]

depends_lib         port:python${python_version}

use_configure       no
build.target

post-patch {
    # A simple quick way to handle this w/o patch
    reinplace "s|^PYTHON=python|PYTHON=${prefix}/bin/python${python_branch}|" ${worksrcpath}/test/makefile
    reinplace "s|^PYTHON2=python2|PYTHON2=${prefix}/bin/python${python_branch}|" ${worksrcpath}/test/makefile
    reinplace "s|^PYTHON3=python3|PYTHON3=${prefix}/bin/python${python_branch}|" ${worksrcpath}/test/makefile
}

destroot {
    reinplace       "s|#!/usr/bin/env python|#!${prefix}/bin/python${python_branch}|" ${worksrcpath}/${name}.py
    xinstall -m 755 ${worksrcpath}/${name}.py ${destroot}${prefix}/bin
        xinstall -m 644 ${worksrcpath}/${name}.1 \
        ${destroot}${prefix}/share/man/man1
}

depends_test-append port:py${python_version}-setuptools
test.run            yes
test.target         check

notes "The executable name has changed to ${name}.py"
