# $Id: Portfile 92837 2012-05-09 00:51:48Z ryandesign@macports.org $

PortSystem      1.0

name            collada-dom
version         2.2
revision        1
set branch      [join [lrange [split ${version} .] 0 1] .]
categories      science devel
maintainers     nomaintainer
platforms       darwin
description     COLLADA Document Object Model (DOM)

long_description \
    The COLLADA Document Object Model (DOM) is an application programming \
    interface (API) that provides a C++ object representation of a COLLADA XML \
    instance document.

homepage        http://collada.org/mediawiki/index.php/Portal:COLLADA_DOM
master_sites    sourceforge
use_zip         yes

checksums       md5     bbb76ef2a8037c945c5cdf26829dcb7d \
                sha1    e6b72ca4c0327fbc342ab87a1d9d76530a980b5d \
                rmd160  b2d4387dfe97d97b30b702f39e4ee312dba6d13a

worksrcdir      ${name}/dom

patchfiles \
    patch-src-dae-daeUtils.cpp.diff \
    patch-test-1.4-domTest.cpp.diff \
    patch-test-1.5-domTest.cpp.diff

post-patch {
    reinplace {s/filter-out x86 ppc/& x86_64/} ${worksrcpath}/Makefile
    reinplace {s/\$(subst x86,i386,\$(archs))/$(subst i386_64,x86_64,&)/} \
        ${worksrcpath}/make/common.mk
    reinplace s:/usr/include:${prefix}/include: ${worksrcpath}/make/dom.mk
    reinplace "s:-lxml2:-L${prefix}/lib &:" ${worksrcpath}/make/dom.mk
    reinplace -E s:-Iexternal-libs/(pcre|boost):-I${prefix}/include: \
        ${worksrcpath}/make/dom.mk \
        ${worksrcpath}/make/domTest.mk
    reinplace s:external-libs/pcre/lib/\\\$(buildID)/:${prefix}/lib/: \
        ${worksrcpath}/make/dom.mk
    reinplace {/libpcre/s/\.a/\.dylib/g} ${worksrcpath}/make/dom.mk
    reinplace -E \
        s:external-libs/boost/lib/\\\$\\(buildID\\)/(libboost_\[a-z\]*)\.a:${prefix}/lib/\\1.dylib: \
        ${worksrcpath}/make/dom.mk ${worksrcpath}/make/domTest.mk
    reinplace {s/# minizip/dependentLibs += $(outPath)libminizip.a/} \
        ${worksrcpath}/make/dom.mk
}

depends_lib \
    port:boost \
    port:libxml2 \
    port:pcre

use_configure   no

variant universal {}

build.args \
    colladaVersion=all \
    parsers=libxml

if {[variant_isset universal]} {
    build.args-append arch="${configure.universal_archs}"
} else {
    build.args-append arch=${build_arch}
}

test.run        yes
test.args       ${build.args}

destroot {
    foreach v {1.4 1.5} {
        set fw Collada[join [split ${v} .] ""]Dom
        set path ${prefix}/Library/Frameworks/${fw}.framework
        copy ${worksrcpath}/build/mac-${v}/${fw}.framework \
            ${destroot}${path}
        set dylib [lindex [glob -tails -types d -directory ${destroot}${path} Versions/*] 0]/${fw}
        system "install_name_tool -id ${path}/${dylib} ${destroot}${path}/${dylib}"
    }

    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} license.txt license/minizip-license.txt \
        readme.txt ${destroot}${docdir}
}

livecheck.type  regex
livecheck.url   http://sourceforge.net/projects/collada-dom/
livecheck.regex {collada-dom-(\d+(?:\.\d+)*)}
