# packages/runit/auxbuild
#

# download and unpack tarball
TARVERSION="1.8.0"
TARDIR="${BUILD_PACKAGE}-${TARVERSION}"
TARBALL="${TARDIR}.tar.gz"
build_download "http://smarden.org/runit/${TARBALL}"
build_unpack "${TARBALL}"
PKGDIR="admin/${TARDIR}"

# yay for crappy build systems
SRCDIR="Distn/${PKGDIR}/src"
mkdir -p "${BUILDROOT}/sbin"

(
    # rather than autoconf, we use different headers depending on system
    cd "${SRCDIR}"
    ln -s iopause.h2 iopause.h
    ln -s reboot_system.h2 reboot_system.h
    ln -s hassgprm.h2 hassgprm.h
    ln -s hassgact.h2 hassgact.h
    ln -s haswaitp.h2 haswaitp.h

    cat > uint64.h <<EOF
#include <stdint.h>
typedef uint64_t uint64;
EOF
)
[ $? -eq 0 ]

# uses a complex Makefile based system, but we only want the `runit' program as `/sbin/init'.
"${ARCH_CC_PREFIX}gcc" ${ARCH_CFLAGS} \
    -o "${BUILDROOT}/sbin/init" \
    "${SRCDIR}/runit.c" \
    "${SRCDIR}/buffer_"{2,put,write}.c \
    "${SRCDIR}/byte_copy.c" \
    "${SRCDIR}/coe.c" \
    "${SRCDIR}/error"{,_str}.c \
    "${SRCDIR}/ndelay_on.c" \
    "${SRCDIR}/open_write.c" \
    "${SRCDIR}/sig"{,_block,_catch,_pause}.c \
    "${SRCDIR}/str_len.c" \
    "${SRCDIR}/strerr"{_die,_sys}.c \
    "${SRCDIR}/wait"{_nohang,_pid}.c


true
# vim: ts=4:sw=4:expandtab:syntax=sh
