# $Id: Portfile 82190 2011-08-10 01:53:38Z blair@macports.org $

PortSystem 1.0

name                    field3d
version                 1.2.0
revision                1
categories              graphics
maintainers             blair
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
master_sites            https://github.com/imageworks/Field3D/tarball/v${version}
platforms               darwin

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

variant universal {}

checksums               md5 e77d4f6e455860291f8e0e0ce547aa50 \
                        sha1 1bbd1c7cadca96d5f0d58f3f2a27241d481e205f \
                        rmd160 89279bbc9906ed7df6052169fb9239f87a2b8cd9

post-extract {
    move [glob ${workpath}/*] ${worksrcpath}
}

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

destroot {
    set sharedir ${destroot}${prefix}/share
    set docdir ${sharedir}/doc/${name}

    set releasedir ${worksrcpath}/install/darwin/m32/release

    foreach f {include/Field3D lib/libField3D.a lib/libField3D.dylib} {
        file copy ${releasedir}/${f} ${destroot}${prefix}/${f}
    }

    xinstall -m 755 -d ${docdir}
    foreach f {CHANGES COPYING README} {
        file copy ${worksrcpath}/$f ${docdir}
    }
}
