# -*- 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                    courier-authlib
version                 0.72.1
revision                0
checksums               rmd160  c25d2a2b1945f58779353f739d532319e65edddf \
                        sha256  1ca3cca191a7f1a973312f4b68da4d45986f006ac1323a71bf10193891c44585 \
                        size    2288448

categories              security mail
license                 GPL-3
maintainers             nomaintainer
description             Courier Authentication Library is a generic authentication API
long_description        {*}${description}

homepage                https://www.courier-mta.org/authlib/
master_sites            sourceforge:project/courier/authlib/${version}
use_bzip2               yes


depends_build-append    port:pkgconfig

depends_lib-append      port:db48 \
                        port:gmake \
                        port:libidn2 \
                        port:libtool \
                        port:courier-unicode

configure.args          --with-db=db \
                        --without-authmysql \
                        --without-authpgsql \
                        --without-authldap \
                        --without-authpam \
                        -C

configure.env-append    MAKE="gmake"
configure.args-append   MAKE="gmake"

configure.cflags-append -I${prefix}/include/db48
configure.ldflags-append \
                        -L${prefix}/lib/db48

patchfiles-append       patch-remove-dtag-configure.diff

build.cmd               ${prefix}/bin/gmake

post-extract {
    foreach _file {install-sh config.guess config.sub} {
        reinplace -E {s|#!/usr/bin/sh|#!/usr/bin/env sh|} ${_file}
    }
}

post-destroot {
    system -W "${destroot}${prefix}/lib/courier-authlib" "rm -f *.a *.la"
}

startupitem.create      yes
startupitem.start       "${prefix}/sbin/authdaemond start"
startupitem.stop        "${prefix}/sbin/authdaemond stop"
startupitem.restart     "${prefix}/sbin/authdaemond restart"
startupitem.pidfile     clean ${prefix}/var/spool/authdaemon/pid

# Limit the length of the minor and patch version components to avoid picking
# up development versions (that contain a YYYYMMDD timestamp).
livecheck.regex         "[quotemeta ${name}]-(\\d+(\\.\\d{1,7})*)[quotemeta ${extract.suffix}]"