# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# $Id: Portfile 115911 2014-01-14 05:45:07Z devans@macports.org $

PortSystem      1.0
PortGroup       python 1.0
PortGroup       active_variants 1.1

name            py-exiv2
platforms       darwin
set my_name     pyexiv2
version         0.3.2
revision        2
set branch      [join [lrange [split ${version} .] 0 1] .]
categories      python graphics
license         GPL-2
maintainers     devans openmaintainer
description     Python bindings for exiv2.

long_description \
                pyexiv2 is a Python binding to exiv2, the C++ library for \
                manipulation of EXIF, IPTC and XMP image metadata.

homepage        http://tilloy.net/dev/pyexiv2/overview.html
master_sites    http://launchpad.net/pyexiv2/0.3.x/${version}/+download/
distname        ${my_name}-${version}
use_bzip2       yes

checksums       rmd160  cbc53e6f45b0f4251b90bfb6ffab8c659463ac5d \
                sha256  0abc117c6afa71f54266cb91979a5227f60361db1fcfdb68ae9615398d7a2127

python.versions 26 27
python.default_version  27

if {$subport ne $name} {
    depends_build-append    port:scons

    depends_lib-append      port:boost \
                            port:exiv2

    patchfiles              patch-src-SConscript.diff

#
# conflict due to dependency on
# Python version specific variant of boost
#
    if {${python.version} == 26} {
        conflicts   py27-exiv2
    } else {
        conflicts   py26-exiv2
    }
#
# Make sure that boost is installed with the correct Python variant
#

    require_active_variants boost python${python.version}

#
# scons (a python script) uses python builtin procedures
# to determine configuration options so correct configuation
# depends on the version of python used to run scons
#

    build.cmd       ${python.bin} ${prefix}/bin/scons
    build.target
    build.args-append \
        BOOSTLIB=boost_python-mt \
        PYTHONLIB=python${python.branch}
    build.env-append \
        PREFIX=${prefix} \
        CXX=${configure.cxx} \

    pre-build {
        if {[variant_isset universal]} {
            build.env-append \
                CXXFLAGS="${configure.universal_cxxflags} -I${prefix}/include" \
                LDFLAGS="${configure.universal_ldflags} -L${prefix}/lib"
        } else {
            build.env-append \
                CXXFLAGS="-I${prefix}/include" \
                LDFLAGS="-L${prefix}/lib"
        }
    }

    destroot.cmd        ${python.bin} ${prefix}/bin/scons
    destroot.destdir    DESTDIR=${destroot}
    destroot.args-append \
        BOOSTLIB=boost_python-mt \
        PYTHONLIB=python${python.branch}
    destroot.env-append \
        PREFIX=${prefix}\
        CXX=${configure.cxx} \

    if {[variant_isset universal]} {
        destroot.env-append \
            CXXFLAGS="${configure.universal_cxxflags} -I${prefix}/include" \
            LDFLAGS="${configure.universal_ldflags} -L${prefix}/lib"
    } else {
        destroot.env-append \
            CXXFLAGS="-I${prefix}/include" \
            LDFLAGS="-L${prefix}/lib"
    }

    livecheck.type  regex
    livecheck.url   http://tilloy.net/dev/pyexiv2/download.html
    livecheck.regex "${my_name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
} else {
    livecheck.type  none
}
