# -*- 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 102128 2013-01-28 08:36:14Z jeremyhu@macports.org $

PortSystem      1.0
PortGroup       cmake 1.0

name            vxl
version         1.14.0
revision        5
set branch      [join [lrange [split ${version} .] 0 1] .]
categories      devel
maintainers     maeth.com:wiking
description     C++ libraries for computer vision
long_description \
    VXL (the Vision-something-Libraries) is a collection of C++ libraries \
    designed for computer vision research and implementation. It was \
    created from TargetJr and the IUE with the aim of making a light, \
    fast and consistent system. VXL is written in ANSI/ISO C++ and is \
    designed to be portable over many platforms.
homepage        http://vxl.sourceforge.net/
platforms       darwin

master_sites    sourceforge:project/vxl/vxl/${branch}
use_zip         yes
checksums       md5    0329521f2fda61d2835e7b3c7c1189df \
                sha1   db42cfce42448c40d37fcdd3127e6d586660c8c3 \
                rmd160 2b7c72ead698d928cfd5d56205b2e1b3f7f2fef9

# licenses in vxl:
# (see also: http://anonscm.debian.org/viewvc/debian-med/trunk/packages/vxl/trunk/debian/copyright?revision=10688&view=markup)
# BSD       for core
# GPL-2+    for v3p/Qv/*
# zlib      for v3p/zlib/*
# GPL-2+    for v3p/mpeg2/libmpeg2/*
# MIT       for v3p/geotiff/*
# Boost     for core/vul/vul_ios_state.h
# Boost     for contrib/rpl/rgrl/*
# MIT/X11   for contrib/brl/b3p/shapelib/* (or LGPL-something)
# zlib      for contrib/brl/b3p/minizip/*
# GPL-2+    for vidl_vil1/vidl_vil1_mpegcodec.cxx and vidl1/vidl1_mpegcodec.cxx
# Boost     for vcl_atomic_count.h and vcl/internal/*
license         BSD GPL-2+ zlib MIT Boost

# error: integer constant is too large for 'long' type
universal_variant no

patchfiles      patch-v3p__mpeg2__libmpeg2__idct_altivec.c \
                patch-v3p__mpeg2__libmpeg2__motion_comp_altivec.c \
                libpng15.diff

if {[string match *clang* ${configure.compiler}]} {
    patchfiles-append \
        patch-contrib__gel__mrc__vpgl__txx-clang-compatibility.diff \
        patch-contrib__prip__vmap__vmap_2_map.txx.diff \
        patch-contrib__prip__vmap__vmap_ptr_sequences.h-clang-compatibility.diff \
        patch-contrib__prip__vpyr__vpyr_2_pyramid_level_elts.h-clang-compatibility.diff \
        patch-contrib__prip__vpyr__vpyr_2_tpyramid_level_elts.h-clang-compatibility.diff \
        patch-contrib__rpl__rgrl__rgrl_est_proj_rad_func.txx-clang-compatibility.diff \
        patch-contrib__tbl__vipl__filter__vipl_filter_2d.txx-clang-compatibility.diff \
        patch-contrib__tbl__vipl__txx-clang-compatibility.diff \
        patch-core__examples__vnl_calc__vnl_calc.cxx-clang-compatibility.diff \
        patch-core__vil__tests__test_image_resource.cxx-clang-compatibility.diff \
        patch-core__vil__tests__test_image_view.cxx-clang-compatibility.diff \
        patch-core__vnl__vnl_matrix_fixed_ref.h-clang-compatibility.diff
}

post-patch {
    file delete ${worksrcpath}/contrib/mul/vil3d/Templates/vil3d_tricub_interp+uint-.cxx
}

depends_build   port:cmake

depends_lib     path:lib/libavcodec.dylib:ffmpeg \
                port:libgeotiff \
                port:libpng

if {${configure.compiler} == "clang"} {
    configure.cxxflags-append -Werror=gnu -Wno-error=vla
}
configure.args-append \
    -DBUILD_SHARED_LIBS=YES \
    -DCMAKE_INSTALL_NAME_DIR=${prefix}/lib/${name} \
    -DBUILD_BRL=NO

# shuffle directories around to turn ${prefix}/lib into ${prefix}/lib/${name}
post-destroot {
    file rename ${destroot}${prefix}/lib ${destroot}${prefix}/tmp
    file mkdir ${destroot}${prefix}/lib
    file rename ${destroot}${prefix}/tmp ${destroot}${prefix}/lib/${name}

    # for some reason this file doesn't get installed, making rev-upgrade complain
    xinstall -m 755 ${worksrcpath}/lib/libvpgl.dylib ${destroot}${prefix}/lib/${name}
}

livecheck.regex /${name}-(\[0-9.\]+)${extract.suffix}

