--- /dev/null	2014-08-12 04:31:44.000000000 +0200
+++ multimedia/mpv/Portfile	2014-08-12 04:26:46.000000000 +0200
@@ -0,0 +1,366 @@
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
+# $Id: $
+
+PortSystem              1.0
+PortGroup               github 1.0
+PortGroup               waf 1.0
+
+github.setup            mpv-player mpv 0.4.2 v
+revision                0
+categories              multimedia
+license                 GPL-2+
+maintainers             ionic.de:ionic
+platforms               darwin
+
+description             mpv is a movie player based on MPlayer and mplayer2.
+long_description        ${description} It plays most MPEG/VOB, AVI, Ogg/OGM, \
+                        VIVO, ASF/WMA/WMV, QT/MOV/MP4, RealMedia, Matroska, \
+                        NUT, NuppelVideo, FLI, YUV4MPEG, FILM, RoQ, PVA files, \
+                        supported by many native, XAnim, and Win32 DLL codecs. \
+                        You can watch VideoCD, SVCD, DVD, 3ivx, DivX 3/4/5, WMV \
+                        and even H.264 movies.
+homepage                http://www.mpv.io/
+
+checksums               rmd160  700dc2d620040b9a65fbd57fd9d047d35b8bc4f9 \
+                        sha256  948fbfd5d51c69224a39b8030333078c7acfac5bd35b511453797b2989975068
+
+depends_build           path:bin/pkg-config:pkgconfig
+depends_lib             path:lib/libavcodec.dylib:ffmpeg \
+                        path:bin/perl:perl5 \
+                        port:libiconv \
+                        port:ncurses \
+                        port:zlib \
+                        port:libass \
+                        port:libbluray \
+                        port:lcms2 \
+                        port:ossp-uuid \
+                        port:icu
+
+# Without the OpenGL patch, mpv will sporadically include both <GL/gl3.h>
+# and <GL/gl.h>. This is a problem, as it will disable compile errors for
+# deprecated functions and may lead to crashes in OpenGL mode.
+# This is really a bug in mpv code and should be fixed there, but
+# we'll provide a workaround by making sure <GL/gl3.h> will
+# not be included for the time being.
+patchfiles              patch-video_out_gl_common.h-use-OpenGL-legacy.diff
+
+universal_variant       no
+
+default_variants        +bundle +network +osd +mp3 +opengl +dvd
+
+
+# Default configuration options. Mostly Mac OS X specific.
+configure.args-append   --enable-libass \
+                        --enable-coreaudio \
+                        --enable-cocoa \
+                        --enable-corevideo \
+                        --disable-vda-hwaccel \
+                        --disable-vda-gl
+
+# mpv autodetects many support libs.  To prevent undeclared
+# dependencies, explicitly disable everything optional first.
+# This list should be expanded each time the port is updated to a
+# new version, disabling any newly added options.
+configure.args-append   --disable-pdf-build \
+                        --disable-macosx-bundle \
+                        --disable-debug-build \
+                        --disable-libsmbclient \
+                        --disable-libass-osd \
+                        --disable-libquvi \
+                        --disable-lirc \
+                        --disable-dvdread \
+                        --disable-dvdnav \
+                        --disable-cdda \
+                        --disable-enca \
+                        --disable-mpg123 \
+                        --disable-pulse \
+                        --disable-portaudio \
+                        --disable-jack \
+                        --disable-openal \
+                        --disable-gl-cocoa \
+                        --disable-x11 \
+                        --disable-xss \
+                        --disable-xext \
+                        --disable-xv \
+                        --disable-gl-x11 \
+                        --disable-xinerama \
+                        --disable-xf86vm \
+                        --disable-xf86xk \
+                        --disable-caca \
+                        --disable-jpeg \
+                        --disable-tv \
+                        --disable-lua
+
+# Fix picking up the correct talloc version.
+# -isystem has the added benefit of moving the include
+# directory specified to the end of the include path list.
+# This will help the build system respect custom include
+# paths correctly (i.e., searching them before the MP include
+# directory.)
+configure.cppflags-replace  -I${prefix}/include -isystem${prefix}/include
+
+platform darwin {
+    notes-append    "
+                     The maintainer ships its personal config file in
+                     * ${prefix}/share/examples/${name}/config-maintainer.
+
+                     You are strongly encouraged to copy this file to either
+                     * ${prefix}/etc/${name}/${name}.conf (globally for all users of the system) or
+                     * ~/.${name}/config (only for your current user)
+                     and adjust it to your needs.
+                    "
+
+    # VDA (video hardware acceleration, mostly H264) is only supported on 10.6.3+
+    if {${os.major} > 10 || {${os.major} == 10 && ${os.minor} >= 3}} {
+        configure.args-delete   --disable-vda-hwaccel \
+                                --disable-vda-gl
+        configure.args-append   --enable-vda-hwaccel \
+                                --enable-vda-gl
+
+        notes-append {
+                       This config file already defines the necessary video output settings to make
+                       use of the hardware acceleration features provided by your operating system.
+        }
+    } else {
+        notes-append {
+                       Sadly, your system is incapable of utilizing mpv's hardware decoding features.
+
+                       Please make sure to edit the file after copying and replace the "vo=" line with
+                       options suited for your system or mpv won't work as expected.
+                       Consult ``man mpv'' for further information.
+        }
+    }
+}
+
+
+# Shameless copy from ipe-tools.
+set python.versions         {27 32 33 34}
+set python.default_version  27
+
+# Create python variants.
+foreach ver ${python.versions} {
+    set variant_line {variant python${ver} description }
+    append variant_line " {Use python${ver} to generate man pages}"
+
+    foreach over ${python.versions} {
+        if {${ver} == ${over}} {
+            continue
+        }
+
+        append variant_line " conflicts python${over}"
+    }
+
+    append variant_line " { depends_build-append port:py${ver}-docutils }"
+    eval $variant_line
+}
+
+# Set default python variant.
+set variant_none true
+foreach ver ${python.versions} {
+    if {[variant_isset python${ver}]} {
+        set variant_none [expr $variant_none && ![variant_isset python${ver}]]
+    }
+}
+
+if {${variant_none}} {
+    default_variants-append "+python${python.default_version}"
+}
+
+# Set ${python.version} to the currently active variant.
+foreach ver ${python.versions} {
+    if {[variant_isset python${ver}]} {
+        set python.version ${ver}
+    }
+}
+
+post-extract {
+    if {${os.platform} eq "darwin"} {
+        xinstall -m 0644 -W ${filespath} config-maintainer ${worksrcpath}/TOOLS/
+    }
+}
+
+post-patch {
+    set python_ver_dot [join [split ${python.version} {}] "."]
+    reinplace -W "${worksrcpath}" "s|'rst2man'|'rst2man-${python_ver_dot}'|" wscript
+}
+
+pre-configure {
+    system -W "${worksrcpath}" "${waf.python} bootstrap.py"
+}
+
+post-destroot {
+    xinstall -d -m 0755 ${destroot}${prefix}/etc/${name}
+    foreach etcfile {encoding-profiles.conf example.conf input.conf} {
+        xinstall -m 0644 ${worksrcpath}/etc/${etcfile} \
+            ${destroot}${prefix}/etc/${name}/${etcfile}
+    }
+    xinstall -d -m 0755 ${destroot}${prefix}/share/examples/${name}
+    eval file copy [glob ${worksrcpath}/TOOLS/lua ${worksrcpath}/TOOLS/*.pl \
+                         ${worksrcpath}/TOOLS/*.sh ${worksrcpath}/TOOLS/*.py \
+                         ${worksrcpath}/TOOLS/umpv ${worksrcpath}/TOOLS/lib] \
+                   ${destroot}${prefix}/share/examples/${name}
+
+    if {${os.platform} eq "darwin"} {
+        xinstall -m 0644 ${worksrcpath}/TOOLS/config-maintainer \
+                         ${destroot}${prefix}/share/examples/${name}
+    }
+
+    if {[variant_isset bundle]} {
+        xinstall -d -m 0755 ${destroot}${applications_dir}
+        file rename ${destroot}${prefix}/bin/mpv.app ${destroot}${applications_dir}
+    }
+}
+
+
+# When enabling features, make sure to replace the "disable" flags with
+# "enable" flags in order to make the waf build system error out in case
+# a feature cannot be used/found. Problems like that indicate a missing
+# runtime dependency.
+# libquvi is a special case. We just add libquvi-scripts as a dependency
+# and hope for waf to autodetect this version. Do not explicitly enable
+# libquvi, as mpv supports multiple versions and we don't want waf to
+# throw an error if some other version wasn't found.
+
+variant bundle description {Enable the optional Mac OS X bundle of mpv} {
+    configure.args-replace  --disable-macosx-bundle \
+                            --enable-macosx-bundle
+}
+
+variant screenshot description {Enable optional screenshot support} {
+    depends_lib-append      port:jpeg
+    configure.args-replace  --disable-jpeg \
+                            --enable-jpeg
+}
+
+variant network description {Enable networking support via libquvi-scripts} {
+    depends_lib-append      port:libquvi \
+                            port:libquvi-scripts
+    configure.args-delete   --disable-libquvi
+}
+
+variant lirc description {Enable Linux Infrared Remote Daemon support} {
+    depends_lib-append      port:lirc
+    configure.args-replace  --disable-lirc \
+                            --enable-lirc
+}
+
+variant dvd description {Enable DVD and DeCSS support} {
+    depends_lib-append      port:libdvdread \
+                            port:libdvdnav
+    configure.args-replace  --disable-dvdread \
+                            --enable-dvdread
+    configure.args-replace  --disable-dvdnav \
+                            --enable-dvdnav
+}
+
+variant audiocd description {Enable Audio CD support via libcdio-paranoia (currently unsupported!)} {
+    #depends_lib-append      port:libcdio-paranoia
+    #configure.args-replace   --disable-cdda \
+                              --enable-cdda
+    ui_error "Audio CD support is currently disabled due to a missing libcdio-paranoia port."
+    error "audiocd variant not supported"
+}
+
+variant enca description {Enable encoding support via ENCA} {
+    depends_lib-append      port:enca
+    configure.args-replace  --disable-enca \
+                            --enable-enca
+}
+
+variant mp3 description {Enable mp3 support via mpg123} {
+    depends_lib-append      port:mpg123
+    configure.args-replace  --disable-mpg123 \
+                            --enable-mpg123
+}
+
+variant pulseaudio description {Enable PulseAudio support} {
+    depends_lib-append      port:pulseaudio
+    configure.args-replace  --disable-pulse \
+                            --enable-pulse
+}
+
+variant portaudio description {Enable portaudio support} {
+    depends_lib-append      port:portaudio
+    configure.args-replace  --disable-portaudio \
+                            --enable-portaudio
+}
+
+variant jack description {Enable Jack Audio Connection Kit support} {
+    depends_lib-append      port:jack
+    configure.args-replace  --disable-jack \
+                            --enable-jack
+}
+
+# TODO: switch that to openal-soft? Leave it as-is?
+variant openal description {Enable OpenAL support} {
+    depends_lib-append      port:openal
+    configure.args-replace  --disable-openal \
+                            --enable-openal
+}
+
+variant x11 {
+    depends_lib-append      port:xorg-libXext \
+                            port:xorg-libXScrnSaver \
+                            port:xorg-libXinerama \
+                            port:xorg-libXv \
+                            port:xorg-libXxf86vm
+
+    configure.args-delete   --disable-x11 \
+                            --disable-xss \
+                            --disable-xext \
+                            --disable-xinerama \
+                            --disable-xv \
+                            --disable-xf86vm
+    configure.args-append   --enable-x11 \
+                            --enable-xss \
+                            --enable-xext \
+                            --enable-xv \
+                            --enable-xinerama \
+                            --enable-xf86vm
+}
+
+variant opengl description {Enable glx output support.  Both the CoreVideo and X11 outputs are supported} {
+    configure.args-replace  --disable-gl-cocoa \
+                            --enable-gl-cocoa
+
+    if {[variant_isset x11]} {
+        depends_lib-append      port:mesa
+        configure.args-replace  --disable-gl-x11 \
+                                --enable-gl-x11
+    }
+}
+
+variant caca description {Enable animated ASCII art video output} {
+    depends_lib-append      port:libcaca
+    configure.args-replace  --disable-caca \
+                            --enable-caca
+}
+
+variant osd description {Enable onscreen display and TrueType font support} {
+    depends_lib-append      port:lua
+    configure.args-delete   --disable-lua \
+                            --disable-libass-osd
+    configure.args-append   --enable-lua \
+                            --lua=52 \
+                            --enable-libass-osd
+}
+
+variant smb description {Enable Samba support} {
+    depends_lib-append      path:lib/pkgconfig/smbclient.pc:samba3
+    configure.args-replace  --disable-libsmbclient \
+                            --enable-libsmbclient
+}
+
+variant debug description {Compile with debugging symbols} {
+    configure.args-replace  --disable-debug-build \
+                            --enable-debug-build
+}
+
+variant printable_doc description {Generate printable documents (PDF help)} {
+    # py27-pdfrw and py27-Pillow are needed by rst2pdf.
+    depends_build-append    port:rst2pdf \
+                            port:py27-pdfrw \
+                            port:py27-Pillow
+    configure.args-replace  --disable-pdf-build \
+                            --enable-pdf-build
+}
--- /dev/null	2014-08-12 04:32:15.000000000 +0200
+++ multimedia/mpv/files/patch-video_out_gl_common.h-use-OpenGL-legacy.diff	2014-08-12 04:20:58.000000000 +0200
@@ -0,0 +1,18 @@
+--- video/out/gl_common.h.old	2014-08-12 03:40:56.000000000 +0200
++++ video/out/gl_common.h	2014-08-12 03:41:27.000000000 +0200
+@@ -38,11 +38,11 @@
+ #include "video/mp_image.h"
+ 
+ #if HAVE_GL_COCOA
++/* Avoid <GL/gl3.h> on OS X. mpv doesn't use any 3.x features and including it causes the compiler
++ * to not complain about missing functions/errors.
++ */
++#define __gl3_h
+-#ifdef GL_VERSION_3_0
+-#include <OpenGL/gl3.h>
+-#else
+ #include <OpenGL/gl.h>
+-#endif
+ #include <OpenGL/glext.h>
+ #else
+ #include <GL/gl.h>
--- /dev/null	2014-08-12 04:32:18.000000000 +0200
+++ multimedia/mpv/files/config-maintainer	2014-08-12 02:28:12.000000000 +0200
@@ -0,0 +1,20 @@
+# Write your default config options here!
+[default]
+
+vo=opengl-hq:backend=cocoa
+ao=coreaudio
+
+sub-scale=3
+
+af=scaletempo
+
+softvol=yes
+softvol-max=800
+
+framedrop=yes
+
+hwdec=vda
+
+#alang=en,eng,de,ger
+
+cache=16384
