# -*- 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.1 v
revision            0
github.tarball_from archive

categories          multimedia
platforms           darwin
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  c14ed61ed903f250a6600176e024259fcce7b622 \
                    sha256  beaa5050a3c45faa77cedc70ad13d88ef26b74d29d52f512b7708671e037d24d \
                    size    459749 \
                    ${name}-server-v${version} \
                    rmd160  557c6120412ea0c841920e9cb4f6a6f255a7e200 \
                    sha256  958f0944a62f23b1f33a16e9eb14844c1a04b882ca175a738c16d23cb22b86c0 \
                    size    90640

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}
