2019-08-10 19:38:27 -06:00
|
|
|
#!/bin/sh -e
|
|
|
|
|
2020-03-05 10:17:42 -07:00
|
|
|
# Grub expects Python but it isn't actually needed. Give
|
|
|
|
# it something fake so that configure passes.
|
|
|
|
export PYTHON=/bin/true
|
|
|
|
|
|
|
|
# Disable the post-python mv calls as a means of disabling
|
|
|
|
# the Python tooling. The /bin/true above will create a
|
|
|
|
# blank file, this prevents the blank file from overwriting
|
|
|
|
# the existing one.
|
2021-07-03 14:22:55 -06:00
|
|
|
for f in ./*/Makefile.in; do
|
|
|
|
sed 's/mv $@.new $@/:/g' "$f" > _
|
|
|
|
mv -f _ "$f"
|
|
|
|
done
|
2020-03-05 10:17:42 -07:00
|
|
|
|
2020-02-11 09:55:35 -07:00
|
|
|
# Strip '-march' from 'CFLAGS' as per advice from upstream.
|
|
|
|
# Fixes build fails on specific hardware.
|
2021-08-16 03:23:40 -06:00
|
|
|
export CFLAGS
|
|
|
|
CFLAGS=$(printf %s "$CFLAGS" | sed 's/-march=[^ ]*//g')
|
|
|
|
|
2023-03-02 07:40:00 -07:00
|
|
|
pkg_dir=$1
|
|
|
|
|
2021-08-16 03:23:40 -06:00
|
|
|
# Force bfd linker to fix issues with alternative linkers. Mold does not yet
|
|
|
|
# have full linker script support and I'm not certain that lld or gold have
|
|
|
|
# ever worked to build Grub.
|
|
|
|
{
|
|
|
|
mkdir -p .bin
|
2022-03-28 04:45:32 -06:00
|
|
|
bfd_path=$(command -v ld.bfd)
|
|
|
|
ln -s "${bfd_path:?}" .bin/ld
|
2022-09-27 11:20:09 -06:00
|
|
|
export PATH="$PWD/.bin:$PATH"
|
2021-08-16 03:23:40 -06:00
|
|
|
|
|
|
|
# Strip '-B<path>mold' and '--ld-path=<path>mold' from CFLAGS.
|
|
|
|
case $CFLAGS in *mold*)
|
|
|
|
CFLAGS=$(printf %s "$CFLAGS" | sed 's/-B[^ ]*//g;s/--ld-path=[^ ]*//g')
|
|
|
|
esac
|
|
|
|
}
|
2020-02-11 09:55:35 -07:00
|
|
|
|
2019-08-10 19:38:27 -06:00
|
|
|
build_grub() (
|
|
|
|
cd "grub-${1##*=}"
|
|
|
|
|
2024-02-04 23:32:19 -07:00
|
|
|
patch -p1 < ../no-asorti.patch
|
|
|
|
|
|
|
|
# This file is missing from the release tarball.
|
|
|
|
touch grub-core/extra_deps.lst
|
|
|
|
|
2019-08-10 19:38:27 -06:00
|
|
|
./configure \
|
2021-08-22 03:40:06 -06:00
|
|
|
HELP2MAN="$OLDPWD/help2man" \
|
2019-08-10 19:38:27 -06:00
|
|
|
--prefix=/usr \
|
|
|
|
--sbindir=/usr/bin \
|
|
|
|
--sysconfdir=/etc \
|
|
|
|
--disable-werror \
|
2020-03-05 09:39:48 -07:00
|
|
|
--disable-nls \
|
2019-08-17 20:18:05 -06:00
|
|
|
--disable-grub-mkfont \
|
|
|
|
--disable-grub-mount \
|
2019-08-10 19:38:27 -06:00
|
|
|
"$@"
|
|
|
|
|
|
|
|
make
|
2023-03-02 07:40:00 -07:00
|
|
|
make DESTDIR="$pkg_dir" install
|
2019-08-10 19:38:27 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
build_grub --with-platform=pc
|
|
|
|
build_grub --with-platform=efi --disable-efiemu
|
|
|
|
|
2021-07-01 10:17:07 -06:00
|
|
|
mkdir -p "$1/etc/default"
|
|
|
|
cp -f grub.default "$1/etc/default/grub"
|
2019-08-10 19:38:27 -06:00
|
|
|
|
|
|
|
# Remove gdb debugging files.
|
|
|
|
(
|
2021-07-15 06:19:33 -06:00
|
|
|
cd "$1/usr/lib"
|
2019-09-07 09:14:04 -06:00
|
|
|
|
|
|
|
rm -f grub/*/*.module
|
|
|
|
rm -f grub/*/*.image
|
|
|
|
rm -f grub/*/kernel.exec
|
|
|
|
rm -f grub/*/gdb_grub
|
|
|
|
rm -f grub/*/gmodule.pl
|
|
|
|
)
|