pkg_name=mdevd
version=0.1.8.2
revision=8
build_style=configure
short_desc="Mdev-compatible Linux hotplug manager daemon"
home_page="https://skarnet.org/software/mdevd"
license="ISC"
dist_files="https://skarnet.org/software/mdevd/mdevd-${version}.tar.gz"
checksum="74975dbb8f48f60076aaf85ffe44a9eb892155ad9e9481f08c1fae8382b9b835"

use_flags="-nsss static services doc"

depends="skalibs"
make_depends="skalibs"
use_depends="$(use_if static skalibs:static)"

configure_args="
    --sysconfdir=/etc
    --bindir=/usr/bin
    --libdir=/usr/lib
    --dynlibdir=/usr/lib
    --libexecdir=/usr/libexec
    --includedir=/usr/include
    --with-sysdeps=/usr/lib/skalibs/sysdeps
    --disable-rpath
    $(use_if nsss --enable-nsss --disable-nsss)
    $(use_if static --enable-static --disable-static)
    $(use_if static --enable-allstatic --disable-allstatic)
    $(use_if static --disable-shared --enable-shared)"

post_install() {
    if use doc; then
        bcopy doc/. "/usr/share/doc/$pkg_name"
    fi
    blicense COPYING

    bconf "$FILESDIR/mdev.conf"

    if use services; then
        bcopy "$FILESDIR/sv/." /etc/sv
        find "$DESTDIR/etc/sv" -type f \
            \( -name run -o -name setup -o -name finish \) -exec chmod 0755 {} +
    fi
}
