# -*- 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
# $Id: Portfile 118687 2014-04-08 03:49:48Z ryandesign@macports.org $

PortSystem 1.0
PortGroup               muniversal 1.0

name                    memcached
version                 1.4.17
description             A high performance, distributed memory object caching system.
long_description        Memcached is a high-performance, distributed memory object \
    caching system, generic in nature, but intended for use in \
    speeding up dynamic web applications by alleviating database load.
maintainers             nomaintainer
license                 BSD
categories              sysutils
platforms               darwin
installs_libs           no

homepage                http://memcached.org/
master_sites            ${homepage}files/

checksums               rmd160  328139b5cbf225265987b3af28f67a0c5187493d \
                        sha256  d9173ef6d99ba798c982ea4566cb4f0e64eb23859fdbf9926a89999d8cdc0458

configure.args          --with-libevent=${prefix} \
                        ac_cv_search_umem_cache_create=no \
                        ac_cv_header_umem_h=no

depends_lib             port:libevent

startupitem.create      yes
startupitem.executable  ${prefix}/bin/memcached -u nobody -m 64 -c 10240 -p 11211

if {[variant_isset universal]} {
    set merger_configure_args(x86_64) --enable-64bit
    set merger_configure_args(ppc64)  --enable-64bit
} else {
    if {[info exists build_arch] && (${build_arch} eq "x86_64" || ${build_arch} eq "ppc64")} {
                configure.args-append --enable-64bit
    }
}

post-patch {
    # http://code.google.com/p/memcached/issues/detail?id=285
    reinplace "s|-Werror||g" ${worksrcpath}/configure ${worksrcpath}/doc/Makefile
}

variant sasl description {enable SASL authentication} {
    configure.args-append   --enable-sasl
}

variant umem description {enable libumem support} {
    depends_lib-append     port:umem
    configure.args-delete  ac_cv_search_umem_cache_create=no
    configure.args-delete  ac_cv_header_umem_h=no
}

livecheck.type  regex
livecheck.regex ${name}-(\\d+(?:\\.\\d+){2,})\\.
