heads/modules/bash
Jonathon Hall e0b46d086a
functions: TRACE_FUNC and DEBUG_STACK
Add TRACE_FUNC to trace the file, line, and name of the calling
function.  File and function names don't have to be duplicated in a
TRACE statement with this (they tend to become inaccurate as functions
are renamed and the TRACE statement is forgotten).

Add DEBUG_STACK to dump the bash stack to debug output.

Configure bash with --enable-debugger.  Bash doesn't actually include
the entire debugger, this is just some supporting variables for it.
Evidently, BASH_SOURCE[n] is only set within a function if this is
enabled.  I couldn't find this indicated in any documentation, but it
happened in practice.

Compressed initrd size only increased by 2560 bytes for librem_mini_v2,
I think that is fine.  This also gives us BASH_ARGC/BASH_ARGV which
might be useful for diagnostics.

Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm>
2024-01-17 16:32:37 -05:00

36 lines
1.0 KiB
Makefile

# GNU bash
modules-$(CONFIG_BASH) += bash
bash_version := 5.1.16
bash_dir := bash-$(bash_version)
bash_tar := bash-$(bash_version).tar.gz
bash_url := https://ftpmirror.gnu.org/bash/$(bash_tar)
bash_hash := 5bac17218d3911834520dad13cd1f85ab944e1c09ae1aba55906be1f8192f558
# --enable-debugger: Enables BASH_SOURCE tracing through functions as well as
# BASH_ARGV/BASH_ARGC. (Otherwise BASH_SOURCE[0] is empty when calling a
# function, it's only set in top level script code.)
bash_configure := CFLAGS="-g0 -Os" LDFLAGS="-s" ./configure \
$(CROSS_TOOLS) \
--host $(target) \
--prefix="/usr" \
--enable-largefile \
--infodir=/usr/share/info \
--mandir=/usr/share/man \
--without-bash-malloc \
--disable-coprocesses \
--enable-debugger \
--disable-net-redirections \
--enable-single-help-strings \
--disable-nls \
--disable-readline \
bash_target := $(MAKE_JOBS) \
&& $(MAKE) -C $(build)/$(bash_dir) \
DESTDIR="$(INSTALL)" \
install \
bash_output := bash
bash_depends := $(musl_dep)