# -*- 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
# $Id: Portfile 102363 2013-02-01 04:17:32Z rmstonecipher@macports.org $

PortSystem          1.0

# https://bugzilla.gnome.org/show_bug.cgi?id=636134
PortGroup   muniversal 1.0

name                gstreamer1-gst-plugins-ugly
set my_name         gst-plugins-ugly
version             1.0.7
description         \
    A set of good-quality plug-ins for GStreamer that might pose distribution \
    problems.
long_description    \
    GStreamer Ugly Plug-ins is a set of plug-ins that have good quality and \
    correct functionality, but distributing them might pose problems. The \
    license on either the plug-ins or the supporting libraries might not be how \
    we'd like. The code might be widely known to present patent problems. 
maintainers         rmstonecipher openmaintainer
categories          gnome
platforms           darwin
homepage            http://gstreamer.freedesktop.org/modules/${my_name}.html
master_sites        http://gstreamer.freedesktop.org/src/${my_name}/
distname            ${my_name}-${version}
license             GPL-2+ LGPL-2+
use_xz              yes

checksums           rmd160  9c2c3fce9db79a38ecc558ae5976f5342a17cc23 \
                    sha256  b78b8cfabe322497da432a0f297dbb21862a033f95e8d4cd8f207eccb5288f2b

depends_build       port:pkgconfig
depends_lib         port:gstreamer1-gst-plugins-base \
                    port:a52dec \
                    port:lame \
                    port:libcdio \
                    port:libdvdread \
                    port:libid3tag \
                    port:libmad \
                    port:libmpeg2 \
                    port:opencore-amr \
                    port:twolame \
                    port:gobject-introspection \
                    port:x264

configure.args-append       mandir=${prefix}/share/man --enable-static
configure.cppflags-append   "-L${prefix}/lib"
configure.cflags-append     -funroll-loops -fstrict-aliasing

# I'm not sure if the pkg-config data is wrong or if gst-plugin is wrong, meh.
configure.cppflags-append -I${prefix}/include/opencore-amrnb -I${prefix}/include/opencore-amrwb

post-extract {
    reinplace "s|-flat_namespace -undefined suppress|-undefined define_a_way|g" \
    ${worksrcpath}/configure
}

if {[variant_isset universal]} { 
    set merger_host(x86_64) x86_64-apple-${os.platform}${os.major}
    set merger_host(i386) i686-apple-${os.platform}${os.major}
    set merger_configure_args(x86_64) --build=x86_64-apple-${os.platform}${os.major}
    set merger_configure_args(i386) --build=i686-apple-${os.platform}${os.major}

    # gobject-introspection uses g-ir-scanner, which uses $CC from env
    foreach arch ${configure.universal_archs} {
        lappend merger_build_args(${arch})  CC='${configure.cc} -arch ${arch}'
        lappend merger_destroot_args(${arch})  CC='${configure.cc} -arch ${arch}'
    }
} else {

    if {${build_arch} == "i386"} {
        configure.args-append \
            --host=i686-apple-${os.platform}${os.major} \
            --build=i686-apple-${os.platform}${os.major}
    } elseif {${build_arch} == "x86_64"} {
        configure.args-append \
            --host=${build_arch}-apple-${os.platform}${os.major} \
            --build=${build_arch}-apple-${os.platform}${os.major}
    }

    build.args-append       CC="${configure.cc} ${configure.cc_archflags}"
    destroot.args-append    CC="${configure.cc} ${configure.cc_archflags}"
}

livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     "${my_name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
