# -*- 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 3.3 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  af82fa5a71ec6275bd21fb255e4c2a296150167b \
                    sha256  6636f97f3a5446e3a1c845545108cf692bbd9cdc02cacfda099a2789ca7f6d56 \
                    size    464716 \
                    ${name}-server-v${version} \
                    rmd160  d6468c1eff3785b0f8b4be02bfe957cb9c4dffdb \
                    sha256  351cb2edc7e4c2c75f09a7933fdabcf137be52e2602df154f24ec02db46e9e51 \
                    size    90752

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}
