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

# Only to provide a wrapper:
legacysupport.newest_darwin_requires_legacy 0

name                    clipboard
github.setup            Slackadays Clipboard 0.10.0
revision                0
categories              sysutils
maintainers             {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
license                 GPL-3
description             Smart clipboard manager
long_description        {*}${description}
homepage                https://getclipboard.app
checksums               rmd160  37b58725e2de29061514b9c33c9498b547dc43ea \
                        sha256  741717ee505a7852fab5c69740b019e2b33f81d948232894ce294ed0a55e70fb \
                        size    31623894
github.tarball_from     archive

compiler.cxx_standard   2023

# cb(64843) malloc: *** error for object 0xa00a6754: pointer being freed was not allocated
legacysupport.redirect_bins cb

# https://github.com/Slackadays/Clipboard/issues/230
patchfiles-append       0001-CMakeLists-do-not-use-clang-flag-with-gcc.patch

# https://github.com/Slackadays/Clipboard/issues/232
if {${os.platform} eq "darwin" && ${os.major} < 11} {
    # TODO: review updates here: https://github.com/Slackadays/Clipboard/issues/231
    patchfiles-append   0002-macos.mm-compat-code.patch
    # cb-orig[66140:60f] *** __NSAutoreleaseNoPool(): Object 0x30071a0
    # of class NSCFData autoreleased with no pool in place - just leaking
    patchfiles-append   0003-Fix-NSAutoreleaseNoPool-errors.patch
}

depends_build-append    path:bin/pkg-config:pkgconfig

platform darwin {
    configure.args-append \
                        -DNO_WAYLAND=1 \
                        -DNO_X11=1
}

if {[string match *gcc* ${configure.compiler}] && ${configure.build_arch} in [list arm i386 ppc]} {
    configure.ldflags-append \
                        -latomic
}
