#!/usr/bin/env sh
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2014, 2015, 2020, 2023 Leah Rowe <leah@libreboot.org>
# SPDX-FileCopyrightText: 2015, 2016 Klemens Nanni <contact@autoboot.org>

[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e

. "include/err.sh"

main()
{
	[ -d "grub/" ] || x_ ./update project repo grub
	build_grub
}

build_grub()
{
	(
	x_ cd grub/
	[ ! -d Makefile ] || x_ make distclean
	x_ ./bootstrap --gnulib-srcdir=gnulib/ --no-git
	x_ ./autogen.sh
	x_ ./configure --with-platform=coreboot
	x_ make -j$(nproc) FS_PAYLOAD_MODULES=""
	)
}

main $@