#!/bin/sh -e

kinstall() {
    mkdir -p "${2%/*}"; cp "$3" "$2"
    chmod "$1" "$2"
}

./configure \
    --prefix=/usr \
    --sbindir=/usr/bin \
    --sysconfdir=/etc \
    --enable-hwdb \
    --disable-introspection

make
make DESTDIR="$1" install

# Install runit service.
kinstall 755 "$1/etc/sv/udevd/run" udevd.run
ln -s /run/runit/supervise.udevd "$1/etc/sv/udevd/supervise"

# Install sysmgr service.
kinstall 755 "$1/etc/sysmgr/udevd" udevd.run