# -*- 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

PortSystem          1.0
PortGroup           boost 1.0
PortGroup           github 1.0
PortGroup           muniversal 1.0
PortGroup           openssl 1.0

github.setup        gearman gearmand 1.1.20
revision            0
categories          sysutils net devel
maintainers         nomaintainer
license             BSD

description         Framework for distributed computation
long_description    \
        Gearman provides a generic application framework to farm out work \
        to other machines or processes that are better suited to do the work. \
        It allows you to do work in parallel, to load balance processing, \
        and to call functions between languages. It can be used in a variety \
        of applications, from high-availability web sites to the transport of \
        database replication events. In other words, it is the nervous system \
        for how distributed processing communicates.

homepage            http://gearman.org/
github.tarball_from releases

checksums           rmd160  f2276d881fa2a8ffd5181a30dcf9afb8df680487 \
                    sha256  2f60fa207dcd730595ef96a9dc3ca899566707c8176106b3c63ecf47edc147a6 \
                    size    1103071

depends_build-append \
                    path:bin/pkg-config:pkgconfig

depends_lib-append  port:curl \
                    port:libevent

if {${configure.cxx_stdlib} eq "libstdc++"} {
    patchfiles-append   patch-libgearman-1.0-gearman.h.diff
}

configure.args-append \
                    --disable-silent-rules \
                    --disable-hiredis \
                    --disable-libdrizzle \
                    --disable-libpq \
                    --disable-libmemcached \
                    --disable-libtokyocabinet \
                    --disable-wolfssl \
                    --enable-jobserver=${build.jobs} \
                    --enable-ssl \
                    --without-mysql \
                    --without-sqlite3 \
                    --with-boost=[boost::install_area]

compiler.cxx_standard 2011
compiler.thread_local_storage yes

# gearmand handles parallel building using the --enable-jobserver arg above.
use_parallel_build  no

post-destroot {
    set docdir ${prefix}/share/doc/${subport}
    xinstall -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} \
        AUTHORS \
        ChangeLog \
        COPYING \
        NEWS \
        README.md \
        THANKS \
        ${destroot}${docdir}
}

platform darwin {
    if {${os.major} >= 14} {
        configure.cxxflags-append -DHAVE_HTONLL
    }
}

variant dtrace description {Enable DTrace probes} {
    configure.args-append   --enable-dtrace
}

variant sqlite description {Build with sqlite3 support} {
    depends_lib-append      port:sqlite3
    configure.args-delete   --without-sqlite3
}
variant drizzle description {Build with libdrizzle support} {
    depends_lib-append      port:libdrizzle
    configure.args-replace  --disable-libdrizzle --enable-libdrizzle
}

variant postgres description {Build with postgresql support} {
    depends_lib-append      port:libpqxx
    configure.args-replace  --disable-libpq --enable-libpq
}

variant memcached description {Build with memcached support} {
    depends_lib-append      port:libmemcached
    configure.args-replace  --disable-libmemcached --enable-libmemcached
}

variant tokyocabinet description {Build with tokyocabinet support} {
    depends_lib-append      port:tokyocabinet
    configure.args-replace  --disable-libtokyocabinet --enable-libtokyocabinet
}

variant redis description {Build with redis support using hiredis} {
    depends_lib-append      port:hiredis
    configure.args-replace  --disable-hiredis --enable-hiredis
}

default_variants +sqlite

startupitem.create  yes
startupitem.executable  ${prefix}/sbin/gearmand \
                        --verbose=WARNING \
                        --port=4730 \
                        -u root \
                        --pid-file=${prefix}/var/run/gearmand.pid \
                        --log-file=${prefix}/var/log/gearmand.log
