# Importada de Alpine aports por `hammer import-alpine` (Etapa G). PUNTO DE PARTIDA — pero
# YA trae los parches de musl de Alpine (lo que un import de nix pierde). Adaptada al tarball
# limpio de GNU (5.3 base, sin los parches upstream), build estático musl.
name    = "bash"
version = "5.3"

[source]
tarball = "https://ftp.gnu.org/gnu/bash/bash-5.3.tar.gz"
sha256  = "0d5cd86965f869a26cf64f4b71be7b96f90a3ba8b3d74e27e8e9d9d5550f31ba"

[build]
compiler = "zig-cc"
target   = "x86_64-linux-musl"
link     = "static"
flags    = []

[build.phases]
# de build() de Alpine (traducido; el lab provee $CBUILD/$CHOST — Etapa G Fase 3):
compile = '''
_abuild_phase() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--bindir=/bin \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--disable-nls \
		--enable-readline \
		--without-bash-malloc \
		--without-installed-readline
	# parallel build workarounds
	make y.tab.c && make builtins/libbuiltins.a && make
}
_abuild_phase
'''
# de package() de Alpine (traducido $pkgdir→/out); sin bashrc/profile (ficheros ausentes):
install = '''
_abuild_phase() {
	mkdir -p "/out"/etc/bash
	make DESTDIR="/out" install
	rm -rf "/out"/usr/share/locale
}
_abuild_phase
'''

[deps]
build = ["ncurses", "readline", "linux-headers"]
