#!/bin/sh -e

export CFLAGS="$CFLAGS -static -fno-stack-protector"
export sbindir="/bin"

./configure

make PREFIX=/usr
make sbindir=/usr/bin DESTDIR="$1" install-stripped

rm -r etc/initdir/sys

mkdir -p "$1/etc/"
mv etc/initdir "$1/etc/initdir"

for file in etc/*
do install -Dm744 $file "$1/etc/"
done

mv init sninit
mv "$1/usr/bin/init" "$1/usr/bin/sninit"
ln -s sninit "$1/usr/bin/init"

