# -*- 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
PortGroup           cmake 1.1
PortGroup           github 1.0

name                libbtbb
categories          devel net security
description         Bluetooth baseband decoding library.
long_description    Bluetooth baseband decoding library, forked from the GR-Bluetooth project. \
                    It can be used to extract Bluetooth packet and piconet information \
                    from Ubertooth devices as well as GR-Bluetooth/USRP.
license             GPL-2
maintainers         nomaintainer

subport             ${name}-devel {}

if {${subport} eq "${name}"} {
    conflicts       ${name}-devel

    github.setup    greatscottgadgets libbtbb 2020-12-R1
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    revision        2
    checksums       rmd160  eca69c16710e4bf793cccfc722101e015a95b0e9 \
                    sha256  aa0588f21701156ccbd6b388fafe63225b41dd5b37b390f6c0ed3504d259847a \
                    size    308473

} elseif {${subport} eq "${name}-devel"} {
    conflicts       ${name}

    github.setup    greatscottgadgets libbtbb f0fe1768b080b1333a5357e8308d900e1273ec7f
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    version         2022-08-26
    revision        2
    checksums       rmd160  82d6f97e4070ec7f14b64d3d21063c3b4d82fd9f \
                    sha256  daa64b8a746f87fb6a6f6e6c589ee251f98454d9b0093b665f883446b49d047f \
                    size    310865
}

patchfiles          patch-python-pcaptools-cmake.diff

post-patch {
    reinplace {s|cmake_minimum_required(VERSION 2\.8)|cmake_minimum_required(VERSION 3.0)|} \
        ${worksrcpath}/CMakeLists.txt
    # version from pcaptools/setup.py
    reinplace {s|project(btbb-python)|project(btbb-python VERSION 0.8)|} \
        ${worksrcpath}/python/CMakeLists.txt
    reinplace {s|${PACKAGE_VERSION}|${PROJECT_VERSION}|} \
        ${worksrcpath}/python/pcaptools/setup.py.in
    reinplace "s|#!/usr/bin/env python3|#!${configure.python}|" \
        ${worksrcpath}/python/pcaptools/btaptap
}

set py_ver          3.14
set py_ver_nodot    [string map {. {}} ${py_ver}]

depends_build-append \
                    port:python${py_ver_nodot} \
                    port:py${py_ver_nodot}-setuptools

depends_lib-append  \
                    port:python${py_ver_nodot}

# cc1: error: unrecognized command line option "-std=gnu90"
compiler.blacklist-append *gcc-4.*

configure.args      -DPython3_ROOT_DIR=${frameworks_dir}/Python.framework/Versions/${py_ver}
configure.python    ${prefix}/bin/python${py_ver}

platform darwin powerpc {
    # Needed for Rosetta
    compiler.blacklist-append clang
}
