#!/bin/sh -e

for file in 0018-prevent-pow-optimization.patch fcommon.patch
do
   patch -p1 < $file
done

# Fix missing <sys/sysmacros.h> include.
sed -i 's@vfs.h>@vfs.h>\n#include <sys/sysmacros.h>@' extlinux/main.c

# Disable debugging and development "stuff".
: > mk/devel.mk

make -j1                     \
    PYTHON=python            \
    bios efi64 installer

make -j1                     \
    INSTALLROOT="$1"         \
    MANDIR=/usr/share/man    \
    SBINDIR=/usr/bin         \
    AUXDIR=/usr/lib/syslinux \
    bios efi64 install
