# 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    = "libdrm"
version = "2.4.134"

[source]
tarball = "https://gitlab.freedesktop.org/mesa/libdrm/-/archive/libdrm-2.4.134/libdrm-libdrm-2.4.134.tar.gz"
# FIXME sha256: el wrapper lo calcula (Alpine publica sha512). sha512 de Alpine:
# sha512 = "2e0125b54e77b6910b1a4961cb0bd0b8e9f157b4ddc47b2b72aced82d5080b570c72d65ddde6c0127bb7217abd88ab230dc301dbaf0fa59babe11ba66d2f36e1"
sha256  = "28af861f62e7a2c3a48c5ff2ad4d01cf440a419f7f877de5caa7f73d3afa5367"

[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() {
CFLAGS="$CFLAGS -O2" \
	CPPFLAGS="$CPPFLAGS -O2" \
	CXXFLAGS="$CXXFLAGS -O2" \
	abuild-meson \
		-Db_lto=true \
		-Dintel=enabled \
		-Dradeon=enabled \
		-Damdgpu=enabled \
		-Dnouveau=enabled \
		-Dvmwgfx=enabled \
		-Domap=enabled \
		-Dexynos=enabled \
		-Dfreedreno=enabled \
		-Dtegra=enabled \
		-Dvc4=enabled \
		-Detnaviv=enabled \
		-Dudev=true \
		-Dinstall-test-programs=true \
		-Dtests=true \
		. output
	meson compile -C output
}
_abuild_phase
'''
# de package() de Alpine (traducido $pkgdir→/out):
install = '''
_abuild_phase() {
DESTDIR="/out" meson install --no-rebuild -C output
}
_abuild_phase
'''

[deps]
build = ["linux-headers", "eudev", "libpciaccess", "xmlto"]
