# -*- 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        google google-authenticator-libpam 1.06
name                pam-google-authenticator
categories          security
platforms           darwin
maintainers         {eborisch @eborisch} openmaintainer
license             apache-2 

description         Pluggable Authentication Module for Google Authenticator

long_description    The Google Authenticator PAM module provides an easy way \
                    use Google's 2FA (via Google Authenticator app) to your \
                    existing user authentication infrastructure.

checksums \
    rmd160  d71e5d0d3a3a351ce7c6533a288eda42c8fee620 \
    sha256  ff4a33db224ab78b5aae5a2a47d5b18da6847b6874a98d03fd9b2b6fa734262f \
    size    62303

depends_run-append      port:qrencode

# While this isn't needed to compile, the application (setup) portion uses
# dlopen to opportunistically load libqrencode. This dependency is recorded
# above, but application needs the prefix/lib directory in the search path to
# find it.
configure.ldflags-append    -Wl,-rpath -Wl,${prefix}/lib

patch {
    # Match pam-u2f's location for consistency
    reinplace "s|/security|/pam|" Makefile.am
}

use_autoreconf          yes
autoreconf.args         --install

post-destroot {
    xinstall -m 0644 ${worksrcpath}/LICENSE \
        ${destroot}${prefix}/share/doc/google-authenticator/
}

notes "
Create a file for a new service in /etc/pam.d/ or edit
an already existing one by adding a line similar to this:

auth required ${prefix}/lib/pam/pam_google_authenticator.so

See man google-authenticator and pam_google_authenticator or
https://github.com/google/google-authenticator-libpam for details
"