# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           gobject_introspection 1.0

name                policykit
version             0.113
revision            2
description         PolicyKit is an application-level toolkit for defining and \
                    handling the policy that allows unprivileged processes to \
                    speak to privileged processes
long_description    ${description}
maintainers         {devans @dbevans} openmaintainer
categories          security
platforms           darwin
license             LGPL-2+
homepage            https://www.freedesktop.org/wiki/Software/polkit/
master_sites        https://www.freedesktop.org/software/polkit/releases/

distname            polkit-${version}

checksums           rmd160  661b0a678f7c770c213404db3af604935fdb25bc \
                    sha256  e1c095093c654951f78f8618d427faf91cf62abdefed98de40ff65eca6413c81

depends_build-append \
                    port:pkgconfig \
                    port:intltool \
                    port:gtk-doc \
                    port:autoconf \
                    port:automake \
                    port:libtool

depends_lib         path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:mozjs17

gobject_introspection yes

patchfiles          patch-configure.ac.diff \
                    patch-getline.diff

pre-patch {
    if {${os.platform} eq "darwin" && ${os.major} < 10} {
        reinplace "s|security/pam|pam/pam|" ${worksrcpath}/configure.ac \
            ${worksrcpath}/src/polkitagent/polkitagenthelper-pam.c \
            ${worksrcpath}/src/programs/pkexec.c
    }
}

# reconfigure using upstream autogen.sh for intltool 0.51 compatibility

post-patch {
    xinstall -m 755 ${filespath}/autogen.sh ${worksrcpath}
}

configure.cmd       ./autogen.sh

configure.cflags-append -I/usr/include
configure.ldflags-append -L/usr/lib

configure.args      --with-authfw=pam \
                    --with-pam-prefix=/etc/pam.d \
                    --with-pam-module-dir=/usr/lib/pam \
                    --with-polkitd-user=polkitd \
                    --with-mozjs=mozjs-17.0 \
                    --enable-systemd=no \
                    --disable-silent-rules \
                    --disable-test \
                    --enable-man-pages \
                    ac_cv_prog_AWK=/usr/bin/awk

destroot.keepdirs   ${destroot}${prefix}/etc/polkit-1/localauthority \
                    ${destroot}${prefix}/var/lib/polkit-1

variant docs description {Build API docs using gtk-doc} {
        configure.args-append --enable-gtk-doc
        depends_build-append  port:gtk-doc
}

add_users           polkitd group=polkitd realname=Policy\ Kit

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