# DIFERIDA (frontera): gettext import quedó en versión basura "1.0"; en static-musl se evita con -Dnls=disabled. Reimportar bien si hace falta libintl real.
# 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). Pendiente: el
# sha256 del tarball (el wrapper lo calcula), y adaptar build/install del shell de abuild.
name    = "gettext"
version = "1.0"

[source]
tarball = "https://ftp.gnu.org/gnu/gettext/gettext-1.0.tar.xz"
# FIXME sha256: el wrapper lo calcula (Alpine publica sha512). sha512 de Alpine:
# sha512 = "fa657faf5685dae7121a9b0293d3308a3910a72b90943a7a493b88cf88e95f29c5758e1573320169fe9beac6f101ef76f4165a279a7f3294155d7a773e2fa09f"
sha256  = "71132a3fb71e68245b8f2ac4e9e97137d3e5c02f415636eb508ae607bc01add7"
patches = ["cwd.patch", "skip-tests-musl.patch", "skip-meaningless-pthread-rwlock-test.patch", "skip-unicode-16-tests.patch"]

[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; revisá --shared para estático):
compile = '''
_abuild_phase() {
# force using system posix complaint printf
	# the test is broken and fails with ash
	gt_cv_func_printf_posix=yes \
	./configure \
		--disable-shared --enable-static \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--enable-threads=posix \
		--disable-java \
		--enable-static
	make
}
_abuild_phase
'''
# de package() de Alpine (traducido $pkgdir→/out):
install = '''
_abuild_phase() {
depends="gettext-envsubst=1.0-r$pkgrel"
	make -j1 DESTDIR="/out" install

	# nothing in here is particularly useful, mostly just hello world examples in
	# every single programming language for using gettext
	rm -r "/out"/usr/share/doc
}
_abuild_phase
'''

[deps]
build = ["perl", "ncurses", "libxml2-dev~2.13", "libunistring", "linux-headers"]
