# 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    = "mutt"
version = "2.4.0"

[source]
tarball = "http://ftp.mutt.org/pub/mutt/mutt-2.4.0.tar.gz"
# FIXME sha256: el wrapper lo calcula (Alpine publica sha512). sha512 de Alpine:
# sha512 = "c0c849136be8eb8dcc4b45c5a602e17e3f4405cb1d9bb82f18ca01d7fd2e0bef176b67676528e340e430ae00632925d255b5a4cd195cb4addaa2341a71e2b23d"
sha256  = "8f6ca2ef42f8f07cdc8ec391e8aa41a702490eae55ac72016b0b94ddf44ae292"

[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() {
ISPELL=/usr/bin/hunspell \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--enable-imap \
		--enable-pop \
		--enable-smtp \
		--enable-hcache \
		--enable-gpgme \
		--enable-sidebar \
		--with-curses \
		--with-mailpath=/var/mail \
		--with-docdir=/usr/share/doc/mutt \
		--without-included-gettext \
		--with-ssl \
		--with-gsasl \
		--with-idn2
	make
}
_abuild_phase
'''
# de package() de Alpine (traducido $pkgdir→/out):
install = '''
_abuild_phase() {
make DESTDIR="/out" install

	rm -f "/out"/etc/*.dist \
		"/out"/etc/mime.types

	# Don't tamper with the global configuration file.
	# Many options set in the global config cannot be
	# overwritten in the users configuration file.
	# Example: Resetting colors isn't possible.
	install -Dm644 contrib/gpg.rc \
		"/out"/etc/Muttrc.gpg.dist
}
_abuild_phase
'''

[deps]
build = ["elinks", "docbook-xml", "docbook-xsl", "gdbm", "gettext", "gpgme", "libidn2", "libgsasl", "ncurses", "openssl-dev>3", "perl"]
