# -*- 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 102362 2013-02-01 03:43:34Z rmstonecipher@macports.org $

PortSystem          1.0

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

name                gstreamer1-gst-plugins-base
set my_name         gst-plugins-base
version             1.0.7
description         This is gst-plugins, a set of plug-ins for GStreamer.
long_description    ${description}
maintainers         rmstonecipher openmaintainer
categories          gnome
platforms           darwin
license             LGPL-2+
homepage            http://gstreamer.freedesktop.org/modules/${my_name}.html

use_xz              yes
master_sites        gnome:sources/${my_name}/1.0/ http://gstreamer.freedesktop.org/src/${my_name}/
distname            ${my_name}-${version}

checksums           rmd160  c3751b5e09290513df96e3496196ff8e07610016 \
                    sha256  014805e50b696bc06c3862ea656df079fc0b5fef0c10f16e9f085f290545677a

depends_build \
    port:pkgconfig
depends_lib	\
    port:gstreamer1 \
    port:gnome-vfs \
    port:libtheora \
    port:openssl \
    port:orc \
    port:xorg-libice \
    port:xorg-libsm \
    port:gobject-introspection

configure.args-append \
    --enable-experimental \
    --disable-examples \
    --disable-libvisual\
    --disable-gst_v4l \
    --disable-alsa \
    --disable-cdparanoia \
    --disable-ivorbis

variant no_x11 {
    configure.args-append --without-x --disable-x --disable-xvideo --disable-xshm
}

variant examples description {Build example programs} {
    PortGroup qt4 1.0
    depends_lib-append port:gtk2
    configure.args-delete --disable-examples
}

# users of qt4-x11, which depends on gst-plugins-base but has no use for its
# deeper gnome-related dependencies may wish to use this variant
variant no_gnome_vfs description {Remove library dependency on gnome-vfs} {
    depends_lib-delete port:gnome-vfs
    configure.args-append --disable-gnome_vfs
}

variant no_ogg description {Remove library dependency on libogg and its dependents} {
    depends_lib-delete port:libtheora
    configure.args-append --disable-ogg --disable-vorbis --disable-theora
}
#
# current cdparanoia port (cdparanoia III 10.2) appears to not be API compatible
# with gst-plugins-base.  See #19843.
# disable by default until this is rectified.
#

variant cdparanoia description {Enable (currently broken) cdparanoia plugin} {
    depends_lib-append port:cdparanoia
    configure.args-delete --disable-cdparanoia
}

#-fgcse (from -O2) causes build failures, but -O2 -fno-gcse doesn't seem to work
if {[string match "*gcc-4.2" ${configure.compiler}]} {
    lappend merger_configure_cflags(i386) -O1 -fexpensive-optimizations
    if {![variant_isset universal] && ${build_arch} == "i386"} {
        configure.cflags-delete -O2
        configure.cflags-append -O1 -fexpensive-optimizations
    }
}

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       http://gstreamer.freedesktop.org/src/${my_name}/
livecheck.regex     "${my_name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
