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

# needed for clock_gettime and static_assert to work on older OS X versions
legacysupport.newest_darwin_requires_legacy 15

github.setup        Genymobile scrcpy 5.0.1 v
revision            0
github.tarball_from archive

categories          multimedia
license             Apache-2
maintainers         {bochtler.io:macports @MarcelBochtler} \
                    openmaintainer
description         Display and control your Android device
long_description    This application provides display and control of Android \
                    devices connected on USB (or over TCP/IP). It does not \
                    require any root access.

# scrcpy-server is downloaded from github releases while the client is downloaded from the Github archive.
master_sites-append https://github.com/Genymobile/${name}/releases/download/v${version}/:bootstrap
extract.only        ${distfiles}
distfiles-append    ${name}-server-v${version}:bootstrap

checksums           ${distname}${extract.suffix} \
                    rmd160  09a74f7028f7dc446a56392df1e56dc82667f079 \
                    sha256  a24b996ac23d0f674d3237c00b39a97829d8acbe9e1657a6c216fd51ea488ee5 \
                    size    513788 \
                    ${name}-server-v${version} \
                    rmd160  7f589e91fd1b983f1e34d41dbeed7f7f63315bdb \
                    sha256  764eb6f79811d5211fe9df341120882ba9994c7a61b897d7bf3fb662e53bc536 \
                    size    733930

depends_build-append \
                    port:pkgconfig

depends_lib-append  path:lib/libavcodec.dylib:ffmpeg \
                    port:SDL3 \
                    port:libusb

depends_run-append  port:android-platform-tools

configure.args-append \
                    --buildtype release \
                    --strip \
                    -Db_lto=true \
                    -Dprebuilt_server=${distpath}/${name}-server-v${version}

compiler.c_standard 2011
# Work around cfm: fatal error: 'stdatomic.h' file not found
# https://trac.macports.org/ticket/60429
compiler.blacklist-append {clang < 701}
