PortSystem      1.0
PortGroup       php5extension 1.0

php5extension.setup zorba 0.9.9 pecl
revision        1
php5extension.extensions zorba_api
license         PHP
categories      php devel
platforms       darwin
maintainers     ryandesign openmaintainer
description     PHP support for XQuery

long_description \
    This extension is a wrapper of Zorba library to allow PHP developers to \
    use XQuery.

homepage        http://www.zorba-xquery.com/

checksums       md5     68435be7b5be3c7006d524d14f3f7801 \
                sha1    6df7b12072359878052253f8ccc783fa72d751fc \
                rmd160  2dd8ebb5f312e4bf431a2e1bbc342ddfa3f9c518

depends_lib-append \
    port:zorba

configure.args-append \
    --with-zorba_api=${prefix}

configure.cppflags-append \
    -I${prefix}/include/zorba

use_parallel_build yes

post-patch {
    # Library files zorba not found
    # configure: error: Is the zorba_api distribution installed properly?
    reinplace /LIBNAMES/s/zorba/zorba_simplestore/ ${worksrcpath}/config.m4

    # Libraries extension is ".dylib" on Darwin, not ".so"
    reinplace {s/\.so/\.dylib/} ${worksrcpath}/config.m4

    # Header "zorba/zorba.h" is in "${prefix}/include/zorba"
    reinplace {s:/include:/include/zorba:} ${worksrcpath}/config.m4
}

post-destroot {
    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} CREDITS ${destroot}${docdir}
}

livecheck.regex {(\d+(?:\.\d+)*)</a></th>}