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

name                xine-lib
version             1.2.13
revision            6
checksums           rmd160  2b1045e3dfe475c92a442f3506ee8b570b73da32 \
                    sha256  5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f \
                    size    5004196

categories          multimedia
# bundled libdvdnav is GPL-2 only but we use MacPorts libdvdnav now
license             GPL-2+
maintainers         {ryandesign @ryandesign} openmaintainer

description         xine-lib is a free multimedia engine, released under the GPL.
long_description    {*}${description}

homepage            https://sourceforge.net/projects/xine/
master_sites        sourceforge:project/xine/xine-lib/${version}
use_xz              yes

depends_build       port:automake \
                    port:libtool \
                    port:optipng \
                    path:bin/pkg-config:pkgconfig \
                    port:xmlto

depends_lib         port:a52dec \
                    port:aalib \
                    port:aom \
                    port:dav1d \
                    port:esound \
                    port:faad2 \
                    path:lib/libavcodec.dylib:ffmpeg \
                    port:flac \
                    port:fontconfig \
                    port:freetype \
                    path:lib/pkgconfig/gdk-pixbuf-2.0.pc:gdk-pixbuf2 \
                    path:lib/pkgconfig/gnutls.pc:gnutls \
                    port:ImageMagick \
                    port:jack \
                    port:libbluray \
                    port:libcaca \
                    port:libcdio \
                    port:libdca \
                    port:libdvdnav \
                    port:libdvdread \
                    port:libGLU \
                    port:libmad \
                    port:libmng \
                    port:libmpcdec \
                    port:libogg \
                    port:libsdl \
                    port:libssh2 \
                    port:libvorbis \
                    path:lib/pkgconfig/vpx.pc:libvpx \
                    port:mesa \
                    port:vcdimager \
                    port:wavpack \
                    port:xorg-libXinerama \
                    port:xorg-libXt \
                    port:xorg-libXvMC \
                    port:xorg-xcb-util

patchfiles-append   dynamic_lookup-11.patch \
                    implicit.patch

post-patch {
    # Use newer config.guess and config.sub to support Apple Silicon.
    set automake_dirs [glob -directory ${prefix}/share automake-*]
    set automake_dir [lindex [lsort -command vercmp $automake_dirs] end]
    copy -force ${automake_dir}/config.guess ${automake_dir}/config.sub \
        ${worksrcpath}
}

# bad register name `%rax'
universal_variant   no

# unsupported inline asm: input constraint with a matching output constraint of incompatible type!
compiler.blacklist  *llvm-gcc-4.2

configure.args      --disable-silent-rules \
                    --disable-wayland \
                    --enable-a52dec \
                    --enable-dvd \
                    --enable-faad \
                    --enable-ffmpeg \
                    --enable-glu \
                    --enable-libjpeg \
                    --enable-libpng \
                    --enable-mad \
                    --enable-mng \
                    --enable-modplug \
                    --enable-opengl \
                    --enable-sftp \
                    --enable-tls \
                    --enable-vpx \
                    --enable-xinerama \
                    --enable-xvmc \
                    --with-dav1d \
                    --with-esound \
                    --with-external-dvdnav \
                    --with-fontconfig \
                    --with-freetype \
                    --with-jack \
                    --with-libaom \
                    --with-libflac \
                    --with-imagemagick \
                    --with-sdl \
                    --with-speex \
                    --with-theora \
                    --with-vorbis \
                    --with-wavpack \
                    --with-x \
                    --with-xcb

# Due to an upstream bug GCC currently cannot build jack for 32-bit targets.
# See: https://github.com/jackaudio/jack2/issues/950
if {[string match *gcc* ${configure.compiler}] && (${configure.build_arch} in [list i386 ppc])} {
    depends_lib-delete      port:jack
    configure.args-delete   --with-jack
}

build.args  V=1

platform darwin {
    patchfiles-append src_xine-engine_Makefile.in.diff

    configure.args-append   --disable-rpath

    if {[string match *64 ${build_arch}]} {
        configure.args-append --build=${build_arch}-apple-${os.platform}${os.version}
    }
}

platform macosx {
    configure.args-append   --enable-macosx-video \
                            --enable-coreaudio
}

livecheck.regex     /${name}-(\[0-9.\]+)${extract.suffix}
