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

PortSystem          1.0

name                libgpod
version             0.8.3
revision            1
set branch          [join [lrange [split ${version} .] 0 1] .]
categories          multimedia
platforms           darwin
maintainers         nomaintainer
license             LGPL-2.1+ GPL-2+

description         libgpod is a library to access the contents of an iPod.

long_description    ${description} This library is based on code used in the \
                    gtkpod project. Starting with V0.96.CVS gtkpod depends \
                    on this library.

homepage            http://www.gtkpod.org/libgpod/
master_sites        sourceforge:project/gtkpod/libgpod/libgpod-${branch}
use_bzip2           yes

checksums           rmd160  96a2b0e48c0af6ecc62fc4aba4e38e8d0579c6cd \
                    sha256  638a7959d04e95f1e62abad02bd33702e4e8dfef98485ac7d9d50395c37e955d

depends_build       port:pkgconfig \
                    port:intltool \
                    port:gtk-doc \
                    port:gnome-common \
                    port:autoconf \
                    port:automake \
                    port:libtool

depends_lib         port:libplist \
                    port:libpng \
                    port:gdk-pixbuf2 \
                    port:taglib \
                    path:lib/pkgconfig/libusb-1.0.pc:libusb

patchfiles-append   patch-bindings-python-gpod.i.in.diff
patchfiles-append   patch-tools-generic-callout.c.diff

# reconfigure using upstream autogen.sh for intltool 0.51 compatibility

post-patch {
    xinstall -m 755 ${filespath}/autogen.sh ${worksrcpath}
}

configure.cmd       ./autogen.sh

# make sure to not use already-installed files,
# to the best of our ability
configure.ldflags-delete "-L${prefix}/lib"
configure.cppflags-delete "-I${prefix}/include"

variant python27 conflicts python26 \
description {Build Bindings for Python 2.7} {}

variant python26 conflicts python27 \
description {Build Bindings for Python 2.6} {}

# default to python27 bindings
if {![variant_isset python27] && ![variant_isset python26]} {
    default_variants +python27
}

# allow for -python27 to disable all Python support

set python.branch ""
if {[variant_isset python27]} {
    set python.branch 2.7
} elseif {[variant_isset python26]} {
    set python.branch 2.6
}

if {${python.branch} != ""} {
    set python.prefix ${frameworks_dir}/Python.framework/Versions/${python.branch}
    set pyver [join [split ${python.branch} "."] ""]
    depends_build-append port:swig-python
    depends_lib-append  port:py${pyver}-gobject port:py${pyver}-mutagen
    configure.env-append PYGOBJECT_CODEGEN=${python.prefix}/bin/pygobject-codegen-2.0
    configure.pkg_config_path ${python.prefix}/lib/pkgconfig
    configure.env-append PYTHON=${prefix}/bin/python${python.branch}
} else {
    configure.args-append --disable-pygobject --with-python=no
}

configure.args-append \
                    --disable-more-warnings \
                    --disable-silent-rules \
                    --disable-udev

post-destroot {
    # fix install location of Python stuff, if variant is selected
    if {${python.branch} != ""} {
        set dr_python_dir ${destroot}${python.prefix}/lib
        xinstall -m 755 -d ${dr_python_dir}
        move ${destroot}${prefix}/lib/python${python.branch} \
            ${dr_python_dir}
    }
}

livecheck.type		regex
livecheck.url		http://sourceforge.net/projects/gtkpod/files/${name}/${name}-${branch}
livecheck.regex     "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"