# -*- 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 101867 2013-01-20 20:36:27Z eborisch@macports.org $

PortSystem 1.0
PortGroup               github 1.0

github.setup            imageworks Field3D 1.3.2 v
name                    field3d
revision                1
categories              graphics
maintainers             blair
license                 BSD

description             Library for storing voxel data.
long_description \
        Field3D is an open source library for storing voxel data.  It \
        provides C++ classes that handle in-memory storage and a file \
        format based on HDF5 that allows the C++ objects to be written \
        to and read from disk. \
        \
        The library and file format is both flexible and extendable. \
        The flexibility comes from supporting heterogeneous storage of \
        data structures, bit depths, transformations/mappings and \
        metadata in a single file.  When functionality needs to be \
        extended, the plugin and class factory architecture allows new \
        data structures, mappings and file I/O routines to be added.

homepage                https://sites.google.com/site/field3d/home
platforms               darwin

checksums               rmd160  cf86b30f1bb7a8ac9eb0ce441ce86b1c8e35a020 \
                        sha256  b3d6d2cb71a9ad21ac81f96dec0a796434c8897f054ba1e1b138d3b7e3ab655b

depends_build           port:scons
depends_lib             port:boost \
                        port:ilmbase \
                        port:hdf5-18

variant universal {}

patchfiles              patch-BuildSupport.py \
                        patch-SConstruct

post-patch {
    reinplace "s#@PREFIX@#${prefix}#g" ${worksrcpath}/BuildSupport.py
    reinplace "s#@CC@#${configure.cc} [get_canonical_archflags]#" \
        ${worksrcpath}/SConstruct
    reinplace "s#@CXX@#${configure.cxx} [get_canonical_archflags]#" \
        ${worksrcpath}/SConstruct
}

use_configure           no
build.cmd               $prefix/bin/scons
build.target
build.args              verbose=1

post-build {
    set releasedir [glob ${worksrcpath}/install/darwin/*/release]
    set dylib lib/libField3D.dylib
    system "install_name_tool -id ${prefix}/${dylib} ${releasedir}/${dylib}"
}

destroot {
    set sharedir ${destroot}${prefix}/share
    set docdir ${sharedir}/doc/${name}
    set releasedir [glob ${worksrcpath}/install/darwin/*/release]

    foreach d {include lib} {
        delete ${destroot}${prefix}/${d}
        copy ${releasedir}/${d} ${destroot}${prefix}
    }

    xinstall -m 755 -d ${docdir}
    xinstall -m 644 -W ${worksrcpath} CHANGES COPYING README ${docdir}
}
