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

name                libmemcache
version             1.4.0.rc2
revision            1
checksums           rmd160  b1e55c9ed7d487e3aafb3a85ba2e3386aa2b82f3 \
                    sha256  f496d41092c697384a7180720689da6a85d7c6ea2283eca69c8aaff2b58bebbf \
                    size    301136

categories          devel
license             MIT BSD
platforms           darwin
maintainers         nomaintainer
description         C library for memcached.

long_description    The libmemcache C API to memcached is a \
                    high-performance library with support for multiple \
                    servers, memory contexts, and client-side hashes. \
                    Using the callback interface, it is possible to \
                    lump many gets together into a single get request \
                    with a great deal of ease.

homepage            https://people.freebsd.org/~seanc/libmemcache/
master_sites        ${homepage}/
use_bzip2           yes

depends_lib         port:memcached

patchfiles          CFLAGS.patch \
                    dynamic_lookup-11.patch \
                    implicit.patch

compiler.c_standard 1999

# MacPorts already sets optimization flags.
configure.args-append --disable-optimize

post-destroot {
    xinstall -m 0755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 0644 -W ${worksrcpath} COPYING ChangeLog \
        ${destroot}${prefix}/share/doc/${name}
}

platform darwin arm {
    depends_build-append    port:automake

    post-patch {
        # Use newer config.guess and config.sub to support Apple Silicon.
        set automake_dirs [glob -directory ${prefix}/share automake-*]
        set automake_dir [lindex [lsort -command vercmp $automake_dirs] end]
        copy -force ${automake_dir}/config.guess ${automake_dir}/config.sub \
            ${worksrcpath}
    }
}
