#!/bin/sh
# DF-0661 module build script (runs as root in the guest).
# Builds the ported ng_device.ko against the warm obj tree and the
# trigger binary.

set -e
BUILD_DIR="/root/ng_device_build"
KERNBUILDDIR="/usr/obj/usr/src/sys/X86_64_GENERIC"

mkdir -p "$BUILD_DIR"

# ng_device.c and Makefile should already be in BUILD_DIR (pushed from host)
cd "$BUILD_DIR"

echo "=== Building ng_device.ko ==="
make KERNBUILDDIR="$KERNBUILDDIR" 2>&1
echo "=== ng_device.ko built ==="
ls -la ng_device.ko

echo "=== Building trigger ==="
cc -O2 -o trigger trigger.c 2>&1
echo "=== trigger built ==="
ls -la trigger
