# SPDX-License-Identifier: GPL-2.0-or-later
# uACPI -- the ACPI AML interpreter. MIT; see LICENSE in the tarball and
# docs/licensing.md.
#
# Kernel code, like lwIP: nothing is installed into the sysroot. This
# directory fetches and unpacks a pinned release, and the top-level Makefile
# compiles its sources straight into the kernel against kernel/acpi/, which
# supplies everything uACPI asks of a host. That is why there is no build or
# install rule below and no dependency on musl.
#
# Chosen over ACPICA, which does the same job in roughly ten times the code
# and asks more of its host, and over writing an interpreter here: AML is a
# whole language, every firmware vendor's compiler emits its own dialect of
# it, and uACPI is tested against real machines' tables as a matter of course.

include ../mk/port.mk

UACPI_VERSION := 6.1.1
UACPI_URL     := https://github.com/uACPI/uACPI/archive/refs/tags/$(UACPI_VERSION).tar.gz
UACPI_SHA256  := 40f2e278b2080e69f4eaa3384404944874d430e50b72c1066cab2ba476e2b769

TARBALL := $(DISTDIR)/uacpi-$(UACPI_VERSION).tar.gz

$(TARBALL): | $(DISTDIR)
	curl -fsSL -o $@ $(UACPI_URL)
	sh $(SHA256CHECK) "$(UACPI_SHA256)" "$@"

download: $(TARBALL)

$(SRCDIR): $(TARBALL)
	mkdir -p $(PORTDIR)
	cd $(PORTDIR) && tar xzf $(abspath $<)
	mv $(PORTDIR)/uACPI-$(UACPI_VERSION) $@

# The kernel build depends on this directory existing, nothing more.
all: | $(SRCDIR)

install:

clean:
	rm -rf $(PORTDIR)

distclean: clean
	rm -f $(TARBALL)
