# -*- 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 119508 2014-04-28 14:51:24Z devans@macports.org $

PortSystem          1.0
PortGroup           conflicts_build 1.0

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

name                gstreamer1
set my_name         gstreamer
version             1.2.4
set branch          [join [lrange [split ${version} .] 0 1] .]
description \
    GStreamer is a library for constructing graphs of media-handling components.
long_description \
    The applications it supports range from simple Ogg/Vorbis playback, audio/video \
    streaming to complex audio (mixing) and video (non-linear editing) processing.
maintainers	rmstonecipher openmaintainer
categories	gnome
platforms	darwin
license     LGPL-2+
homepage	http://${my_name}.freedesktop.org/
distname    ${my_name}-${version}

master_sites        gnome:sources/${my_name}/${branch}/ \
                    http://gstreamer.freedesktop.org/src/${my_name}/

checksums           rmd160  3b4f7eb39186600fc4d68d0c128f58e2563f0d5d \
                    sha256  1e7ca67a7870a82c9ed51d51d0008cdbc550c41d64cc3ff3f9a1c2fc311b4929

depends_build   \
    port:gzip \
    port:m4 \
    path:bin/perl:perl5 \
    port:pkgconfig
depends_lib \
    port:bison \
    port:flex \
    port:gettext \
    path:lib/pkgconfig/glib-2.0.pc:glib2 \
    port:libxml2 \
    port:gobject-introspection

use_xz           yes

conflicts_build         check

configure.env-append    PERL_PATH=${prefix}/bin/perl
configure.cflags-append -funroll-loops -fstrict-aliasing -fno-common

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} eq "i386"} {
        configure.args-append \
            --host=i686-apple-${os.platform}${os.major} \
            --build=i686-apple-${os.platform}${os.major}
    } elseif {${build_arch} eq "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}"
}

# The rules enabled by gobject-introspection require GNU make 3.81+
platform darwin 8 {
    depends_build-append    port:gmake
    build.cmd               ${prefix}/bin/gmake
}

livecheck.type      gnome
livecheck.name      ${my_name}
