# -*- 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           cmake   1.0

epoch               2
github.setup        FreeRDP FreeRDP 2.0.0-rc4
categories          net
platforms           darwin
license             Apache
maintainers         nomaintainer
description         A Remote Desktop Protocol implementation
long_description    FreeRDP is a free implementation of the Remote Desktop Protocol (RDP), released \
                    under the Apache license.

homepage            http://www.freerdp.com

checksums           rmd160  8c492959eca7d8621dbb243a94cd1b12d14529f8 \
                    sha256  5bdaffd8bee655e8471120438c89e84143902cea38e29ecd6c07cc1715e8f91f \
                    size    6614847

depends_build-append \
                    port:pkgconfig \
                    port:libxslt \
                    port:docbook-xsl-nons

depends_lib-append  port:xorg-libX11 \
                    port:xorg-libXcursor \
                    port:xorg-libXext \
                    port:xorg-libXi \
                    port:xorg-libXinerama \
                    port:xorg-libXv \
                    port:xrender \
                    port:zlib \
                    path:lib/libssl.dylib:openssl

post-patch {
    if {[string match "*gcc*" ${configure.compiler}]} {
        reinplace "s:-fobjc-nonfragile-abi::" \
            ${worksrcpath}/client/Mac/cli/CMakeLists.txt \
            ${worksrcpath}/client/Mac/CMakeLists.txt
    }
}

cmake.out_of_source yes

# optional ffmpeg support is disabled by default

configure.args-append \
                    -DWITH_ALSA=OFF \
                    -DWITH_CCACHE=OFF \
                    -DWITH_FFMPEG=OFF \
                    -DWITH_X11=ON

# ffmpeg only supports VDA (video hardware acceleration, mostly H264) on 10.6.3+ (#48397)
if {${os.major} > 10 || (${os.major} == 10 && ${os.minor} >= 3)} {
    configure.args-replace  -DWITH_FFMPEG=OFF -DWITH_FFMPEG=ON
    depends_lib-append      path:lib/libavcodec.dylib:ffmpeg
}