# $Id: Portfile 64728 2010-03-15 13:12:00Z nox@macports.org $

PortSystem      1.0
PortGroup       archcheck 1.0
PortGroup       cmake 1.0

name            zorba
version         1.0.0
license         Apache-2
categories      textproc devel
platforms       darwin
maintainers     nox openmaintainer
description     The XQuery Processor

long_description \
    Zorba is a general purpose XQuery processor implementing in C++ the W3C \
    family of specifications. It is not an XML database. The query processor \
    has been designed to be embeddable in a variety of environments such as \
    other programming languages extended with XML processing capabilities, \
    browsers, database servers, XML message dispatchers, or smartphones. Its \
    architecture employes a modular design, which allows customizing the Zorba \
    query processor to the environment’s needs. In particular the architecture \
    of the query processor allows a pluggable XML store (e.g. main memory, DOM \
    stores, persistent disk-based large stores, S3 stores).

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

checksums       md5     79c3ff5ae9016b0bc203c96175b3c281 \
                sha1    0d8ec92881a501f686f8ecd42d1546c6ff2f2b58 \
                rmd160  dd4ac37f0e19d9ae2988a6b3eab4b9385e8db634

# In-source-builds are not allowed
worksrcdir      ${distname}/build

post-extract {
    xinstall -d ${worksrcpath}
}

patch.dir       ${worksrcpath}/..

patchfiles \
    patch-SchemaValidatorFilter-resolveQName.diff \
    patch-XMLValid-NoSubforBlock.diff

post-patch {
    # Do not install dependencies' libraries
    reinplace s/APPLE/FALSE/ ${patch.dir}/src/CMakeLists.txt

    # Disable erroneous Apple-specific flags
    reinplace {s/( *APPLE *)/(FALSE)/} ${patch.dir}/CMakeCompiler.txt

    # XMLScanner::loadGrammar's toCache argument is optional
    reinplace {s/toCache/toCache = false/} \
        ${patch.dir}/src/types/schema/SchemaValidatorFilter.h

    # Install documentation in a unversioned directory
    reinplace {s/zorba-[^/)]*/zorba/} \
        ${patch.dir}/doc/c/examples/CMakeLists.txt \
        ${patch.dir}/doc/CMakeLists.txt \
        ${patch.dir}/doc/cxx/examples/CMakeLists.txt

    # Disable SWIG bindings documentation
    reinplace /FIND_PACKAGE(SWIG)/d \
        ${patch.dir}/doc/CMakeLists.txt
}

depends_build-append \
    port:bison \
    port:flex

depends_lib \
    port:boost \
    port:curl \
    port:icu \
    port:libiconv \
    port:libxml2 \
    port:libxslt \
    port:xercesc3 \
    port:tidy

archcheck.files \
    lib/libboost_program_options-mt.dylib \
    lib/libcurl.dylib \
    lib/libiconv.dylib \
    lib/libicuuc.dylib \
    lib/libxml2.dylib \
    lib/libxslt.dylib \
    lib/libxerces-c.dylib \
    lib/libtidy.dylib \
    lib/libz.dylib

configure.post_args ..
configure.args-append \
    -DCMAKE_INSTALL_NAME_DIR=${prefix}/lib \
    -DCURL_FOUND=YES \
    -DCURL_INCLUDE_DIR=${prefix}/include \
    -DCURL_LIBRARY=${prefix}/lib/libcurl.dylib \
    -DZORBA_USE_SWIG=NO \
    -DZORBA_XQUERYX=YES

test.env DYLD_LIBRARY_PATH=${worksrcpath}/src
test.run yes

livecheck.type  regex
livecheck.url   ${homepage}index.php/download/
livecheck.regex {zorba-(\d+(?:\.\d+)*)\.}
