# -*- 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
# $Id: Portfile 107655 2013-07-03 23:07:19Z jeremyhu@macports.org $

PortSystem 1.0

name            policykit
version         0.104
revision        1
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 openmaintainer
categories      security
platforms       darwin
license         LGPL-2+
homepage        http://www.freedesktop.org/wiki/Software/PolicyKit
master_sites    http://hal.freedesktop.org/releases/

distname        polkit-${version}

checksums       rmd160  244e825347a463ff4b9eb0a2318ab04c821bded9 \
                sha256  6b0a13d8381e4a7b7e37c18a54595191b50757e0fcd186cd9918e9ad0f18c7f9

patchfiles      patch-configure.diff \
                patch-setnetgrent-returns-void.diff \
                patch-no-tests.diff

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

# Don't do intltool's INTLTOOL_PERL dance
use_autoreconf  yes
autoreconf.args -fvi

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 \
                --enable-systemd=no \
                --enable-introspection \
                --disable-silent-rules \
                --enable-man-pages \
                --disable-gtk-doc

depends_build   port:pkgconfig \
                port:intltool \
                port:gnome-doc-utils

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

# gobject-introspection uses g-ir-scanner, which uses $CC from env
build.args-append       CC="${configure.cc} ${configure.cc_archflags}"

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-delete --disable-gtk-doc
        depends_build-append  port:gtk-doc
}

add_users       polkituser group=polkituser realname=Policy\ Kit

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