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

name                libevent1
github.setup        libevent libevent 1.4.15-stable release-
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
version             [lindex [split ${version} -] 0]
revision            1
categories          devel
license             BSD
maintainers         nomaintainer

description         asynchronous event library

long_description    The libevent API provides a mechanism to execute \
                    a callback function when a specific event occurs \
                    on a file descriptor or after a timeout has been \
                    reached. libevent is meant to replace the \
                    asynchronous event loop found in event driven \
                    network servers. An application just needs to call \
                    event_dispatch() and can then add or remove events \
                    dynamically without having to change the event loop.

homepage            http://libevent.org
dist_subdir         libevent

checksums           rmd160  5813137c24a6581fb530858e6c45ce48c6a9edbe \
                    sha256  92fa504d8f275b7aaceab87f65f0e039c08b1e511acda04cf3822a6e534ab879

post-extract {
    move ${worksrcpath}/configure.in ${worksrcpath}/configure.ac
}

patchfiles          patch-test__test.sh \
                    patch-sierra-kqueue.diff \
                    implicit.patch

if {${os.platform} eq "darwin" && ${os.major} >= 21} {
    # No /usr/bin/python, use python3
    patchfiles-append   python.patch
    post-patch {
        system -W ${worksrcpath} "/usr/bin/python3 -m lib2to3 --write --nobackups --no-diffs ./event_rpcgen.py"
    }
}

use_autoreconf      yes
autoreconf.args     -fvi

configure.args      --program-suffix=-1.4 \
                    --includedir=${prefix}/include/${name} \
                    --libdir=${prefix}/lib/${name}

test.run            yes
test.target         verify

livecheck.url       ${homepage}
livecheck.version   ${version}
livecheck.type      regex
livecheck.regex     libevent-(1(?:\\.\\d+)*)-stable
