# -*- 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 91922 2012-04-13 08:12:21Z jeremyhu@macports.org $

PortSystem          1.0
PortGroup           muniversal 1.0

name                lensfun
version             0.2.5
revision            1
categories          graphics
platforms           darwin
maintainers         gmail.com:julians37
license             GPL-3 LGPL-3

description         Library for fixing lens geometry distortion

long_description    Provides a database of photographic lenses and a library \
                    that allows advanced access to the database including \
                    functions to correct images based on intimate knowledge \
                    of lens characteristics and calibration data.

homepage            http://lensfun.berlios.de/
master_sites        http://download.berlios.de/lensfun/

checksums           sha1    0ed0ceccd8ea0fe19b942682a9e71b0bf08c9336 \
                    rmd160  d2d2c45eddc03e50e9425125e283b236c976b5d2

depends_build       port:pkgconfig

depends_lib         path:lib/pkgconfig/glib-2.0.pc:glib2

# Ensure lensfun.pc is created
patchfiles          patch-pkgconfig.diff \
                    patch-build-tibs-target-mac-mak.diff

configure.args      -v

platform darwin 8 {
    # lensfun requires make >= 3.81; Tiger comes with 3.80
    depends_build-append port:gmake
    # fix configure script check which is hardcoded to using "make"
    post-extract {
        xinstall -d ${workpath}/bin
        ln -s ${prefix}/bin/gmake ${workpath}/bin/make
    }
    configure.env PATH=${workpath}/bin:$env(PATH)
    # fix build and destroot
    build.cmd ${prefix}/bin/gmake
}

if {[variant_isset universal]} {
    foreach arch ${configure.universal_archs} {
        set merger_host($arch) ""
    }
    set merger_configure_args(ppc64)  "--target=mac.powerpc64.G5 --vectorization=''"
    set merger_configure_args(ppc)    "--target=mac.powerpc.powerpc --vectorization=''"
    set merger_configure_args(i386)   "--target=mac.x86.i686"
    set merger_configure_args(x86_64) "--target=mac.x86_64.generic"
} elseif {${build_arch} == "ppc64"} {
    configure.args-append --target=mac.powerpc64.G5 --vectorization=''
} elseif {${build_arch} == "ppc"} {
    configure.args-append --target=mac.powerpc.powerpc --vectorization=''
} elseif {${build_arch} == "i386"} {
    configure.args-append --target=mac.x86.i686
} elseif {${build_arch} == "x86_64"} {
    configure.args-append --target=mac.x86_64.generic
}

configure.universal_args-delete --disable-dependency-tracking

build.args          V=1 GCC.LD="${configure.cxx}"

livecheck.type      regex
livecheck.url       http://developer.berlios.de/project/showfiles.php?group_id=9034
livecheck.regex     "lensfun-(\\d+(?:\\.\\d+)*).tar"
