#!/bin/sh -e

# Install our pre-configured Makefile.
cp makefile.mid ./Makefile

make LDFLAGS="$LDFLAGS -static -fPIC -fno-lto -fno-use-linker-plugin -static"
make DESTDIR="$1" PREFIX=/usr install

echo '#!/bin/sh
exec grep -E "$@"
' >> "$1/usr/bin/egrep"

echo '#!/bin/sh
exec grep -F "$@"
' >> "$1/usr/bin/fgrep"

for i in egrep fgrep
do
    chmod +x "$1/usr/bin/$i"
done

install -Dm700 cron.service "$1/var/sysmgr/"
