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

github.setup        libpwquality libpwquality 1.4.0 libpwquality-
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            2

license             LGPL-2.1+
categories          devel
maintainers         nomaintainer
description         A library for password quality checking and \
                    the generation of random passwords that \
                    pass the checks.

long_description    {*}${description}

checksums           rmd160  7404be81e78bcace422a38f91ecc3c65e72c8f63 \
                    sha256  1d9f39e946d10fd691ad9667bc6b97ba2b804008f2cc30648f073a4fd42d1bd2

depends_build       port:pkgconfig \
                    port:autoconf \
                    port:automake \
                    port:libtool

depends_lib         port:gettext \
                    port:libiconv \
                    port:cracklib

patchfiles          patch-doc-man-Makefile.am.diff \
                    patch-python-Makefile.am.diff \
                    patch-src-pam_pwquality.c.diff

configure.cmd       ./autogen.sh && ./configure

configure.args      --disable-pam

variant python311 conflicts python310 description {Build python 3.11 bindings} {
    set python_ver          3.11
    depends_lib-append      port:python311
    set python_prefix       ${frameworks_dir}/Python.framework/Versions/${python_ver}
    configure.args-append   --with-python-binary=${prefix}/bin/python${python_ver} \
                            --with-pythonsitedir=${python_prefix}
}

variant python310 conflicts python311 description {Build python 3.10 bindings} {
    set python_ver          3.10
    depends_lib-append      port:python310
    set python_prefix       ${frameworks_dir}/Python.framework/Versions/${python_ver}
    configure.args-append   --with-python-binary=${prefix}/bin/python${python_ver} \
                            --with-pythonsitedir=${python_prefix}
}

if {![variant_isset python310]} {
    default_variants +python311
}

platform darwin {
# On darwin 15 (El Capitan), System Integrity Protection (SIP)
# blocks, by default, any attempt by non-AppStore applications
# to install content in system locations.  This causes
# activation of PAM modules in /usr/lib/pam by MacPorts to fail.
# Disabling optional PAM support on this platform.
    if {${os.major} > 9 && ${os.major} < 15} {
        configure.args-delete --disable-pam
        configure.args-append --with-securedir=/usr/lib/pam \
                              --with-sconfigdir=/etc/security
        # installs PAM modules into /usr/lib/pam
        destroot.violate_mtree yes
    }
}
