update/trees: dont hardcode autoconf/bootstrap arg

at present, the bootstrap and configure script is only
directly executed for grub, because grub is the only
project that uses them in lbmk

however, when i start adding linuxboot support, i will
have to start building a lot of projects, some of which
make use autoconf and bootstrap scripts

e.g.

./bootstrap --foo
./configure --bar

the "bootstrap" script is often used on GNU programs,
because they like to over-engineer absolutely everything

Signed-off-by: Leah Rowe <leah@libreboot.org>
9020vga
Leah Rowe 2023-12-30 16:03:29 +00:00
parent eb3a8e2b53
commit b061558104
2 changed files with 20 additions and 10 deletions

2
config/grub/target.cfg Normal file
View File

@ -0,0 +1,2 @@
bootstrapargs="--gnulib-srcdir=gnulib/ --no-git"
autoconfargs="--with-platform=coreboot"

View File

@ -11,7 +11,8 @@ set -u -e
. "include/git.sh"
eval "$(setvars "" xarch cfgsdir codedir config config_name xlang mode \
elfdir listfile project target target_dir targets tree _f target1)"
elfdir listfile project target target_dir targets tree _f target1 \
bootstrapargs autoconfargs)"
main()
{
@ -34,6 +35,7 @@ main()
[ -z "$_f" ] && err "missing flag (-m/-u/-b/-c/-x/-f/-s/-l/-n)"
[ -z "$project" ] && err "project name not specified"
elfdir="elf/${project}"
cfgsdir="config/${project}"
check_project
@ -47,6 +49,8 @@ build_projects()
[ $# -gt 0 ] && x_ ./update trees $_f $@
[ "$mode" = "fetch" ] && eval "fetch_project_repo; return 0;"
load_target_config "$cfgsdir"
codedir="src/${project}"
[ -d "$codedir" ] || x_ ./update trees -f "$project"
@ -67,7 +71,6 @@ build_targets()
[ "$elfdir" = "elf/coreboot" ] && \
elfdir="elf/coreboot_nopayload_DO_NOT_FLASH"
cfgsdir="config/${project}"
[ -d "$cfgsdir" ] || err "directory, $cfgsdir, does not exist"
listfile="${cfgsdir}/build.list"
@ -127,11 +130,9 @@ handle_src_tree()
target_dir="${cfgsdir}/${target}"
[ "$mode" = "fetch" ] && eval "fetch_project_trees; return 1;"
x_ mkdir -p "${elfdir}/${target}"
eval "$(setvars "" xarch xlang tree)"
load_target_config "$target_dir"
. "${target_dir}/target.cfg" || \
err "handle_src_tree ${target_dir}: cannot load target.cfg"
x_ mkdir -p "${elfdir}/${target}"
[ -z "$tree" ] && err "handle_src_tree $project/$tree: tree unset"
@ -151,6 +152,15 @@ handle_src_tree()
[ -z "$mode" ] && check_cross_compiler; return 0
}
load_target_config()
{
eval "$(setvars "" xarch xlang tree bootstrapargs autoconfargs)"
[ -f "${1}/target.cfg" ] || return 0
. "${1}/target.cfg" || \
err "load_target_config ${1}: cannot load target.cfg"; return 0
}
check_cross_compiler()
{
for _xarch in $xarch; do
@ -223,11 +233,9 @@ check_autoconf()
(
_cfgopt=""
cd "${codedir}" || err "!cd $codedir"
[ "$project" = "grub" ] && _cfgopt="--gnulib-srcdir=gnulib/ --no-git"
[ -f "bootstrap" ] && x_ ./bootstrap $_cfgopt
[ -f "bootstrap" ] && x_ ./bootstrap $bootstrapargs
[ -f "autogen.sh" ] && x_ ./autogen.sh
[ "$project" = "grub" ] && _cfgopt="--with-platform=coreboot"
[ -f "configure" ] && x_ ./configure $_cfgopt; return 0
[ -f "configure" ] && x_ ./configure $autoconfargs; return 0
) || err "can't bootstrap project: $codedir"
}