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

github.setup            fuzziqersoftware phosg e1bd000
github.tarball_from     archive

# blacklisting to select C++20 capable compilers
compiler.blacklist-append {clang < 1300}
compiler.cxx_standard   2020

version                 2023.03.04
revision                0
categories              devel
maintainers             {alum.wpi.edu:arno+macports @fracai} openmaintainer
license                 MIT

description             Phosg is a basic C++ wrapper library around some common C routines.
long_description        {*}${description}

checksums               rmd160  526fb52a0eadbb3e33da6e2711c4c43afca04eda \
                        sha256  802170acf4b8bae5383183c9361812d5309cb3e79d703e365b96feffe5d776cd \
                        size    147998

set pyver               3.11
set python_version      [string index ${pyver} 0][string range ${pyver} 2 end]

patchfiles              CMakeLists-txt.diff

# https://github.com/fuzziqersoftware/phosg/pull/23
if {${os.platform} eq "darwin" && ${os.major} < 20} {
    patchfiles-append   0001-Encoding.hh-define-__STDC_FORMAT_MACROS.patch \
                        0002-Image.hh-define-__darwin_ssize_t.patch \
                        0003-Network.cc-add-missing-cstring-header.patch \
                        0004-CMakeLists-fix-libatomic-for-macOS-ppc.patch \
                        0005-Filesystem-replacement-for-fmemopen.patch
}

depends_build-append    port:python${python_version}

configure.args-append   -DPYTHON_EXECUTABLE=${prefix}/bin/python${pyver}

pre-test {
    # Test infrastructure uses /bin/ps, which is forbidden by sandboxing
    append portsandbox_profile " (allow process-exec (literal \"/bin/ps\") (with no-profile))"
}

# Several tests fail on PPC: https://github.com/fuzziqersoftware/phosg/issues/24
test.run                yes
test.cmd                ctest
