# -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# $Id $

PortSystem          1.0

name                VLC
version             1.0.6

categories          multimedia

maintainers         mnick openmaintainer
description         VLC is a cross-platform media player and streaming server
long_description    VLC media player is a highly portable multimedia player for \
                    various audio and video formats (MPEG-1, MPEG-2, MPEG-4, DivX, \
                    mp3, ogg, ...) as well as DVDs, VCDs, and various streaming protocols. \
                    It can also be used as a server to stream in unicast or multicast \
                    in IPv4 or IPv6 on a high-bandwidth network.
license             GPL

platforms           darwin
conflicts           VLC09

homepage            http://www.videolan.org
master_sites        http://download.videolan.org/pub/videolan/vlc/${version}/
distname            vlc-${version}
use_bzip2           yes

checksums           md5     246a3865ec037f8f5757ef6b973a80fc \
                    sha1    834346a84a71d915440b7741e04b6e02de451786 \
                    rmd160  2185eb418748f2aadfce5e61b7a9de66a62ef2d1

depends_lib     port:lame port:a52dec port:libogg port:flac \
                port:libdca port:libcddb port:libcdio port:libmad \
                port:libvorbis port:libmatroska port:libid3tag \
                port:ncurses port:lua port:libpng port:jpeg \
                port:libdvdplay port:libdvdnav path:lib/libavcodec.dylib:ffmpeg \
                port:gnutls port:taglib port:libxml2 port:faad2 \
                port:live555

pre-fetch {
    if {"darwin" == ${os.platform} && ${os.major} < 9} {
        ui_error "${name} ${version} requires Mac OS X 10.5 or greater, use port 'VLC09' instead"
        return -code error "incompatible Mac OS X version"
    }
}

patchfiles      patch-Makefile.am.diff patch-configure.ac-xcb.diff

use_parallel_build no
use_autoreconf yes
autoreconf.args -fvi

# VLC needs to be compiled with llvm-gcc frontend
configure.compiler llvm-gcc-4.2

build.target    all
destroot.target install

livecheck.url   http://download.videolan.org/pub/videolan/vlc/
livecheck.regex <a href=\"(\\d\[\\d|\.|\\w\]+).*/\">

# live555 and possibly others are not universal, so disabling for now
universal_variant   no

# VLC currently doesn't build with 10.6sdk, force 10.5sdk (#21487)
configure.args-append   --disable-macosx-defaults \
    --enable-release --enable-macosx --enable-macosx-audio --enable-a52 --enable-cddax \
    --enable-dvdnav --enable-dvdread --enable-faad --enable-flac --enable-live555 \
    --enable-vorbis --enable-ogg --enable-mad --disable-libass --enable-asademux \
    --enable-dca --enable-gnutls --enable-ncurses --enable-png --enable-realrtsp \
    --with-macosx-version-min=10.5 \
    --with-macosx-sdk=/Developer/SDKs/MacOSX10.5.sdk \
    --with-live555-tree=${prefix}/lib/live \
    --disable-debug --disable-x11 --disable-xvideo --disable-glx --disable-xinerama \
    --disable-xcb --disable-xvmc --disable-qt4 --disable-quicktime \
    --disable-skins2 --disable-notify --disable-telepathy --disable-twolame \
    --disable-speex --disable-theora --disable-x264 --disable-dvbpsi \
    --disable-vcdx  --disable-fontconfig --disable-freetype \
    --disable-dbus --disable-bonjour --disable-fribidi --disable-goom \
    --disable-growl --disable-sdl --disable-caca --disable-smb \
    --disable-update-check --without-x

variant x264 description {Enable H.264 en/decoding} {
    depends_lib-append      port:x264
    configure.args-delete   --disable-x264
    configure.args-append   --enable-x264
}

variant theora description {Enable OggTheora support} {
    depends_lib-append      port:libtheora
    configure.args-delete   --disable-theora
    configure.args-append   --enable-theora
}

variant twolame description {Enable MPEG Audio Layer 2 encoding} {
    depends_lib-append      port:twolame
    configure.args-delete   --disable-twolame
    configure.args-append   --enable-twolame
}

variant speex description {Enable Speex decoder support} {
    depends_lib-append      path:lib/libspeex.dylib:speex
    configure.args-delete   --disable-speex
    configure.args-append   --enable-speex
}

variant svg description {Enable SVG support} {
    depends_lib-append      port:librsvg
    configure.args-append   --enable-svg
}

variant shout description {Enable Shoutcast support} {
    depends_lib-append      port:libshout2
    configure.args-append   --enable-shout
}

variant vcd description {Enable VCD support} {
    depends_lib-append      port:vcdimager
    configure.args-delete   --disable-vcdx
    configure.args-append   --enable-vcdx
}

variant mod description {Enable MOD demuxer support} {
    depends_lib-append      port:libmodplug
    configure.args-delete   --disable-mod
    configure.args-append   --enable-mod
}

variant mpc description {enable Musepack Decoder library support} {
    depends_lib-append      port:libmpcdec
    configure.args-delete   --disable-mpc
    configure.args-append   --enable-mpc
}

variant dvb description {enable DVB Program Specific Information support} {
    depends_lib-append      port:libdvbpsi
    configure.args-delete   --disable-dvbpsi
    configure.args-append   --enable-dvbpsi
}

variant osd description {Enable onscreen display and TrueType font support} {
    depends_lib-append      port:fontconfig port:freetype
    configure.args-delete   --disable-fontconfig
    configure.args-delete   --disable-freetype
    configure.args-append   --enable-freetype
}

variant fribidi requires osd description {Enable FriBidi Unicode support} {
    depends_lib-append      port:fribidi
    configure.args-delete   --disable-fribidi
    configure.args-append   --enable-fribidi
}

# avahi port is currently broken, so this variant is removed
# from +huge
variant bonjour description {Enable Bonjour support} {
    depends_lib-append      port:avahi
    configure.args-delete   --disable-dbus --disable-bonjour
    configure.args-append   --enable-dbus --enable-bonjour
}

variant sdl description {Enable SDL/SDL-Image support} {
    depends_lib-append          path:lib/pkgconfig/sdl.pc:libsdl port:libsdl_image
    configure.args-delete       --disable-sdl
    configure.args-append       --enable-sdl
}

variant smb description {Enable Samba 3 support} {
    depends_lib-append      port:samba3
    configure.args-delete   --disable-smb
    configure.args-append   --enable-smb
    configure.ldflags-append    -L${prefix}/lib/samba3
}

variant no_dvd description {disable DVD and DeCSS support} {
    depends_lib-delete      port:libdvdnav port:libdvdread
    configure.args-append   --disable-dvdnav --disable-dvdread
}

variant no_ffmpeg description {disable FFmpeg support} {
    depends_lib-delete      port:ffmpeg
    configure.args-append   --disable-avcodec --disable-avformat \
                            --disable-postproc --disable-swscale
}

variant x11 description {Build support for X11} {
    depends_lib-append \
    port:mesa \
    port:xorg-libXinerama \
    port:xorg-libXv \
    port:xorg-libXxf86vm

    configure.args-delete   --disable-x11 --disable-xvideo --disable-glx --disable-xinerama --disable-xcb
    configure.args-append   --enable-x11 --enable-xvideo --enable-glx --enable-xinerama --enable-xcb
    patchfiles-delete       patch-configure.ac-xcb.diff
}

variant qt4 description {Build using QT4 UI.  This will use qt4-x11 if +x11 and qt4-mac otherwise.} {
    configure.args-delete --disable-qt4
    configure.args-append --enable-qt4

    if {[variant_isset x11]} {
        depends_lib-append port:qt4-x11
        patchfiles-append patch-qt4-x11.diff
        set qt_dir ${prefix}/libexec/qt4-x11
        configure.cppflags-append -D__USE_WS_X11__
    } else {
        depends_lib-append path:bin/qmake-mac:qt4-mac
        set qt_dir ${prefix}/libexec/qt4-mac
    }
    configure.env-append QTDIR=${qt_dir}
    set env(PATH) "${qt_dir}/bin:$env(PATH)"
    configure.pkg_config_path "${configure.pkg_config_path}:${qt_dir}/lib/pkgconfig"
}

platform macosx {
    destroot.target-append  VLC.app
    post-destroot {
        file rename ${worksrcpath}/VLC.app ${destroot}${applications_dir}/VLC.app
    }
}

platform darwin 10 {
    patchfiles-append patch-fdatasync_sl.diff
}

variant minimal description {VLC Mac OS X minimal configuration} {}

variant huge conflicts minimal \
    requires svg vcd speex dvb fribidi sdl shout \
    description {Enable all variants except x11, qt4, smb and no_*} {}

variant full requires huge qt4 smb \
    description {Enable all variants except x11 and no_*} {}

# Unless minimal variant is set compile with default Mac OS X configuration
if {![variant_isset minimal]} {
    default_variants +x264 +theora +twolame +mod +mpc +osd
}

if {[variant_isset x11]} {
    default_variants-append +qt4
}
