#!/bin/sh
# DF-2902 build: KLD harness that calls mbrinit() with a hostile blksize.
# Run inside the DragonFly guest as root with /usr/src present.
set -e
cd /root/mbrprobe
sed 's/DEV_MODULE(mbrprobe,/DEV_MODULE(mbrprobe_a,/' mbrprobe.c > mbrprobe_a.c
sed 's/DEV_MODULE(mbrprobe,/DEV_MODULE(mbrprobe_b,/' mbrprobe.c > mbrprobe_b.c
for v in a b; do
  mkdir -p $v
  cp mbrprobe_$v.c $v/
  printf 'KMOD=\tmbrprobe_%s\nSRCS=\tmbrprobe_%s.c\nSYSDIR?= /usr/src/sys\n\n.include "${SYSDIR}/conf/kmod.mk"\n' $v $v > $v/Makefile
  ( cd $v && make )
done
