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

PortSystem          1.0

name                VLC09
version             0.9.10
revision            2

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. This is the 0.9 branch of VLC \
                    and intended for Mac OS X 10.4. On 10.5+ the 'VLC' port is recommended \
                    instead
license             GPL

platforms           darwin
conflicts           VLC

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

checksums           md5     5035b2ea8f88ff6ee92b0a9feaed8c7c \
                    sha1    8b562a5327c358a332f97d9012702ca2b445c0ed \
                    rmd160  25a96098e3507d48f7d62d1b2f3a1138c2004832

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

patchfiles      patch-Makefile.am.diff

use_autoreconf yes
autoreconf.args -fvi

build.target    all
destroot.target install

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

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

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-quicktime \
    --enable-vorbis --enable-ogg --enable-mad --disable-libass --enable-asademux \
    --enable-dca --enable-gnutls --enable-ncurses --enable-png --enable-realrtsp \
    --with-macosx-version-min=${macosx_deployment_target} \
    --disable-debug --disable-x11 --disable-xvideo --disable-glx --disable-xinerama \
    --disable-xcb --disable-xvmc --disable-qt4 \
    --disable-skins2 --disable-notify --disable-telepathy --disable-twolame \
    --disable-speex --disable-theora --disable-x264 --disable-live555 --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 live555 description {Enable Live555 streaming media support} {
    depends_lib-append      port:live555
    configure.args-delete   --disable-live555
    configure.args-append   --enable-live555 \
                            --with-live555-tree=${prefix}/lib/live
}

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}/VLC09.app
    }
}

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

variant huge conflicts minimal \
    requires svg vcd live555 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
}
