# -*- 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           compiler_blacklist_versions 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 3.2 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  077662193dd933a1a3c164d91aae8229b79d5a6a \
                    sha256  9902a3afd75f9a5da64898ac06ffaf77065dd713a58f47a408630b98f03ba9ce \
                    size    464967 \
                    ${name}-server-v${version} \
                    rmd160  870d556649797a36e56a6af5230e832d2f260b9e \
                    sha256  b920e0ea01936bf2482f4ba2fa985c22c13c621999e3d33b45baa5acfc1ea3d0 \
                    size    90888

depends_build-append \
                    port:pkgconfig

depends_lib-append  path:lib/libavcodec.dylib:ffmpeg \
                    port:libsdl2 \
                    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}
