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

github.setup        Corvusoft restbed 5.0.0
revision            0
categories          devel
license             AGPL-3
maintainers         nomaintainer
description         Framework that brings asynchronous RESTful functionality to C++14 applications.
long_description    Restbed is a comprehensive and consistent programming model for building applications \
                    that require seamless and secure communication over HTTP, with the ability to model \
                    a range of business processes, designed to target mobile, tablet, desktop \
                    and embedded production environments.
homepage            https://www.corvusoft.co.uk
checksums           rmd160  ae716b5b0efbdb40d2035ada1d217c3aa022f2d1 \
                    sha256  1f4bec850b84080cb8259945dd73df365f2601f291521d0cb1542f3604244b3c \
                    size    104501
github.tarball_from archive

depends_lib-append  path:${prefix}/share/pkgconfig/asio.pc:asio

patchfiles          patch-CMakeLists.diff

compiler.cxx_standard   2023

configure.args-append \
                    -DBUILD_IPC=OFF \
                    -DBUILD_SSL=OFF \
                    -DBUILD_TESTS=OFF

# https://github.com/Corvusoft/restbed/issues/557
if {[string match *gcc* ${configure.compiler}] && ${configure.build_arch} in [list arm i386 ppc]} {
    configure.ldflags-append \
                    -latomic
}

pre-destroot {
    xinstall -d ${destroot}${prefix}/include/${name}
}

post-destroot {
    # Fix permissions; setting to 0644 does not have a needed effect.
    file attributes ${destroot}${prefix}/include/${name} -permissions 0755
    # Remove unneeded subprefix; we install headers in ${prefix}/include/restbed:
    fs-traverse h ${destroot}${prefix}/include/${name} {
        if {[file isfile ${h}]} {
            reinplace -q "s,corvusoft/,,g" ${h}
        }
    }
}
