140 Commits

Author SHA1 Message Date
Leah Rowe 387e6dd771 mk: much safer forx loop
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-17 21:14:08 +01:00
Leah Rowe e1c2525783 lib.sh: make build_sbase a macro
sh macros are cool

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-17 10:40:55 +01:00
Leah Rowe 69875b8e10 xbmk: general cleanup
note: mecleaner check removed in vendor.sh, because
it's already guaranteed to be fetched. the check will
never indicate failure, so we can just assume that
the me cleaner python script exists.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-17 10:33:43 +01:00
Leah Rowe 1722964f66 mk: add safety check for grep -o usage
very unlikely not to have it, but we deal in
certainty, not rm -Rf /

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-17 10:33:43 +01:00
Leah Rowe 856551a36d mk: add forx function for shorthand loops
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-17 01:53:56 +01:00
Leah Rowe 089875ac1f mk: error handling on command -v
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-16 11:43:58 +01:00
Leah Rowe 2dc01a93b9 mk: tidy up xbmk_sanitize_version
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-16 11:21:56 +01:00
Leah Rowe cebae0ed80 mk: rename autoconfargs to configureargs
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-16 10:58:00 +01:00
Leah Rowe d165f14a4d mk: general cleanup and awk appreciation
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-16 10:39:52 +01:00
Leah Rowe 5afd77433d mk: tidy up handle_defconfig
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-16 09:41:40 +01:00
Leah Rowe 08ec187842 wip
defconfig file test unnecessary in check_defconfig
because it's already checked in handle_defconfig

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-16 09:25:55 +01:00
Leah Rowe 2dc4a4d16b mk: clean up run_make_command_real
merge check_cmake with run_make_command_real

tidied up some redundant checks

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-16 07:54:16 +01:00
Leah Rowe ca55077032 mk: tidy up check_cmake
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-16 07:25:31 +01:00
Leah Rowe 113dac006f variable ./mk location, based on user input
when calling ./mk, or from PATH, an absolute path
is created to ./mk

this will likely be different than mk, but it might
be a different script. perhaps the operator is making
a copy of the mk script temporarily - obviously not
advised, no, but here we have a problem because then
lbmk is still running ./mk everywhere

run arg0 instead, now called "mk"

./mk is still hardcoded in release.sh, because we
do need to make sure we're using the right script
there

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-16 05:52:06 +01:00
Leah Rowe 88887c0163 mk: fix check_cross_compiler call
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 22:15:16 +01:00
Leah Rowe 0c41ea82dd mk: move config back to getopt
really pointless doing it here. do it in the loop.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 22:10:37 +01:00
Leah Rowe bbc56b714b fix build error on no-makefile projects
e.g. biosutilities

the subshell screws up error handling. this
patch changes it to old behaviour.

some projects don't have makefiles. the
non-zero exit also prevents further call
to copy_elf when no binaries are created,
as in this example.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 21:17:10 +01:00
Leah Rowe 6a5b4c98d6 mk: clean up getopt flags
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 21:11:51 +01:00
Leah Rowe 50eec6d485 mk: simplify single_tree_build
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 20:58:40 +01:00
Leah Rowe 59cbc1784c mk: remove -c and -x commands (clean/xgcc-clean)
the user never runs these. it's not needed. the design
of lbmk already cleans everything, or caches everything,
between builds. everything cached out of tree.

it's not expected to ever need to clean manually, so just
remove the option. knobs are for nobs.

releases don't need it either, because we tar everything
before building, thus eliminating all build artifacts.
we do this on a fresh copy of lbmk on ./mk release

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 20:38:08 +01:00
Leah Rowe 6725b616f3 mk: skip build if makefile check fails
this was the previous behaviour, and prevents
single-tree builds from proceeding with
use of copy_elf

otherwise you get a bunch of build errors

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 20:24:08 +01:00
Leah Rowe 7507655d34 simplified make-clean handling
no point using distclean, because the context there
is providing clean sources for distribution, but we
use ./mk release which tars everything up before ever
running any build commands.

make-clean is enough

distclean is a stupid gnuism anyway, and most makefiles
that have it will just do the same as clean anyway

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 20:20:03 +01:00
Leah Rowe 2aad50cd59 even more tidy up run_make_command
tidy it all the way up

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 19:51:55 +01:00
Leah Rowe f7b9c9e410 mk: tidy up run_make_command
yeah, this reverses the last change

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 19:03:39 +01:00
Leah Rowe 4878cec84d mk: optimise make-clean check
only check makefiles if if_not_make_clean is set

this avoids unnecessary disk usage

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 18:06:52 +01:00
Leah Rowe 04be963383 mk: remove unnecessary check
on dry builds, if_not_make_clean will also be empty

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 18:06:14 +01:00
Leah Rowe 5043b6dc97 mk: abuse an absurd number of sh macros
just the right amount of absurd

this is why i don't need to use python

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 17:08:05 +01:00
Leah Rowe 828578cc57 mk: use correct elddir for coreboot xgcc
in practise, it was always correct because on projects
that used coreboot xgcc, the tree would always be called
default.

however, this is a bug. the logic uses a correct directory
name for coreboot in src/, but not elf/

this patch makes the two consistent, programattically.

this is therefore a preventative bugfix.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 09:16:28 +01:00
Leah Rowe 7cb4cdf0f2 mk: turn on git-clean by default, except coreboot
libreboot's policy is to thoroughly clean sources per
build, because we cache builds out of tree and avoid
re-builds if they exist; these and the sources are
deleted if metadata in config/ changes per project,
tree and/or target.

the problem is that this change only affects lbmk.git

it doesn't affect release archives, where project sources
do not have git-init applied to them. this will be
addressed.

can't use it on coreboot, because it will delete xgcc
tarballs in a way currently not handled, and handling
it will mean adding a project-specific hack.

the xgcc tarballs could be built out-of-tree, and this
will have to be done, otherwise coreboot will have to be
made gitclean="y" for now.

everything else is fair game.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 18:01:57 +01:00
Leah Rowe 300f2cb434 mk: remove u-boot-specific git-clean handling
yes, make it generalised. use a new variable in
mkhelper.cfg, gitclean and gitcleanargs

not enabled by default, but u-boot enables it. i'm
considering whether to use this by default, as it
is the general policy of lbmk to clean everything
just after a build, as builds are cached out of
tree. this way, we can do re-builds safely for each
project. there are probably a lot of subtle bugs that
might be fixed if we used this

the problem is that this is currently only used on
lbmk.git, but not on libreboot release archives which
lack .git directories; the main one is initialised in
lbmk, but not in upstream sources. we could just initialise
those.

in fact, that is probably what i'm going to do.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 17:46:34 +01:00
Leah Rowe 2c94101884 mk: remove cleanargs from git-clean
totally worthless

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 17:35:19 +01:00
Leah Rowe 08f93ec812 mk: redirect readlink err to /dev/null
i had this before. forgot to add it in the new
design. oops.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 13:23:10 +01:00
Leah Rowe e99be6e5dc mk: ruthlessly simplify findpath()
i love eval, printf and awk

eval, printf and awk are the best things ever

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 12:47:01 +01:00
Leah Rowe e075a79867 err even louder
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 12:27:42 +01:00
Leah Rowe cd52750fec mk: further simplify err()
yes, just awk everything, double-quoted

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 12:25:35 +01:00
Leah Rowe f115bdfe37 mk: add error check on xbmkpwd init
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 12:19:08 +01:00
Leah Rowe 76bf71ff65 mk: simplified findpath()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 12:08:53 +01:00
Leah Rowe c4695497f5 mk: simplified error functions
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 11:54:52 +01:00
Leah Rowe d9ca4265ef mk: remove xprintf
totally useless function. all it does is print
quotes. just printf the args into awk

this does literally the same thing. the output
will literally be the same.

unclear thinking == unclear code

right thinking == this patch

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 11:45:28 +01:00
Leah Rowe b32dd39262 move findpath and err functions to mk
otherwise, it's totally broken. i also now include
lib.sh later.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 11:37:34 +01:00
Leah Rowe c0402ef642 mk: simplify xbmkpwd initialisation
do it from mk instead. we don't need to run pwd
anymore, because we just get the path and cd
to it, setting that as the path.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 11:30:49 +01:00
Leah Rowe 16e04411f2 mk: include lib.sh earlier
this means we can now cd to wrkdir using findpath,
and it means the cd command can be wrapped in x_

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 11:11:04 +01:00
Leah Rowe b09cd4ada4 mk: call xbmk_init through x_
the function never returns 1 at the moment, but
this is a useful future trap.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 11:07:56 +01:00
Leah Rowe abee462f2a mk: run xbmk_init here, not from init.sh
it should be clear on first reading, what the actual
control flow is. hiding the call in init.sh obscures
first reading.

now it is absolutely clear on first reading, that
xbmk_init is called before going through everything
else in mk.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 11:07:24 +01:00
Leah Rowe cb49e77947 delete straggler
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 10:09:22 +01:00
Leah Rowe 93b49afa3f mk: remove gcc/gnat matching logic (obsolete)
coreboot has this now:

commit c421847fe2fef61586eb313206a4be0f2e491974
Author: Matt DeVillier <matt.devillier@gmail.com>
Date:   Mon Dec 29 10:12:17 2025 -0600

    util/crossgcc: Fix GNAT detection for gnat-15

this one is advisory instead, telling the user to
create such a symlink as we did. this is much less
invasive.

our own check was bad, because it basically silences
what is otherwise an error. coreboot's approach is
more correct, so we will defer to that instead.

note that this means older coreboot (for fam15h) is
no longer covered, but those trees don't use gnat
anyway as libgfxinit is unused on those targets

this lbmk patch removes 61 sloc of dead code, which
makes me very happy.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 10:05:16 +01:00
Leah Rowe 6c3791ce81 mk: rename trees() to main()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 09:33:30 +01:00
Leah Rowe d17b06f589 merge tree.sh into mk
mk is so tiny now, and will likely never get
bigger. tree.sh is effectively the main script
now, so let's treat it as such.

i'll start splitting tree.sh instead. e.g.
move gcc setup to its own file.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 09:26:37 +01:00
Leah Rowe 4ebede5b99 tree.sh: fix globbing in multi-tree command args
this solves a bug that does not yet manifest, because
this bug *can't* currently trigger any error due to
lbmk's design. this is therefore a preventative fix,
for reasons that will become clear.

we previously put arguments in a variable, in a way
that didn't handle globbing. now we avoid a variable
and use "$@" instead, which solves the problem.

this also means that the main logic in mk can be
cleaner, as trees-specific control logic is now
placed entirely in tree.sh's main.

this means that we can now also wrap x_ around trees()

this was never a problem in the past, because all of
the arguments for trees commands never have globbing;
config names are always e.g. foo_bar, not foo bar

in commands where globbing did need to be handled,
those commands were never trees commands. e.g.
you had ./mk inject filename

yes, this is a design improvement, or a preventative
bug fix. pick your poison.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 08:06:51 +01:00
Leah Rowe a82328904e mk: clean up printf command
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 00:36:10 +01:00