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

PortSystem          1.0

name                libpwquality
version             1.3.0
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}

platforms           darwin

homepage            https://fedorahosted.org/${name}/
master_sites        https://fedorahosted.org/releases/l/i/${name}/

use_bzip2           yes

checksums           rmd160  5ca6e8eea9c3ee277ecb9aa9b2875748fe3ff000 \
                    sha256  74d2ea90e103323c1f2d6a6cc9617cdae6877573eddb31aaf31a40f354cc2d2a

depends_build       port:pkgconfig

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

patchfiles          patch-python-Makefile.in.diff \
                    patch-src-pam_pwquality.c.diff

configure.args       --disable-pam

variant python27 conflicts python34 description {Build python 2.7 bindings} {
    set python_ver          2.7
    depends_lib-append      port:python27
    set python_prefix       ${frameworks_dir}/Python.framework/Versions/${python_ver}
    set python_site_path    ${python_prefix}/lib/python${python_ver}/site-packages
    configure.args-append   --with-python-binary=${prefix}/bin/python${python_ver} \
                            --with-pythonsitedir=${python_site_path}
}

variant python34 conflicts python27 description {Build python 3.4 bindings} {
    set python_ver          3.4
    depends_lib-append      port:python34
    set python_prefix       ${frameworks_dir}/Python.framework/Versions/${python_ver}
    set python_site_path    ${python_prefix}/lib/python${python_ver}/site-packages
    configure.args-append   --with-python-binary=${prefix}/bin/python${python_ver} \
                            --with-pythonsitedir=${python_site_path}
}

if {![variant_isset python27]} {
    default_variants +python34
}

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
    }
}

livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"